SoapHttpClientProtocol.SoapVersion 属性

定义

获取或设置用于对 XML Web services 修改的 SOAP 请求的 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>

注解

当 XML Web 服务的 WSDL 文档支持 SOAP 版本 1.1 时,此属性 SoapVersion 在 Web 服务描述语言工具 (Wsdl.exe) 生成的 Soap11 代理类中设置为默认。 但是,当 XML Web 服务仅支持 SOAP 1.2 时,Wsdl.exe将 SoapVersion 属性设置为 Soap12。 若要在生成具有Wsdl.exe的代理类时选择 SOAP 协议的版本,请使用/protocol开关和SOAP``SOAP12设置分别将属性Soap11设置为SoapVersion和设置Soap12

适用于

另请参阅