【发布时间】:2016-08-24 21:01:14
【问题描述】:
我正在尝试连接到 SOAP Web 服务并收到此错误:
令牌提供者无法获取目标“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 而不是 HTTPS。这意味着安全模式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>
我不知道为什么会收到令牌错误。有人可以帮忙吗?
谢谢!
【问题讨论】:
标签: vb.net soap app-config