使用SOAP 1.1进行WCF Web服务调用

时间:2013-05-06 16:02:49

标签: vb.net wcf web-services

我正在尝试从VB .NET 3.5 Win Forms应用程序调用Web服务。我已经能够创建服务引用,但是当我调用Web服务时,我收到了SOAP错误:

A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.

Web服务使用带有证书的用户名和密码身份验证。我还需要根据环境(开发或生产)连接到不同的URL。出于这些原因,我试图使用在代码中创建的WSHttpBinding。但是,似乎绑定类型假定SOAP 1.2。 Web服务的作者告诉我,他们无法支持SOAP 1.2。

是否有一种方法,使用WSHttpBinding或代码中的CustomBinding,使用WCF服务引用来使用仅支持SOAP 1.1的Web服务?

Dim binding As New System.ServiceModel.WSHttpBinding

binding.Security.Mode = ServiceModel.SecurityMode.Transport
binding.Security.Transport.ClientCredentialType = ServiceModel.HttpClientCredentialType.Basic

Dim service As New ServiceReference.ServiceClient(binding, New System.ServiceModel.EndpointAddress(baseUrl))

service.ClientCredentials.UserName.UserName = serviceUsername
service.ClientCredentials.UserName.Password = servicePassword

感谢任何帮助!

0 个答案:

没有答案