如何使用引导令牌正确连接到WCF服务



我找不到我做错了什么

当我尝试调用服务操作时,我得到错误:

通信对象System.ServiceModel.Channels。

ServiceChannel的状态为"Faulted",不能用于通信。
    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>

尝试使用CreateChannelWithIssuedToken调用的返回值来调用服务,而不是使用客户端变量。请参阅本示例中的CreateChannel代码,了解如何使用CreateChannelWithIssuedToken。它看起来像这样:

var serviceClient = ChannelFactoryOperations.CreateChannelWithIssuedToken<Ref.ISService_V1_0>(client.ChannelFactory, ((Microsoft.IdentityModel.Claims.ClaimsIdentity)(Page.User.Identity)).BootstrapToken);
serviceClient.StartTransaction("string argument");

相关内容

  • 没有找到相关文章

最新更新