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
下面的代码示例将用于与 XML Web 服务通信的协议版本设置为 SOAP 1.2。
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Web.Services.Protocols" %>
<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>
<form runat=server ID="Form1">
Click to bump up the Session Counter.
<asp:button text="Bump Up Counter" Onclick="EnterBtn_Click" runat=server ID="Button1" NAME="Button1"/>
<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" %>
<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>
<form runat=server ID="Form1">
Click to bump up the Session Counter.
<asp:button text="Bump Up Counter" Onclick="EnterBtn_Click" runat=server ID="Button1" NAME="Button1"/>
<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。