如何在SOAP请求中正确定义命名空间?

时间:2017-08-28 14:34:08

标签: java web-services soap

我有一个预先编译的类,我的输入SOAP消息应该适合。(
) 字段和顺序一切正确,除了命名空间,我尝试在@webservice和输入SOAP xmlns中添加相同的命名空间。

然而,我收到以下错误。

enter image description here

我的服务:

@WebService(serviceName = "OTMTransService",targetNamespace="http://xmlns.oracle.com/apps/otm/transmission/v6.4" )
public class OTMTransServiceImpl implements OTMTransService{

我正在点击XML输入,

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:trm="http://receiver.tms.renault">
       <soapenv:Header/>
       <soapenv:Body>
          <trm:publish>
            <Transmission>
        <TransmissionHeader/>
        <TransmissionBody>...
    </TransmissionBody>
   </Transmission>
   </trm:publish>
   </soapenv:Body>
</soapenv:Envelope>

我得到的输出,

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Client</faultcode>
            <faultstring>Unmarshalling Error: unexpected element (uri:"", local:"TransmissionHeader"). Expected elements are &lt;{http://xmlns.oracle.com/apps/otm/transmission/v6.4}TransmissionBody>,&lt;{http://xmlns.oracle.com/apps/otm/transmission/v6.4}TransmissionHeader> </faultstring>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

1 个答案:

答案 0 :(得分:0)

您需要使用名称空间前缀为TransmissionHeader和TransmissionBody添加前缀,并声明该前缀:

In the top tag add: xmlns:ts="http://xmlsns.oracle.com/apps...the rest..." then ... <ts:TransmissionHeader>... <ts:TransmissionBody>...

如果您将XML请求粘贴为文本,我可以更具体地向您展示