在使用SOAP UI测试SOAP Web Service时,SOAP请求xml值不绑定到Java请求Object并作为空值。
请找到如下代码:
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "UserList")
@ResponsePayload
public JAXBElement<UserListResponse> UserListRequest(@RequestPayload JAXBElement<UserListRequest> request) throws Exception {
System.out.println("Enters into UserList()");
try {
UserListRequest userListRequest = request.getValue();//Giving UserListRequest@2
System.out.println("Number:"+userListRequest.getXMLRequest().getNumber());//Getting Number is null even passing passing in SOAP UI
//As i am not getting why soap Ui values are not binding and object reference is coming to userListRequest.
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
在SOAP UI中请求XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prim="http://COM.SERVICES.WebServices/UserServices">
<soapenv:Header/>
<soapenv:Body>
<prim:UserList>
<!--Optional:-->
<prim:XMLRequest>
<!--Optional:-->
<prim:Header>
<!--Optional:-->
<prim:MessageID>2</prim:MessageID>
<!--Optional:-->
<prim:CorrelationID>2</prim:CorrelationID>
<!--Optional:-->
<prim:SystemID>2</prim:SystemID>
<!--Optional:-->
<prim:RequestorID>2</prim:RequestorID>
</prim:Header>
<prim:Reference>C</prim:Reference>
<!--Optional:-->
<prim:Number>1120521877477751</prim:Number>
<!--Optional:-->
<prim:Usercount>51</prim:Usercount>
</prim:XMLRequest>
</prim:UserList>
</soapenv:Body>
</soapenv:Envelope>
我使用WSDL生成类并将Service操作映射到终点,就像上面的代码一样。没有JAXBElement方法就没有调用。
当我尝试获取在SOAP UI中传递的值时,获取为Null。 Please see debugger mode screen shot as all values are coming as null.
任何人都可以就此提出建议。