Web Services 服务引用问题

zphenhs4  于 2022-11-24  发布在  其他
关注(0)|答案(2)|浏览(208)

我创建了控制台应用程序以使用Web服务。调用该Web服务时出现以下异常
传入消息的信封版本(Soap11(http://schemas.xmlsoap.org/soap/envelope/))与编码器的信封版本(Soap12(http://www.w3.org/2003/05/soap-envelope))不匹配。请确保使用与预期消息相同的版本配置绑定。
这是我的配置。你能帮我解决这个问题吗?

<wsHttpBinding>   
   <binding name="SecurityDemo">    
      <security mode="Transport">
         <transport clientCredentialType="Certificate" />
      </security>
   </binding>
</wsHttpBinding>
<endpoint name="endpointname" 
    address="URL"
    binding="wsHttpBinding" bindingConfiguration="SecurityDemo"
    contract="contractname" />
q43xntqr

q43xntqr1#

通过采用wsHttpBinding,您基本上是在强迫客户端使用Soap12。将其更改为BasicHttpBinding,看看是否会得到不同的结果,如果不需要Soap12特性,则保留它。更多详细信息可以在here中找到

vs3odd8k

vs3odd8k2#

在.NET 6中,我可以做到这一点:

// In Program.cs ...
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// ...
app.UseSoapEndpoint<IMyServiceContract>("/MyService.asmx", new SoapEncoderOptions()
{
    // Use SOAP version 1.2 (aka Soap12)
    MessageVersion = MessageVersion.Soap12WSAddressingAugust2004
}, caseInsensitivePath: true);

相关问题