WCF: Use Contract with Post to Make a Soap Header
I need to add a header for my web service. I am planning to use this to check my clients (Windows Mobile Devices).
I found this link: http://www.c-sharpcorner.com/UploadFile/rog_21/soapheaders05172007120046PM/soapheaders.aspx
This is exactly what I want to do. But it is not written for WCF.
I've done some research and I seem to be paralyzed by the number of options .
Basically I want to add a simple header to my soap object that will be the username and password. The client is not using WCF, so the soap header should just be a normal soap header.
Any code example or sounds in the right direction would be appreciated.
a source to share
Use MessageContract instead of defining DataContract
[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;}
...
}
a source to share
You can also use UsernameToken in the SOAP header if you only need to pass the paaword username and use a custom UserNamePasswordValidator as the behavior of the service being plugged in. http://msdn.microsoft.com/en-us/library/aa702565.aspx
a source to share