如何使用引导令牌正确连接到 WCF 服务
我找不到我做错了什么。
当我尝试调用服务操作时,出现错误:
通信对象 System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为它处于“故障”状态。
using (Ref.SService_V1_0Client client = new Ref.SService_V1_0Client("RWS"))
{
var request = new Ref.IVISRequestStructure();
request.Header = new Ref.RequestHeaderStructure();
client.ChannelFactory.Credentials.SupportInteractive = false;
ChannelFactoryOperations.ConfigureChannelFactory(client.ChannelFactory);
ChannelFactoryOperations.CreateChannelWithIssuedToken<Ref.ISService_V1_0>(client.ChannelFactory, ((Microsoft.IdentityModel.Claims.ClaimsIdentity)(Page.User.Identity)).BootstrapToken);
client.StartTransaction("string argument");
}
web.config 中的配置:
<system.serviceModel>
<bindings>
<ws2007FederationHttpBinding>
<binding name="ws2007FederationUserName" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" maxReceivedMessageSize="100000000">
<security mode="TransportWithMessageCredential">
<message issuedKeyType="SymmetricKey" negotiateServiceCredential="true">
<issuer address="adress/STS/Issue.svc/trust/13/issuedtokenmixedsymmetricbasic256" binding="customBinding" bindingConfiguration="issuedtokenmixedsymmetricbasic256"/>
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
</bindings>
<client>
<endpoint address="another_address/servicename.svc/ws2007Federation"
binding="ws2007FederationHttpBinding" bindingConfiguration="ws2007FederationUserName"
contract="Ref.ISService_V1_0" name="RWS" />
</client>
</system.serviceModel>
I cannot find what I`m doing wrong.
When I try to call service operation I get error:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
using (Ref.SService_V1_0Client client = new Ref.SService_V1_0Client("RWS"))
{
var request = new Ref.IVISRequestStructure();
request.Header = new Ref.RequestHeaderStructure();
client.ChannelFactory.Credentials.SupportInteractive = false;
ChannelFactoryOperations.ConfigureChannelFactory(client.ChannelFactory);
ChannelFactoryOperations.CreateChannelWithIssuedToken<Ref.ISService_V1_0>(client.ChannelFactory, ((Microsoft.IdentityModel.Claims.ClaimsIdentity)(Page.User.Identity)).BootstrapToken);
client.StartTransaction("string argument");
}
Configuration in web.config:
<system.serviceModel>
<bindings>
<ws2007FederationHttpBinding>
<binding name="ws2007FederationUserName" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" maxReceivedMessageSize="100000000">
<security mode="TransportWithMessageCredential">
<message issuedKeyType="SymmetricKey" negotiateServiceCredential="true">
<issuer address="adress/STS/Issue.svc/trust/13/issuedtokenmixedsymmetricbasic256" binding="customBinding" bindingConfiguration="issuedtokenmixedsymmetricbasic256"/>
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
</bindings>
<client>
<endpoint address="another_address/servicename.svc/ws2007Federation"
binding="ws2007FederationHttpBinding" bindingConfiguration="ws2007FederationUserName"
contract="Ref.ISService_V1_0" name="RWS" />
</client>
</system.serviceModel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 CreateChannelWithIssuedToken 调用的返回值来调用服务,而不是使用客户端变量。请参阅 本示例中的 CreateChannel 代码介绍了如何使用 CreateChannelWithIssuedToken。 代码如下所示:
Try using the return value of the CreateChannelWithIssuedToken call to invoke the service instead of using the client variable. See the CreateChannel code in this sample for how CreateChannelWithIssuedToken is used. It would look like this: