2012-04-13 7 views
1

現在、hmrcのapiに接続しようとしています。私のプロジェクトでサービスを設定しています。送信するメッセージを作成中です。SOAPヘッダにwsse:security要素を追加する

メッセージのボディセクションを作成できましたが、ヘッダーを正しく取得できませんでした。メッセージがどのように表示されるかの例を次に示します。

<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/"> 
<soap:Header>  
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/04/security/trust/RST/Issue</wsa:Action> 
<wsa:MessageID>uuid:39610e5b-162b-4491-9301-85578046a583</wsa:MessageID> 
<wsa:ReplyTo> 
    <wsa:Address> 
     http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous 
    </wsa:Address> 
</wsa:ReplyTo> 
<wsa:To> 
    http://www.gateway.gov.uk/soap/2007/02/sts 
</wsa:To> 
<wsse:Security> 
    <wsu:Timestamp wsu:Id="Timestamp-201ebb7a-d2f4-44d5-85e4-b8bb4c71ed54"> 
    <wsu:Created>2012-04-13T16:18:11Z</wsu:Created> 
    <wsu:Expires>2012-04-13T16:23:11Z</wsu:Expires> 
    </wsu:Timestamp> 
</wsse:Security> 
</soap:Header> 
<soap:Body> 
<wst:RequestSecurityToken xmlns:wst="http://schemas.xmlsoap.org/ws/2004/04/trust"> 
<wst:TokenType>urn:GSO-SystemServices:external:1.65:gatewaytoken#GatewayToken</wst:TokenType>  
<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType> 
    <wst:Base> 
    <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"> 
     <wsse:Username>513FDQ37JILL</wsse:Username> 
     <wsse:Password Type="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"> 
     NXJ3ynAa8Sy136aifThXJl8vLoE= 
     </wsse:Password> 
     <wsse:Nonce>4nJy2oD6xC79zatTHvuywg==</wsse:Nonce> 
     <wsu:Created>2007-02-01T11:03:10Z</wsu:Created> 
    </wsse:UsernameToken> 
    </wst:Base> 
    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"> 
    <wsa:EndpointReference> 
     <wsa:Address>urn:GSO-SystemServices:external:1.65:GatewayWebServices</wsa:Address> 
    </wsa:EndpointReference> 
    </wsp:AppliesTo> Version 1.0 32 9 June 2008 
    <wst:Lifetime> 
    <wsu:Expires>2012-04-13T20:23:11Z</wsu:Expires> 
    </wst:Lifetime> 
</wst:RequestSecurityToken> 
</soap:Body> 
</soap:Envelope> 

主な問題は、表示するセキュリティエレメントを取得できないことです。私は現在、さまざまな種類のバインディングを試してapp.configファイルを試していますが、私は本当にサービスを使用することに新しいし、完全に立ち往生しています。ここに私の現在のapp.configです:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
    </configSections> 
    <system.serviceModel> 
    <bindings> 
     <customBinding> 
      <binding name="XmlTokenServiceBinding" > 
       <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" 
        messageVersion="Soap11WSAddressing10" writeEncoding="utf-8"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       </textMessageEncoding> 
       <security authenticationMode="SecureConversation" includeTimestamp="True" requireSecurityContextCancellation="false" 
         messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"> 
       </security>     
       <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" /> 
      </binding> 
     </customBinding> 
    </bindings> 
    <behaviors> 
    <endpointBehaviors> 
     <behavior> 
     <clientVia viaUri="https://secure.gateway.gov.uk/soap/2007/02/sts/GatewayTokenService.ashx"/> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 
    <client> 
     <endpoint address="https://secure.gateway.gov.uk/soap/2007/02/sts/GatewayTokenService.ashx" 
      binding="customBinding" bindingConfiguration="XmlTokenServiceBinding" 
      contract="ServiceReference1.XmlTokenServicePortType" name="XmlTokenServicePort" /> 
    </client> 
</system.serviceModel> 

編集:コードサービスを呼び出すためのコメントで要求されるように:ここにも

TokenService.RequestSecurityToken request = CreateTokenRequest(); 
    TokenService.XmlTokenServicePortTypeClient client = new TokenService.XmlTokenServicePortTypeClient(); 
    TokenService.RequestSecurityTokenResponseType response = client.RequestSecurityTokenRequest(request); 

はシオマネキを通じて要求メッセージである:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"> 
<s:Header> 
    <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action> 
    <a:MessageID>urn:uuid:0f43afa7-c22c-400b-87b2-c9b76bd0abdd</a:MessageID> 
    <a:ReplyTo> 
     <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> 
    </a:ReplyTo> 
     <a:To s:mustUnderstand="1">https://secure.gateway.gov.uk/soap/2007/02/sts/GatewayTokenService.ashx</a:To> 
</s:Header> 
<s:Body> 
    <t:RequestSecurityToken Context="uuid-829d42ad-a560-44aa-9be8-95c212d82762-1" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> 
     <t:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</t:TokenType> 
     <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> 
     <t:KeySize>256</t:KeySize> 
     <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">YIGeBgYrBgEFBQKggZMwgZCgGjAYBgorBgEEAYI3AgIeBgorBgEEAYI3AgIKonIEcE5FR09FWFRTAAAAAAAAAABgAAAAcAAAABOP7thI+QdbUguCiBDWyeqYiLGof7AdxPVl4cuUPGbTiMyHDzMox/EGGxas/mzB/AAAAAAAAAAAYAAAAAEAAAAAAAAAAAAAAEVyfDIyRYtIv9kqa6BepAo=</t:BinaryExchange> 
    </t:RequestSecurityToken> 
</s:Body> 
</s:Envelope> 
+0

サービスを呼び出す際に使用しているコードを表示してください。 「本文セクションを作成する」または「ヘッダーを正しく取得する」必要はありません。 WCFはあなたにそれをしているはずです。 –

+0

あなたの質問は、手作業でXMLを構築しようとしていると信じてくれました。あなたはXMLを操作しているかどうか? –

+0

bodyセクションでは、bodyセクションに作成して入れなければならないuserTokenが必要です。ヘッダーに関しては、それの残りは私のために作成されています、ちょうどこの1つのセクションは作成されていません。 – emybob

答えて

0

サービスセキュリティ設定の追加仕様はありますか? 1つのメッセージだけでなく、複数のメッセージ交換(ws-trust)を必要とするようです。また、サンプル・メッセージは、wcfによって直接サポートされていないws-addressingバージョン2004/03を使用します。これらのすべてがあなたのケースで問題になるかもしれません(おそらくSTSと直接仕事をしているだけかもしれません)

あなたの設定はセキュリティヘッダーのいくつかのkineを出すべきです。なぜそれはないと思いますか? WCFログはセキュリティを表示します(トランスポートレベルでログに記録するように設定されていない場合)。ワイヤで実際に何が起こっているかを見るには、フィドラーを使用します。

+0

私はすでに要求と応答を見るためにfiddlerを使用しています。これは現在、作成されているセキュリティヘッダーがないことを知っています。 – emybob

+0

完全な作業用石鹸サンプル(セキュリティ部分のみではありません)とあなたが送信している完全な石鹸メッセージ(Fiddler経由で)を公開してください。 –

+0

私は元の投稿に完全なサンプルとメッセージを追加しました – emybob

関連する問題