I used wsdl.exe to generate a class in C# to call a web service. This works fine as long as this web service does not require a header. Now I need to add a header like this:
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>myUsername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
Therefore I added a class Security with the class UsernameToken inside, which carries Username and Password and added it to the calling class. The problem to capture the whole SOAP message, which is sent out could be solved with a SOAP extension. I could achieve:
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>username</Username>
<Password>verysecret</Password>
</UsernameToken>
</Security>
So now I am missing this wsse
part and the "Type" attribute in the password tag?
How can this be done? Should I be using a [MessageContract]
instead?
Or can I just "hard code" the string and put it in the header?