2016-04-29 17 views
0
私は、SOAP Webサービスに接続しようとしている

のためのトークンを取得することはできませんし、私はこのエラーを取得:サービスを作っWebサービスへの接続 - トークンプロバイダが対象

The token provider cannot get tokens for target ' http://realurl.com/myservice.svc '

会社が私にこのapp.configを送りましたサンプルコード:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
     <!-- Specify UserName and Password of context user --> 
     <add key="UserName" value="xxxxxx" /> 
     <add key="Password" value="xxx" /> 
    </appSettings> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="ValuationServiceEndpoint" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
        allowCookies="false" > 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
        <security mode="TransportWithMessageCredential" > 
         <message clientCredentialType="UserName" establishSecurityContext="false"/> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="https://sampleurl.com/service.svc" 
       binding="wsHttpBinding" bindingConfiguration="ValuationServiceEndpoint" 
       contract="Provider.ValuationService.ValuationService" name="ValuationServiceEndpoint" > 
      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

私が与えたエンドポイントアドレスがHTTPではないため、このコードに問題があります。つまり、セキュリティモードTransportWithMessageCredentialはここでは機能しませんので、代わりにMessageに変更しました。

ここに私の現在のコードです:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
    </configSections> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
    <appSettings> 
     <add key="Username" value="myuser" /> 
     <add key="Password" value="mypass" /> 
    </appSettings> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="ValuationServiceEndpoint"> 
        <security mode="Message"> 
         <message clientCredentialType="UserName" establishSecurityContext="false" /> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://realurl.com/service.svc" 
       binding="wsHttpBinding" bindingConfiguration="ValuationServiceEndpoint" 
       contract="Provider.ValuationService.ValuationService" name="ValuationServiceEndpoint" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

は、私はトークンエラーを取得していますなぜ私が把握することはできません。誰も助けることができますか?

ありがとうございます!

答えて

1

2か月後に投稿に返信して申し訳ありませんが、少なくともそれが機能しなかった理由は分かっています。

問題は実際には簡単でした。セキュリティモードがサーバーとクライアントの間で不一致でした。サーバーはTransportWithMessageCredentialを予期していて、クライアントはMessageを提供していました。

パスワードセキュリティを使用する場合は、両側にメッセージを使用します。 httpsを使用する場合は、両側にTransportWithMessageCredentialを指定する必要があります。

関連する問題