共用方式為


SoapHttpClientProtocol.SoapVersion 屬性

定義

取得或設定 SOAP 通訊協定的版本,用於對 XML Web Service 發出 SOAP 要求。

public:
 property System::Web::Services::Protocols::SoapProtocolVersion SoapVersion { System::Web::Services::Protocols::SoapProtocolVersion get(); void set(System::Web::Services::Protocols::SoapProtocolVersion value); };
[System.Runtime.InteropServices.ComVisible(false)]
public System.Web.Services.Protocols.SoapProtocolVersion SoapVersion { get; set; }
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.SoapVersion : System.Web.Services.Protocols.SoapProtocolVersion with get, set
Public Property SoapVersion As SoapProtocolVersion

屬性值

SoapProtocolVersion

其中一個 SoapProtocolVersion 值。 預設為 Soap11

屬性

範例

下列程式碼範例會將用來與 XML Web 服務通訊的通訊協定版本設定為 SOAP 1.2。

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Web.Services.Protocols" %>

<html>

    <script runat="server">

        void EnterBtn_Click(Object Src, EventArgs E) 
    {
      // Create a new instance of a proxy class for your XML Web service.
      ServerUsage su = new ServerUsage();
            
          // Specifies that SOAP 1.2 is used communicate with the XML Web service.
         su.SoapVersion = SoapProtocolVersion.Soap12;

      // Invoke an XML Web service method that uses session state and thus cookies.
      int count = su.PerSessionServiceUsage();         
       }
         
    </script>
    <body>
       <form runat=server ID="Form1">
           
             Click to bump up the Session Counter.
             <p>
             <asp:button text="Bump Up Counter" Onclick="EnterBtn_Click" runat=server ID="Button1" NAME="Button1"/>
             <p>
             <asp:label id="SessionCount"  runat=server/>
          
       </form>
    </body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Web.Services.Protocols" %>

<html>

    <script runat=server>

        Public Sub EnterBtn_Click(src As Object, E As EventArgs) 

      ' Create a new instance of a proxy class for your XML Web service.
      Dim su As ServerUsage = new ServerUsage()

          ' Specifies that SOAP 1.2 is used communicate with the XML Web service.
          su.SoapVersion = SoapProtocolVersion.Soap12

      ' Invoke an XML Web service method that uses session state and thus cookies.
      Dim count As Integer = su.PerSessionServiceUsage()         
    End Sub
         
    </script>
    <body>
       <form runat=server ID="Form1">
           
             Click to bump up the Session Counter.
             <p>
             <asp:button text="Bump Up Counter" Onclick="EnterBtn_Click" runat=server ID="Button1" NAME="Button1"/>
             <p>
             <asp:label id="SessionCount"  runat=server/>
          
       </form>
    </body>
</html>

備註

SoapVersion當 XML Web 服務的 WSDL 檔案支援 SOAP 1.1 版時,屬性會在 Web 服務描述語言工具 (Wsdl.exe 產生的 Proxy 類別中設定為 Soap11) 。 不過,當 XML Web 服務只支援 SOAP 1.2 時,Wsdl.exe將 SoapVersion 屬性設定為 Soap12 。 若要使用 Wsdl.exe 產生 Proxy 類別時選擇 SOAP 通訊協定的版本,請使用 /protocol 參數搭配 SOAPSOAP12 設定,分別將 SoapVersion 屬性設定為 Soap11Soap12

適用於

另請參閱