Skip to main content
Home Forums Silverlight Programming Accessing Web Services with Silverlight Adding SOAP headers to ASMX web service message
6 replies. Latest Post by jacanon7 on August 26, 2009.
(0)
kobruleht
Member
141 points
525 Posts
01-02-2009 5:48 PM |
How to add User Name and password to SOAP ASMX webservice call message header ?
I tried MSDN sample from
http://msdn.microsoft.com/en-us/library/8728chd5(VS.80).aspx
{
}
but got error since SoapHeader class is not defined.
How to fix ? Can we use WCF OperationContext with ASMX web services or any other idea ?
Andrus.
davidezo...
Contributor
5614 points
863 Posts
01-02-2009 7:26 PM |
Hi Andrus,
you have to use HttpContext, the following example permits to retrieve the header "Username":
[WebMethod]
HttpStream.Position = 0;
dom.Load(HttpStream);
Username =
01-03-2009 9:48 AM |
Davide,
Thank you.
You showed a way to retrieve message headers.
I asked for a way to add username/password to message from SL client application.
Btw. HttpContex class is not available in sl runtime.
01-03-2009 12:10 PM |
for the client just use the code available here (solution SilverlightHeaders):
http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&DownloadId=3473
modify the SilverlightIpAddressMessageInspector class adding your personalized Headers:
Now insert a new asmx service in your web project to retrieve the Headers using the code I've posted in the previous post (here you have to use HttpContext).
Please let me know if the code works, otherwise I can send you a complete VS solution.
01-03-2009 12:56 PM |
I've posted a working solution here: http://www.davidezordan.net/blog/?p=658
Hope this helps.
integragreg
16 points
3 Posts
08-04-2009 3:00 PM |
David, your solution works very well except for one thing: what if the asmx web service is deployed on a production machine and you are not able to upgrade the server code to retrieve the headers from the httpcontext?
jacanon7
2 points
1 Posts
08-26-2009 1:28 PM |
This is the answer to all my question.
Mr. I have found this for year, please help me can you pass your code to VB? My boss is going to kill me...
Thanks a lot and God bless you.
Jorge andrés Cañón