SoapDocumentMethodAttribute.ResponseElementName 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定與 XML Web 服務方法相關的 SOAP 回應相關的 XML 元素。
public:
property System::String ^ ResponseElementName { System::String ^ get(); void set(System::String ^ value); };
public string ResponseElementName { get; set; }
member this.ResponseElementName : string with get, set
Public Property ResponseElementName As String
屬性值
與 SOAP 請求相關的 XML 元素,用於 XML Web 服務方法。 預設值為 WebServiceNameResult,其中 WebServiceName 是 XML Web 服務方法的名稱。
範例
以下程式碼範例將 SOAP 回應中與 XML Web 服務方法相關聯的 XML 元素名稱設為 MyCustomResponseElement。
<%@ WebService Language="C#" Class="SoapDocumentMethodSample" %>
using System.Web.Services;
using System.Web.Services.Protocols;
public class SoapDocumentMethodSample
{
[WebMethod]
[SoapDocumentMethod(ResponseNamespace="http://www.contoso.com",ResponseElementName="MyCustomResponseElement")]
public int[] ResponseDocument(int numentries)
{
int[] intarray = new int[numentries];
for (int i=0;i<numentries;i++)
{
intarray[i] = i;
}
return intarray;
}
}
<%@ WebService Language="VB" Class="SoapDocumentMethodSample" %>
Imports System.Web.Services
Imports System.Web.Services.Protocols
Public Class SoapDocumentMethodSample
<WebMethod(),SoapDocumentMethod(ResponseNamespace :="http://www.contoso.com",ResponseElementName := "MyCustomResponseElement")> _
Public Function ResponseDocument(numentries as Integer) As Integer()
Dim intarray(numentries - 1) as Integer
Dim i as Integer
For i = 0 To numentries - 1
intarray(i) = i
Next
Return intarray
End Function
End Class
備註
定義 ResponseElementName 了用來包裹 SOAP 回應元素下方 Body 參數的 XML 元素,當 ParameterStyle 為 Wrapped時。 這反映在 XML Web 服務描述中,XSD 架構代表 SOAP 對 XML Web 服務方法的回應。