PedroAlves-5166 avatar image
0 Votes"
PedroAlves-5166 asked PedroAlves-5166 published

C# - When consuming a web service using SOAP protocol how to set the WS-A address header before calling the service method (Async)?

I'm consuming a web service that uses SOAP protocol, I created a new .net framework console app and added the service, all good.
Now I need to use WS-Adressing for making asynchronous calls.

How to correctly setup my project (app.config, references?) so that it uses wsHttpBinding?

When instantiating the client and before calling the wanted method, how can I set the header with the following info: MessageID and ReplyTo ?

Thanks in advance.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you show some existing code?
Let us build on your work and continue to move forward instead of starting from scratch.

0 Votes 0 ·

Hi, not much code only added the service reference and instantiated the proxy class.
I used SoapUI to test the endpoint and all works, I'm also using Fiddler to catch all the messages.
In SoapUI I can enable WS-A Addressing and fill the envelope header, but I don't know how to accomplish that in C#.
In Web.config I changed the Binding to wsHttpBinding, also without results
Here's part of my code:

 public bool SendData()
         BASEWS2018Client client = new BASEWS2018Client();
         create payload = new create();
         payload.apikey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
         // Message Body definitions//
         return true;
     catch (Exception ex)
         Console.WriteLine("Error: " + ex.Message);
         Console.WriteLine("StackTrace: " + ex.StackTrace);
     return false;

0 Votes 0 ·

For WCF, maybe you can refer to the solution in this link:
How do I use WS-Addressing in WCF and set the wsa:replyto header?
What type of project are you using?

0 Votes 0 ·
Show more comments

0 Answers