我正在使用Spring + SOAP + JAXB + XSD开发soap app
我想将名称空间添加到soap请求xml
我现有的请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://WSInfo.co.in/">
<soapenv:Header/>
<soapenv:Body>
<res:WSRequest>
<res:ID>9999999</res:ID>
<res:NAME>JOHN</res:NAME>
<res:MOBILE>9876543210</res:MOBILE>
<res:EMAIL>john@gmail.com</res:EMAIL>
</res:WSRequest>
</soapenv:Body>
</soapenv:Envelope>
我的预期请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://WSInfo.com/">
<soapenv:Header/>
<soapenv:Body>
<res:WSRequest xmlns:res="http://WSInfo.com">
<res:ID>9999999</res:ID>
<res:NAME>JOHN</res:NAME>
<res:MOBILE>9876543210</res:MOBILE>
<res:EMAIL>john@gmail.com</res:EMAIL>
</res:WSRequest>
</soapenv:Body>
如果您看到我想要添加以下内容的预期请求
<res:WSRequest xmlns:res="http://WSInfo.com">
我的端点类
@Endpoint
public class MyEndpoint
{
private static final String TARGET_NAMESPACE = "http://WSInfo.co.in/"";
@PayloadRoot(localPart = "WSRequest", namespace = TARGET_NAMESPACE)
public @ResponsePayload WSResponse getwsDetails(@RequestPayload WSRequest request) throws Exception
{
WSResponse response =new WSResponse();
//logic goes here
return response;
}
}
请告知如何使用命名空间
更改请求xml
两者都有效,但如果我想使用SoapUI
测试服务,则断言失败,因为请求和响应应具有相同的命名空间。在我的例子中,请求包封头具有命名空间而不是res:WSRequest
感谢您能提供帮助
提前致谢