我正在尝试从 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
任何帮助表示赞赏!