Reputation: 82291
I need to add a soap header to my web service. I plan to use this to validate my clients (Windows Mobile Devices).
I found this link: http://www.c-sharpcorner.com/UploadFile/rog_21/soapheaders05172007120046PM/soapheaders.aspx
Which is exactly what I want to do. But it is not written for WCF.
I have done some research and I seem to be paralyzed by the number of options.
I basically want to add a simple header to my soap object that will be a user name and password. The client does not use WCF, so the soap header needs to just be a normal soap header.
Any Sample code or shoves in the right direction would be appreciated.
Upvotes: 2
Views: 3725
Reputation: 1892
You can also use UsernameToken in SOAP header if you have to pass only username paaword and use custom UserNamePasswordValidator as a pluggable service behaviour. http://msdn.microsoft.com/en-us/library/aa702565.aspx
Upvotes: 0
Reputation: 53699
Rather than define a DataContract, use MessageContract
[MessageContract]
public class YourMessageType
{
// This is in the SOAP Header
[MessageHeader] public string UserName {get;set;}
[MessageHeader] public string Password {get;set;}
// This is in the SOAP body
[MessageBodyMember] public string OtherData {get;set;}
...
}
Upvotes: 3