question

cK-2289 avatar image
0 Votes"
cK-2289 asked Bruce-SqlWork answered

How to add http header to webservice soap request C#

I need to add http header to webservice soap request using C#. Already I created webservice proxy using wsdl.exe. But I searched the code in stackoverflow, MSDN forum and found it is available for soapclient, and HttpWebRequest webRequest . Can I know how to add http header to web service request ? (but the existing project has webservice proxy- the service proxy created using wsdl.exe)

dotnet-aspnet-general
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.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

its pretty simple:

1) create a class that inherits from the generated proxy class
2) override the method GetWebRequest
3) in the override method, add code like above to set set the header

use this new class instead of the original.

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.

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @cK-2289,
You could try these codes:

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create( Your URL );
 request.Headers.Add( "SOAPAction", YOUR SOAP ACTION );

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

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.