jefersonsv
asked on
How to add SOAP HEADER SECURITY in C# WCF 3.5 (http)
I need add <soapenv:Header> with my credential (simple text over http)
Below is a example of my SOAP correctly
<soapenv:Envelope xmlns:ser="http://servicos.meucliente.com.br/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-19" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>wsuser</wss e:Username >
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">wspass</wsse:Passw ord>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">LLxargkOak cn/LYvaUwA mw==</wsse :Nonce>
<wsu:Created>2010-07-26T18 :08:34.276 Z</wsu:Cre ated>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:solTarefas/>
</soapenv:Body>
</soapenv:Envelope>
The URI of EndPoint is: HTTP not HTTPS.
All the tests I did, basically resulted in two errors. The first is reporting that the the tag <wsse:security> not been informed and the second is the transport chosen requires a HTTPS endpoint.
I need a code in C#
I try this code:
myClient.ClientCredentials .UserName. UserName = "wsuser";
myClient.ClientCredentials .UserName. Password = "wspass";
myClient.solTarefas();
but i throw Expcetion ...
My config its:
<basicHttpBinding>
<binding name="MyClientServiceSoapB inding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="St rongWildca rd"
maxBufferPoolSize="524288" maxReceivedMessageSize="65 536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="81 92" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="163 84" />
<security mode="TransportCredentialO nly">
<transport clientCredentialType="Basi c" />
</security>
</binding>
</basicHttpBinding>
<endpoint address="http://200.211......./"
binding="basicHttpBinding" bindingConfiguration="MyCl ientServic eSoapBindi ng"
contract="WebService.Homol ogacao.MyC lientHom" name="MyClientImplPort">
<headers>
<Username>wsuser</Username >
<Password>wspass</Password >
</headers>
</endpoint>
I try acces the WS with app. soapUI and this its fine!!!
Below is a example of my SOAP correctly
<soapenv:Envelope xmlns:ser="http://servicos.meucliente.com.br/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
<wsse:UsernameToken wsu:Id="UsernameToken-19" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>wsuser</wss
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">wspass</wsse:Passw
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">LLxargkOak
<wsu:Created>2010-07-26T18
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:solTarefas/>
</soapenv:Body>
</soapenv:Envelope>
The URI of EndPoint is: HTTP not HTTPS.
All the tests I did, basically resulted in two errors. The first is reporting that the the tag <wsse:security> not been informed and the second is the transport chosen requires a HTTPS endpoint.
I need a code in C#
I try this code:
myClient.ClientCredentials
myClient.ClientCredentials
myClient.solTarefas();
but i throw Expcetion ...
My config its:
<basicHttpBinding>
<binding name="MyClientServiceSoapB
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
maxBufferPoolSize="524288"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="81
maxBytesPerRead="4096" maxNameTableCharCount="163
<security mode="TransportCredentialO
<transport clientCredentialType="Basi
</security>
</binding>
</basicHttpBinding>
<endpoint address="http://200.211......./"
binding="basicHttpBinding"
contract="WebService.Homol
<headers>
<Username>wsuser</Username
<Password>wspass</Password
</headers>
</endpoint>
I try acces the WS with app. soapUI and this its fine!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn.microsoft.com/en-us/library/aa529264.aspx