Web services 如何为需要SAML令牌的web服务创建客户端
好的,我的任务是基本上自动化一些在公司内部发出的web服务请求。因为我知道wsdl的位置,所以我创建了一个简单的空白控制台应用程序,并添加了一个指向该wsdl的服务引用。VS创建了代理类以及与之配套的app.config文件。以下是它生成的app.config文件:Web services 如何为需要SAML令牌的web服务创建客户端,web-services,wcf,soap,wsdl,ws-federation,Web Services,Wcf,Soap,Wsdl,Ws Federation,好的,我的任务是基本上自动化一些在公司内部发出的web服务请求。因为我知道wsdl的位置,所以我创建了一个简单的空白控制台应用程序,并添加了一个指向该wsdl的服务引用。VS创建了代理类以及与之配套的app.config文件。以下是它生成的app.config文件: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="TestBinding">
<security authenticationMode="UserNameOverTransport" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12">
</security>
<httpTransport/>
</binding>
<binding name="STSBinding">
<security allowInsecureTransport="False"
authenticationMode="UserNameOverTransport"
requireSignatureConfirmation="false"
messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12">
</security>
<textMessageEncoding messageVersion="Soap12WSAddressing10" />
<httpsTransport/>
</binding>
</customBinding>
<ws2007FederationHttpBinding>
<binding name="WS2007FederationHttpBinding_TestsService">
<security mode="TransportWithMessageCredential">
<message establishSecurityContext="false" issuedKeyType="BearerKey"
issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
<issuer address="https://sts.abc.com/idp/sts.wst" bindingConfiguration="STSBinding" binding="customBinding"/>
<issuerMetadata address="http://docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust-1.3.wsdl" />
<tokenRequestParameters>
<trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
<trust:TokenType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</trust:TokenType>
<trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
<trust:Claims Dialect="http://schemas.xmlsoap.org/ws/2005/05/identity"
xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
<wsid:ClaimType Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"
Optional="true" xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />
<wsid:ClaimType Uri="http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
Optional="true" xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />
<wsid:ClaimType Uri="http://schemas.xmlsoap.org/claims/AppId"
xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />
<wsid:ClaimType Uri="http://schemas.xmlsoap.org/claims/Environment"
xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />
<wsid:ClaimType Uri="http://schemas.xmlsoap.org/claims/SecondLvlAuthzId"
xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />
</trust:Claims>
<trust:CanonicalizationAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>
<trust:EncryptionAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>
</trust:SecondaryParameters>
</tokenRequestParameters>
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
</bindings>
<client>
<endpoint address="https://Tests.abc.com/201308/TestsService.svc"
binding="ws2007FederationHttpBinding" bindingConfiguration="WS2007FederationHttpBinding_TestsService"
contract="ServiceReference1.TestsService" name="WS2007FederationHttpBinding_TestsService" />
</client>
</system.serviceModel>
</configuration>
我实际上无法控制现有的web服务。我不确定继续调试问题的最佳方法。我还是缺少配置中的东西吗?如果我是,我怎么知道
我现在遇到的最新错误是:
“{”无法通过AppliesTo确定伙伴SP连接:“}”您正在使用联合安全性 错误的意思是找不到要使用的服务提供商 配置中的客户端地址与根据错误调用的服务不匹配
您的程序似乎没有使用您发布的配置。谢谢您的反馈。我已确认应用程序正确使用app.config文件设置。我的配置是否存在潜在问题?
TestServiceClient vClient = new TestServiceClient();
ServiceProcessingDirectivesType vType = new ServiceProcessingDirectivesType();
UserContextType vUserContextType = new UserContextType();
ServiceCallContextType vServiceCallContextType = new ServiceCallContextType();
GetSummaryRequest vRequest = new GetSummaryRequest();
vClient.ClientCredentials.UserName.UserName = "Test";
vClient.ClientCredentials.UserName.UserName = "Pass";
vClient.GetSummary(vType, vUserContextType, ref vServiceCallContextType, vRequest);