のためのトークンを取得することはできませんし、私はこのエラーを取得:サービスを作っ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>
は、私はトークンエラーを取得していますなぜ私が把握することはできません。誰も助けることができますか?
ありがとうございます!