Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding wsse:security element to soap header
    primarykey
    data
    text
    <p>I'm currently trying to connect to the hmrc's api and have set up a service in my project and am now in the process of creating the message to send.</p> <p>I've been able to create the body section of the message fine, but am having trouble getting the header right. here's an example of what the message should look like:</p> <pre><code>&lt;soap:Envelope xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap:Header&gt; &lt;wsa:Action&gt;http://schemas.xmlsoap.org/ws/2004/04/security/trust/RST/Issue&lt;/wsa:Action&gt; &lt;wsa:MessageID&gt;uuid:39610e5b-162b-4491-9301-85578046a583&lt;/wsa:MessageID&gt; &lt;wsa:ReplyTo&gt; &lt;wsa:Address&gt; http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous &lt;/wsa:Address&gt; &lt;/wsa:ReplyTo&gt; &lt;wsa:To&gt; http://www.gateway.gov.uk/soap/2007/02/sts &lt;/wsa:To&gt; &lt;wsse:Security&gt; &lt;wsu:Timestamp wsu:Id="Timestamp-201ebb7a-d2f4-44d5-85e4-b8bb4c71ed54"&gt; &lt;wsu:Created&gt;2012-04-13T16:18:11Z&lt;/wsu:Created&gt; &lt;wsu:Expires&gt;2012-04-13T16:23:11Z&lt;/wsu:Expires&gt; &lt;/wsu:Timestamp&gt; &lt;/wsse:Security&gt; &lt;/soap:Header&gt; &lt;soap:Body&gt; &lt;wst:RequestSecurityToken xmlns:wst="http://schemas.xmlsoap.org/ws/2004/04/trust"&gt; &lt;wst:TokenType&gt;urn:GSO-SystemServices:external:1.65:gatewaytoken#GatewayToken&lt;/wst:TokenType&gt; &lt;wst:RequestType&gt;http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue&lt;/wst:RequestType&gt; &lt;wst:Base&gt; &lt;wsse:UsernameToken xmlns:wsu="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-94d12e0f-400b-4412-bde8-e03357eb0692"&gt; &lt;wsse:Username&gt;513FDQ37JILL&lt;/wsse:Username&gt; &lt;wsse:Password Type="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"&gt; NXJ3ynAa8Sy136aifThXJl8vLoE= &lt;/wsse:Password&gt; &lt;wsse:Nonce&gt;4nJy2oD6xC79zatTHvuywg==&lt;/wsse:Nonce&gt; &lt;wsu:Created&gt;2007-02-01T11:03:10Z&lt;/wsu:Created&gt; &lt;/wsse:UsernameToken&gt; &lt;/wst:Base&gt; &lt;wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"&gt; &lt;wsa:EndpointReference&gt; &lt;wsa:Address&gt;urn:GSO-SystemServices:external:1.65:GatewayWebServices&lt;/wsa:Address&gt; &lt;/wsa:EndpointReference&gt; &lt;/wsp:AppliesTo&gt; Version 1.0 32 9 June 2008 &lt;wst:Lifetime&gt; &lt;wsu:Expires&gt;2012-04-13T20:23:11Z&lt;/wsu:Expires&gt; &lt;/wst:Lifetime&gt; &lt;/wst:RequestSecurityToken&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>The main issue is i can't get the Security element to show. I've currently been playing around in the app.config file trying out various types of binding, but i'm really new to using services and am getting completely stuck. Here's my current app.config:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;/configSections&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;customBinding&gt; &lt;binding name="XmlTokenServiceBinding" &gt; &lt;textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11WSAddressing10" writeEncoding="utf-8"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;/textMessageEncoding&gt; &lt;security authenticationMode="SecureConversation" includeTimestamp="True" requireSecurityContextCancellation="false" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"&gt; &lt;/security&gt; &lt;httpsTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" requireClientCertificate="false" /&gt; &lt;/binding&gt; &lt;/customBinding&gt; &lt;/bindings&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior&gt; &lt;clientVia viaUri="https://secure.gateway.gov.uk/soap/2007/02/sts/GatewayTokenService.ashx"/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;client&gt; &lt;endpoint address="https://secure.gateway.gov.uk/soap/2007/02/sts/GatewayTokenService.ashx" binding="customBinding" bindingConfiguration="XmlTokenServiceBinding" contract="ServiceReference1.XmlTokenServicePortType" name="XmlTokenServicePort" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p></p> <p>edit: Code as requested in comments for calling service:</p> <pre><code> TokenService.RequestSecurityToken request = CreateTokenRequest(); TokenService.XmlTokenServicePortTypeClient client = new TokenService.XmlTokenServicePortTypeClient(); TokenService.RequestSecurityTokenResponseType response = client.RequestSecurityTokenRequest(request); </code></pre> <p>Also here is the request message through fiddler:</p> <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"&gt; &lt;s:Header&gt; &lt;a:Action s:mustUnderstand="1"&gt;http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue&lt;/a:Action&gt; &lt;a:MessageID&gt;urn:uuid:0f43afa7-c22c-400b-87b2-c9b76bd0abdd&lt;/a:MessageID&gt; &lt;a:ReplyTo&gt; &lt;a:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/a:Address&gt; &lt;/a:ReplyTo&gt; &lt;a:To s:mustUnderstand="1"&gt;https://secure.gateway.gov.uk/soap/2007/02/sts/GatewayTokenService.ashx&lt;/a:To&gt; &lt;/s:Header&gt; &lt;s:Body&gt; &lt;t:RequestSecurityToken Context="uuid-829d42ad-a560-44aa-9be8-95c212d82762-1" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"&gt; &lt;t:TokenType&gt;http://schemas.xmlsoap.org/ws/2005/02/sc/sct&lt;/t:TokenType&gt; &lt;t:RequestType&gt;http://schemas.xmlsoap.org/ws/2005/02/trust/Issue&lt;/t:RequestType&gt; &lt;t:KeySize&gt;256&lt;/t:KeySize&gt; &lt;t:BinaryExchange ValueType="http://schemas.xmlsoap.org/ws/2005/02/trust/spnego" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"&gt;YIGeBgYrBgEFBQKggZMwgZCgGjAYBgorBgEEAYI3AgIeBgorBgEEAYI3AgIKonIEcE5FR09FWFRTAAAAAAAAAABgAAAAcAAAABOP7thI+QdbUguCiBDWyeqYiLGof7AdxPVl4cuUPGbTiMyHDzMox/EGGxas/mzB/AAAAAAAAAAAYAAAAAEAAAAAAAAAAAAAAEVyfDIyRYtIv9kqa6BepAo=&lt;/t:BinaryExchange&gt; &lt;/t:RequestSecurityToken&gt; &lt;/s:Body&gt; &lt;/s:Envelope&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload