用于在JAVA类中初始化Object值的SOAP XML请求

问题描述 投票:1回答:1

我有以下JAVA类:

@WebService()
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL, parameterStyle = ParameterStyle.BARE)
public class Demo extends JaxWsWebService
{
@WebMethod(operationName = "createMethod")
@WebResult(targetNamespace = "xyz.com/")
@RequestWrapper(localName = "Testing", targetNamespace = "xyz.com/", className = "com.Test")
public void createMethod(Testing testingData) throws SOAPException {

    System.out.println(" createMethod service --- xId = " + testingData.getXId() "); // xId is coming as NULL
    System.out.println(" createMethod service --- name = " + testingData.getName() "); // name is coming as NULL
}
}

现在我使用我的SOAP XML Request调用上面的JAVA方法,如下所示:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:NS1="xyz.com/">
<x:Header/>
<x:Body>
<NS1:createMethod>
<NS1:Testing>
    <xId>12345</xId>
    <name>abcd</name>
</NS1:Testing>
</NS1:createMethod>
</x:Body>
</x:Envelope>

现在,当我使用SOAP客户端调用SOAP请求时,调用成功并进入JAVA方法,但主要问题是“Testing”类的“testingData”实例未初始化。

因此,我在我的JAVA方法中将'xId'和'name'变量的值变为NULL。任何有关这方面的建议都会有所帮助,看起来我在SOAP请求调用中犯了错误,但无法弄明白。

请建议。 TIA

java soap soapui soap-client
1个回答
0
投票

找到了我错的地方:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:NS1="xyz.com/">
<x:Header/>
<x:Body>
<NS1:createMethod>
    <xId>12345</xId>
    <name>abcd</name>
</NS1:createMethod>
</x:Body>
</x:Envelope>

在XML请求中,我删除了<NS1:Testing>开始和结束</NS1:Testing>标签,最后它开始为我工作。

© www.soinside.com 2019 - 2024. All rights reserved.