multiRef in generated xml sending by WS

末鹿安然 提交于 2019-12-23 09:59:46

问题


I have application that running on my local machine on jboss.
I downloaded wsdl file, generate java code in eclipse. Run and have exception:

caught exception while handling request: deserialization error: java.lang.NumberFormatException: For input string: ""

(Application correctly work with another simple WS).

After some Googling I found that code generate wrong xml:
expected:

<soapenv:Body>
    <ns1:setLevel soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:ns1="###">
        <id xsi:type="xsd:string">x2148</id>
        <level xsi:type="xsd:long">5</level>
    </ns1:setLevel>
</soapenv:Body>

but through TCPMon/Fiddler i found that my requests look like that:

<soapenv:Body>
    <ns1:setLevel soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:ns1="###">
        <id xsi:type="xsd:string">x2148</id>
        <level href="#id0" />
    </ns1:setLevel>
    <multiRef id="id0" soapenc:root="0"
        soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">5</multiRef>
</soapenv:Body>  

after googling i found that solution is change

<parameter name="sendMultiRefs" value="true"/>

on false in server-config.wsdd file on server side. But i don't have this file.
Any solutions? I see only one solution - change xml file on runtime - but it's sounds not good.


回答1:


The server-config.wsdd file is a part of the remote service description. The entity that published that WSDL you downloaded (service provider) would have to change it and redeploy on their side. Lucky you if you published the service...you can change it. Unlucky you if dealing with third-party.

We dealt with a similar problem by applying a stylesheet to the response to flatten the multi refs. Got the stylesheet from StackOverflow in fact [here][1]Creating XSLT transform to flatten multiRef encoded SOAP message

It works pretty good as is to flatten the response back to the schema you were expecting. But be warned, it doesn't handle multiRefs of multiRefs. I need a solution to that myself.



来源:https://stackoverflow.com/questions/14319468/multiref-in-generated-xml-sending-by-ws

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!