2017-07-07 34 views
0

自分自身を保護するために、WS-Security(username + password)を使用するサービスに接続しようとしています。ColdFusion 2016(WS-Security実装)

<cfxml variable="securityHeaders"> 
    <wsse:Security soapenv:mustUnderstand="1" 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-wss-wssecurity-utility-1.0.xsd"> 
    <wsse:UsernameToken wsu:Id="UsernameToken-65" 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-wss-wssecurity-utility-1.0.xsd"> 
    <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:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">1vrSoBRiARpSIXvhXExgqg==</wsse:Nonce> 
    <wsu:Created>2017-07-07T20:07:22.041Z</wsu:Created> 
    </wsse:UsernameToken> 
    </wsse:Security> 
</cfxml> 

<cfscript> 
    ws = createObject("webservice", #wsurl#,{wsversion="2",refreshWSDL=true}); 
    WriteDump(#securityHeaders#); 
    AddSoapRequestHeader(ws, "","",#securityHeaders#,true); 

    version = ws.GetVersion(); 
</cfscript> 

しかし、ColdFusionが私のXMLについて何かを好きではないようです:私は私のコードは、現在このようになりますColdFusionの2016

から接続しています。私はsoapenvを削除した場合

An error occurred while Parsing an XML document. 
The prefix "soapenv" for attribute "soapenv:mustUnderstand" associated with an element type "wsse:Security" is not bound. 

The error occurred in C:/ColdFusion2016/cfusion/wwwroot/test/getVersion.cfm: line 12 

10 : </cfif> 
11 : 
12 : <cfxml variable="securityHeaders"> 
13 :  <wsse:Security soapenv:mustUnderstand="1" 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-wss-wssecurity-utility-1.0.xsd"> 
14 : <wsse:UsernameToken wsu:Id="UsernameToken-65" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 

:私はこのエラーが発生しますのmustUnderstand =「1」は、私は別のエラーが表示されるが、私の理解では、それはそこにする必要があるということです。このXMLで私が間違っていることはありますか? soapenvについて知らない理由はありますか?mustUnderstand?

洞察力があれば幸いです。ありがとうございます。

EDIT 1 は、この変更は、問題を修正しました:

<wsse:Security soapenv:mustUnderstand="1" 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-wss-wssecurity-utility-1.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 

しかし、今、私は次のことを受け付けております:

Cannot perform web service invocation GetVersion. 
The fault returned when invoking the web service operation is: 

AxisFault 

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}MustUnderstand 

faultSubcode: 

faultString: Did not understand &quot;MustUnderstand&quot; header(s): 

faultActor: 

faultNode: 

faultDetail: 

    {http://xml.apache.org/axis/}stackTrace: 

    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96) 

    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) 

    at org.apache.axis.client.Call.invokeEngine(Call.java:2765) 

    at org.apache.axis.client.Call.invoke(Call.java:2748) 

    at org.apache.axis.client.Call.invoke(Call.java:2424) 

    at org.apache.axis.client.Call.invoke(Call.java:2347) 

    at org.apache.axis.client.Call.invoke(Call.java:1804) 

これはワーキングエンベロープです:

<soapenv:Envelope xmlns:abc="ABCService" 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" 
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <wsse:UsernameToken wsu:Id="UsernameToken-41D8D78B82FF48D24D149946784898124"> 
    <wsse:Username>usernamegoeshere</wsse:Username> 
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">passgoeshere</wsse:Password> 
    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">noncehere</wsse:Nonce> 
    <wsu:Created>2017-07-07T22:50:48.980Z</wsu:Created> 
    </wsse:UsernameToken> 
    </wsse:Security></soapenv:Header> 
    <soapenv:Body> 
     <abc:GetVersion/> 
    </soapenv:Body> 
</soapenv:Envelope> 

これは私が見ることができる失敗している封筒です私の痕跡で

<MessageHeaders> 
<wsse:Security soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 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-wss-wssecurity-utility-1.0.xsd" soapenv:actor=""> 
<wsse:UsernameToken wsu:Id="UsernameToken-65" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
<wsse:Username> 
<!-- Removed--> 
</wsse:Username> 
<wsse:Password> 
<!-- Removed--> 
</wsse:Password> 
<wsse:Nonce> 
<!-- Removed--> 
</wsse:Nonce> 
<wsu:Created>2017-07-07T20:35:22.041Z</wsu:Created> 
</wsse:UsernameToken> 
</wsse:Security> 
<To d4p1:mustUnderstand="1" xmlns:d4p1="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">https://pc/Service/Service.svc</To> 
<Action d4p1:mustUnderstand="1" xmlns:d4p1="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">Service/Service/GetVersion</Action> 
</MessageHeaders> 

トレース(CF2016/Axisはリクエストや結果に窒息されている場合イムわからない) - 私はそれが「チャネルを介してメッセージを受信したことを確認することができ、セキュリティプロトコルがメッセージを確認し、メッセージが読まれます私はGetVersionの実行をTo/fromにしてから、送信メッセージが表示されます。メッセージの受信時に軸が失敗する可能性はありますか?

+0

テストエンドポイント#wsurl#はテストできますか? – ah7866

+0

残念ながら、すべてがローカルにホストされていません。 @ ah7866 –

答えて

0

だから、WCFとColdfusionがやりとりするようになった。この場合、要求はサーバーに当たっており、Axisは応答を理解できませんでした。

SOAPUIでは、レスポンスにタイムスタンプヘッダー/タグが必要です。このヘッダーは、basichttpbindingを使用するときにWCFで追加されます。クライアントはこのヘッダを理解することができず、そのためチョークします。

解決策は、セキュリティノードでincludeTimestampをfalseに設定するためにcustomBindingに移動することでした。

はコンフィグ

<bindings> 
     <customBinding> 
     <binding name="myCustomBinding"> 
      <security authenticationMode="UserNameOverTransport" includeTimestamp="false"> 
      <secureConversationBootstrap/> 
      </security> 
      <textMessageEncoding messageVersion="Soap12"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      </textMessageEncoding> 
      <httpsTransport></httpsTransport> 
     </binding> 
     </customBinding> 

サービスコンフィグバインディング:

<services> 
     <service behaviorConfiguration="MyBehavior" name="MyNamespace.MyService"> 
     <endpoint address="" binding="customBinding" bindingConfiguration="myCustomBinding" 
      bindingNamespace="MyNamespace" contract="MyNameSpace.IMyService" /> 

応答は、この(ないタイムスタンプタグに気づかない)のようになります。

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> 
    <s:Body> 
     <GetVersionResponse xmlns="MyNamespace"> 
     <GetVersionResult>1.0</GetVersionResult> 
     </GetVersionResponse> 
    </s:Body> 
</s:Envelope> 

そして、私のColdFusionコードは次のようになります。

<cfxml variable="securityHeaders" casesensitive="true"> 
    <wsse:Security soapenv:mustUnderstand="1" 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-wss-wssecurity-utility-1.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <wsse:UsernameToken wsu:Id="UsernameToken-65" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <wsse:Username>usernamegoeshere</wsse:Username> 
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">passgoeshere</wsse:Password> 
    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">1vrSoBRiARpSIXvhXExgqg==</wsse:Nonce> 
    <wsu:Created>2017-07-07T20:35:22.041Z</wsu:Created> 
    </wsse:UsernameToken> 
    </wsse:Security> 
</cfxml> 

<cfscript> 
    ws = createObject("webservice", #wsurl#); 
    //WriteDump(#securityHeaders#); 
    AddSoapRequestHeader(ws, "dummy","dummy",#securityHeaders#,true); 
    version = ws.GetVersion(); 
    WriteOutput(version); 
</cfscript> 
関連する問題