简体   繁体   English

生成的和预期的SOAP消息之间的补救措施存在细微差别

[英]Remedy subtle difference between generated and expected SOAP message

I'm trying to establish some communictaion between services hosted on different platforms: .net <-> java. 我正在尝试在不同平台上托管的服务之间建立某种通信:.net <-> Java。 It's not possible for me to change anything in the Java part. 对我来说,更改Java部分中的任何内容都是不可能的。 This is third party software to which we have no access. 这是我们无法访问的第三方软件。

My troubles basically boil down to a subtle difference in what the services is expecting (tested with SoapUI) and what WCF is sending (tested via tracing). 我的麻烦基本上归结为服务期望(使用SoapUI测试)和WCF发送(通过跟踪测试)发送的内容之间的细微差异。

Expected (or at least allowed): 预期(或至少允许):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
     xmlns:ser="http://servicenamespace/">      
    <s:Header /> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">      
        <ser:method >           
            <param1/>
            <param2>xxx</param2>
            <param3>zzz</param3>        
        </ser:method>   
    </s:Body>
</s:Envelope>

What .NET actually tries to send: .NET实际尝试发送的内容:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header/>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <method xmlns="http://servicenamespace/">
            <param1/>
            <param2>xxx</param2>
            <param3>zzz</param3>
        </method>
    </s:Body>
</s:Envelope>

As you see, the difference is subtle. 如您所见,差异是微小的。 What the servicen is expecting is the namespace declaration in the header tag... Is there some way to fix this, preferably in a low impact (eg not intercepting and changing the message) manner? servicen期望的是标头标记中的名称空间声明...是否有某种方法可以解决此问题,最好以较低的影响(例如,不截取和更改消息)的方式? Perhaps by using attributes in some other manner? 也许通过以其他方式使用属性?

No, the difference is less subtle than you think and it is not about the placement of the namespace declarations. 不,区别没有您想像的那么细微,与名称空间声明的位置无关。 It is about the namespace of the paramX elements. 它与paramX元素的名称空间有关。

  • In your first example, the paramX elements are in the null -namespace; 在第一个示例中, paramX元素位于null -namespace中;

  • in your second example, the paramX elements are in http://servicenamespace/ . 在第二个示例中, paramX元素位于http://servicenamespace/

This kind of difference must be evident in the XML Schema of your message body and the tool you use to build the code from the Schema must respect that. 这种差异必须在消息正文的XML模式中显而易见,并且用于从该模式构建代码的工具必须尊重这一点。 So perhaps you can make an intervention into either the code-building tool or the generated code. 因此,也许您可​​以干预代码构建工具或生成的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM