0

好吧,我的任务是从根本上自动化我公司内部发出的一些 Web 服务请求。因为我知道 wsdl 的位置,所以我创建了一个简单的空白控制台应用程序并添加了一个指向该 wsdl 的服务引用。VS 创建了代理类和与之配套的 app.config 文件。这是它生成的 app.config 文件:

    <?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>

我自己添加了 CustomBindings,显然是在尝试使用它。到目前为止,当我尝试像这样使用客户端时,我遇到了很多错误:

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);

我几乎无法控制那里的 Web 服务。我不确定继续调试问题的最佳方法。我还缺少配置中的东西吗?如果我是,我怎么知道?

我现在遇到的最新错误是:“{”AppliesTo 无法确定合作伙伴 SP 连接:https ://dc-balances-acp.fmr.com/201308/BalancesService.svc “}”

4

1 回答 1

0

您正在使用联合安全性。

错误的意思是它找不到要使用的服务提供者。

您的配置中的客户端地址和根据错误调用的服务不匹配。

您的程序似乎没有使用您发布的配置。

于 2014-04-02T15:43:11.853 回答