我之前已經從WSDL生成了Metro/JAXB客戶端,並且將Java類編組/解組到SOAP/XML中的工作沒有任何問題。我產生了一個新的客戶,似乎有解組問題,我不知道爲什麼。 WSDL非常大(> 27,000行),我不得不使用-B-XautoNameResolution,因爲除了大小寫外,其他元素名稱相同。解析webservice響應的問題(Metro/JAXB)
我試圖執行此方法/操作:
@WebService(name = "servicePortType", targetNamespace = "urn:service")
@XmlSeeAlso({
ObjectFactory.class
})
public interface ServicePortType {
/**
* Service definition of function unsp__GetSubscriberList
*
* @param result
* @param totalSubsFound
* @param getSubListReq
* @param paginatedInfo
* @param getSubscriberListData
*/
@WebMethod(operationName = "GetSubscriberList")
@RequestWrapper(localName = "GetSubscriberList", targetNamespace = "urn:service", className = "service.GetSubscriberList")
@ResponseWrapper(localName = "GetSubscriberListResult", targetNamespace = "urn:service", className = "service.GetSubscriberListResult")
public void getSubscriberList(
@WebParam(name = "GetSubListReq", targetNamespace = "")
GetSubscriberListRequest getSubListReq,
@WebParam(name = "Result", targetNamespace = "", mode = WebParam.Mode.OUT)
Holder<ResultCodeStruct> result,
@WebParam(name = "PaginatedInfo", targetNamespace = "", mode = WebParam.Mode.OUT)
Holder<PaginatedInfo> paginatedInfo,
@WebParam(name = "TotalSubsFound", targetNamespace = "", mode = WebParam.Mode.OUT)
Holder<Integer> totalSubsFound,
@WebParam(name = "GetSubscriberListData", targetNamespace = "", mode = WebParam.Mode.OUT)
Holder<GetSubscriberListData> getSubscriberListData);
}
此方法將返回用戶數據和用戶也的總數。我的電話是這樣的:
public int getTotalSubscriptions()
throws Exception
{
GetSubscriberListRequest subscriberListRequest = factory.createGetSubscriberListRequest();
Holder<ResultCodeStruct> result = null;
Holder<PaginatedInfo> paginatedInfo = null;
Holder<Integer> totalSubsFound = null;
Holder<GetSubscriberListData> subscriberListData = null;
subscriberListRequest.setMaxSubscribers(factory.createGetSubscriberListRequestMaxSubscribers(1));
port.getSubscriberList(subscriberListRequest,
result,
paginatedInfo,
totalSubsFound,
subscriberListData);
if (result.value.getResultCode() != CODE_SUCCESS)
{
throw new Exception("Failed call");
}
return totalSubsFound.value.intValue();
}
我得到一個NullPointerException對結果對象。我跟蹤了SOAP調用,並且返回的XML與預期的一樣,包括一個Result元素。
我從來沒有遇到過WebParam.Mode.OUT。在我打電話之前是否應該初始化持有人<>實例?什麼?
這些元素封裝在SOAP中的GetSubscriberListResult元素中,但由於接口方法具有在@ResponseWrapper中定義的方法,因此我期望它們被解組入傳入的對象中。也許我需要做其他事情?
任何意見/幫助非常感謝!