RDeveloper
RDeveloper

Reputation: 143

Issue with service reference

I created console application to consume a web service. When I invoke that web service I am getting below exception

The envelope version of the incoming message (Soap11 (http://schemas.xmlsoap.org/soap/envelope/)) does not match that of the encoder (Soap12 (http://www.w3.org/2003/05/soap-envelope)). Make sure the binding is configured with the same version as the expected messages.

This is my configuration. Can you please help me to fix this?

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

Upvotes: 3

Views: 5369

Answers (2)

Cryptc
Cryptc

Reputation: 3595

In .NET 6, I was able to do this:

// 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);

Upvotes: 1

Ot&#225;vio D&#233;cio
Ot&#225;vio D&#233;cio

Reputation: 74250

By adopting wsHttpBinding you are basically forcing your clients to use Soap12. Change it to BasicHttpBinding and see if you get different results and keep it if you don't need the Soap12 features. Some more details can be found here

Upvotes: 3

Related Questions