Skip to main content
Home Forums Silverlight Programming Accessing Web Services with Silverlight Adding user name and password to SOAP message header
9 replies. Latest Post by kobruleht on January 5, 2009.
(0)
kobruleht
Member
159 points
572 Posts
01-01-2009 3:56 PM |
SL appl asks for user name and password. How to pass user name and password to SOAP WebService for custom validation?
I tried code below but got error on line
proxy.Headers.Add(header);
about missing
Andrus.
proxy.SaveAssetDocumentCompleted += proxy_AddOrderCompleted;
proxy.SaveAssetDocumentAsync();
class UserCredentials
{
}
UserName = userName;
Password = password;
davidezo...
Contributor
5682 points
871 Posts
01-01-2009 4:45 PM |
Hi,
check out this article:
http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-3.aspx
01-01-2009 5:57 PM |
Thank you. I tried this code with SOAP Web Service.
In service line
MessageHeaders messageHeaders = OperationContext.Current.IncomingMessageHeaders;
Causes NullReferenceException
Any idea how to make this code to work with SOAP web service ?
01-01-2009 7:04 PM |
The source code of the article works fine for me.
However you can find here a simpler example using custom SOAP headers:
http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&DownloadId=3473
01-02-2009 5:15 AM |
Thank you.
Have you tried with ASMX Web service?
I'm looking for a way to get message headers from ASMX web service, not from WCF web service.
Code sample you posted uses WCF web service.
01-02-2009 8:27 AM |
Hi Andrus,
I suggest you to use WCF services instead of "old" asmx, they are more scalable.
Once you have upgraded to WCF, use the last example I've posted, it works very well.
01-02-2009 1:53 PM |
I'm planning to host web service in MONO. I have'nt found a way to run .svc service from MONO so I'm forced to use asmx which works OK.
I found the following article about retrieving SOAP headers in ASMX web service
http://www.codeproject.com/KB/cpp/authforwebservices.aspx
Should I use this method ?
01-02-2009 7:28 PM |
Check out this thread:
http://silverlight.net/forums/p/62643/155224.aspx
ljun
2 points
6 Posts
01-05-2009 8:26 AM |
So it seems like the best way to deal with this is to have a centralized method for calling web services. Is that correct?
01-05-2009 9:52 AM |
My goal is to exchange the following info with ASMX service:
1. SQL Server login credentials (user name, password, database etc)
2. ValidationException and other exception message texts.
I think that best way is not use message headers at all.
So I created special type
class MessageHeader {
public string User, Class, ExceptionText;
...
and pass this as ref parameter to every web method call
List<Customer> GetCustomers( ref header, ... )
Ugly, but seems to be only solution.