是否可以从 SOAP 信封中确定 WCF 绑定配置? [英] Is it possible to determine a WCF binding configuration from the SOAP envelope?

查看:23
本文介绍了是否可以从 SOAP 信封中确定 WCF 绑定配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 WSDL 文件生成了一个 WCF 客户端服务代理,该文件调用了第三方 Java Web 服务.现在我需要配置绑定和代理来调用 Web 方法.

I've generated a WCF client service proxy from a WSDL file, which calls a third-party java web service. Now I need to configure the binding and proxy to call a web method.

但是,我只有以下 SOAP 信息、用户名和密码以及客户端证书.我怎样才能弄清楚我需要做什么?

However, I only have the below SOAP information, a username and password, and a client certificate. How can I work out what I need to do?

是否有任何将其反转为配置"的应用程序或教授所需技能的网站?

Are there any "reverse this to configuration" apps, or websites that teach the skills required?

我想我是在消息的这一部分,翻译成这个配置".有人可以帮忙吗?

I think I am after, "this part of the message, translates to this configuration". Can anyone help?

对于同一个项目,我问了这个问题,所以如果有人知道向第三方询问什么,那也会有所帮助(我将其描述为通信信息",但我认为不够具体).

For the same project, I asked this question, so if anyone knows what to ask the third party for, that would also be of help (I'd describe this as "communication information", but I don't think that specific enough).

    <env:Envelope xmlns:env=http://schemas.xmlsoap.org/soap/envelope/xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://etis.ford.com/services/fsa/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <env:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" env:mustUnderstand="1">
        <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-messagesecurity-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="token-2-1172677451503-9243153">MIICDTCC……..k/j8lARlQ==</wsse:BinarySecurityToken>
        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
        <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
        <ds:Reference URI="#element-1-1172677451465-2619907">
        <ds:Transforms>
            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
        <ds:DigestValue>k_REDACTED_=</ds:DigestValue>
        </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>k_REDACTED_=</ds:SignatureValue>
        <ds:KeyInfo>
        <wsse:SecurityTokenReference wsu:Id="reference-3-1172…..1504-94…25">
        <wsse:Reference URI="#token-2-117…..51503-9…3" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference>
        </ds:KeyInfo>
        </ds:Signature>
        </wsse:Security>
    </env:Header>
    <env:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"wsu:Id="element-1-1172677451465-2619907">
        <ns0:list>
            <String_1>k_REDACTED_</String_1>
        </ns0:list>
    </env:Body>
    </env:Envelope>

以下内容是生成到我的 app.config 中的.它没有例外,但我得到的响应(以正确格式的 XML 格式)包含没有"的对象 - 实际响应看起来像是我发送内容的镜像.

The following was generated to my app.config. It doesn't have an exception, but the response I get (in correctly formed XML) contains objects with "nothing" - the actual response looks like a mirror of what I sent.

<bindings>
    <basicHttpBinding>
        <binding name="MyBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>
<client>
    <endpoint address="http://myurl"
        binding="basicHttpBinding" bindingConfiguration="MyBinding"
        contract="wsServiceProxy.ServiceName" name="MyServicePort" />
</client>

请求:

POST http://www.thehost.com/
Content-Type: text/xml; charset=utf-8
VsDebuggerCausalityData: uIDPo2dteAUjcNNDmQ28Qhsz8KcAAAAARUELWtvXc06cOf2eOs23AWKlzgCLFBNImUOop7Ho+PoACQAA
SOAPAction: ""
Host: www.thehost.com
Content-Length: 299
Expect: 100-continue
Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <list xmlns="http://thehost.com">
            <String_1 xmlns="">MyString</String_1>
        </list>
    </s:Body>
</s:Envelope>

回复:

HTTP/1.1 200 OK
Date: Thu, 24 Oct 2013 14:17:20 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/1.0.0a mod_jk/1.2.31
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
VsDebuggerCausalityData: uIDPo2dteAUjcNNDmQ28Qhsz8KcAAAAARUELWtvXc06cOf2eOs23AWKlzgCLFBNImUOop7Ho+PoACQAA
SOAPAction: ""
host: www.thehost.com
Expect: 100-continue
connection: Keep-Alive, Keep-Alive
Content-Length: 299
Keep-Alive: timeout=2, max=100
Content-Type: text/xml;charset=utf-8

<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
    <s:Body xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
        <list xmlns='http://thehost.com'>
            <String_1 xmlns=''>MyString</String_1>
        </list>
    </s:Body>
</s:Envelope>

推荐答案

使用这个自定义绑定:

<customBinding>
        <binding name="NewBinding0">
            <textMessageEncoding messageVersion="Soap11" />
            <security authenticationMode="MutualCertificate" includeTimestamp="false"
                messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
                <secureConversationBootstrap />
            </security>
            <httpTransport />
        </binding>
</customBinding>

确保装饰你的合同只签署:

make sure to decorate your contract to sign only:

[System.ServiceModel.ServiceContractAttribute(ConfigurationName=..., ProtectionLevel=System.Net.Security.ProtectionLevel.Sign)]

除了客户端证书之外,您还需要配置服务证书.您(可能)没有这样的证书,没关系,只需在那里配置任何虚拟证书(甚至与客户端相同).

you will need to configure a service certificate in addition to a client certificate. You (probably) don't have such certificate which is ok, just configure any dummy certificate there (even same one as client).

请参阅此链接在这种情况下更多可能的错误解决方案.

See this link for more possible error resolution with this scenario.

这篇关于是否可以从 SOAP 信封中确定 WCF 绑定配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆