2017-03-22 12 views
0

私はjavaから書かれたwcfサービスに.netから接続しています。 サービスメソッドを呼び出すと成功しますが、戻り値は不正です(空ではありませんが、空です)。 SoapUIを使用してリクエストをテストしました - 正しく動作する=>問題はサービス側ではありません。 私はクライアント側で何が問題なのか、それをどう修正するのか分かりません。奇妙なwcf .netクライアントの動作

SOAPUI要求を発生:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="SOME LINK"> 
      <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> 
             <wsse:Username>USERNAME</wsse:Username>        
             <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password> 
           </wsse:UsernameToken> 
         </wsse:Security> 
      <soapenv:Header> 
      <soapenv:Body> 
       <web:GetObjects> 
       <!--Optional:--> 
       <ObjectTypeCode>01</ObjectTypeCode> 
       <!--Optional:--> 
       <OkrugCode>1</OkrugCode> 
       <!--Optional:--> 
       <ObjectLink>true</ObjectLink> 
       <Offset>0</Offset> 
       <Limit>5</Limit> 
       </web:GetObjects> 
      </soapenv:Body> 
     </soapenv:Envelope> 

C#の-clientはApp.configファイル

<bindings> 
     <customBinding> 
      <binding name="SomeConfig"> 
       <security 
        authenticationMode="UserNameOverTransport" 
        enableUnsecuredResponse="true" 
        includeTimestamp="false" 
        defaultAlgorithmSuite="Basic256" 
        requireDerivedKeys="True" 
        messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"/> 
       <textMessageEncoding messageVersion="Soap11" /> 
       <httpsTransport maxReceivedMessageSize="2147483647"/> 
      </binding> 
     </customBinding> 
    </bindings> 


    <client> 
     <endpoint address="Some Link" 
      binding="customBinding" 
      bindingConfiguration="SomeConfig" 
      contract="SomeContact" 
      name="SomeName" > 
     </endpoint> 
    </client> 

С#コード

の要求(IClientMessageInspectorから入手)

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
      <s:Header> 
      <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" /> 
      <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">SMTH</VsDebuggerCausalityData> 
      </s:Header> 
      <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
      <GetObjects xmlns="Some Link"> 
       <ObjectTypeCode xmlns="">01</ObjectTypeCode> 
       <ObjectId xmlns="">0</ObjectId> 
       <ObjectLink xmlns="">true</ObjectLink> 
       <Offset xmlns="">0</Offset> 
       <Limit xmlns="">5</Limit> 
      </GetObjects> 
      </s:Body> 
     </s:Envelope> 

パートを生成しました

var someClient = new SomeServiceClient(); 
someClient.ClientCredentials.UserName.UserName = username; 
someClient.ClientCredentials.UserName.Password = password; 

someClient.Open(); 

var channel = someClient.ChannelFactory.CreateChannel(remoteAddress); 
var objectsResponse = someClient.GetObjects(getObjectsRequest); 
+0

SOAPUIメッセージにWS-Securityヘッダーが含まれているようで、C#メッセージには表示されない。おそらくあなたのカスタムバインディングは、それがあなたが思っていることをしていないでしょう。 – Joe

答えて

0

解決策は、セキュリティクライアントを.netクライアントに追加することでした。