我遇到了几个问题,假设 Excel 电子表格调用我在 JAX-WS 中创建的 Java Web 服务并取回结果。但是,不发送或接收返回 NodeList 存在一些问题。我不确定我需要如何更改我的网络服务来处理这个问题。
另一个问题是 MS Office 2003 Web Service Toolkit 将 Web 方法定义为子例程而不是函数。
我的 web 方法在端点接口中定义为:
@WebMethod
@WebResult(name="CreateWorkOrderItemResponse")
CreateWorkOrderItemResponse createWorkItems(@WebParam(name = "CreateWorkOrderItemRequest")CreateWorkOrderItemRequest request);
CreateWorkOrderItemRequest定义为:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"authentication",
"createData"
})
@XmlRootElement(name = "CreateWorkOrderItemRequest", namespace="")
public class CreateWorkOrderItemRequest {
@XmlElement(name = "authentication", required = true)
protected Authentication authentication = null;
@XmlElement(name = "create_data", required = true)
protected ArrayList<CreateWorkOrderItemData> createData = new ArrayList<CreateWorkOrderItemData>();
public Authentication getAuthentication() {
return authentication;
}
public void setAuthentication(Authentication authentication) {
this.authentication = authentication;
}
public ArrayList<CreateWorkOrderItemData> getCreateData() {
return createData;
}
public void setCreateData(ArrayList<CreateWorkOrderItemData> createData) {
this.createData = createData;
}
}
CreateWorkOrderItemResponse定义为:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"submissionResponse",
"errorList"
})
@XmlRootElement(name = "CreateWorkOrderItemResponse")
public class CreateWorkOrderItemResponse{
@XmlElement(name = "submission_response", required = true)
protected SubmissionResponse submissionResponse = new SubmissionResponse();
@XmlElementWrapper(name="error_list")
@XmlElement(name="error", required = true, nillable = true)
protected ArrayList<Error> errorList = new ArrayList<Error>();
public SubmissionResponse getSubmissionResponse() {
return submissionResponse;
}
public void setSubmissionResponse(SubmissionResponse submissionResponse) {
this.submissionResponse = submissionResponse;
}
public ArrayList<Error> getErrorList() {
return errorList;
}
public void addError(Error error) {
errorList.add(error);
}
public void addErrors(ArrayList<Error> errors) {
for (Error error : errors) {
errorList.add(error);
}
}
public void setErrorList(ArrayList<Error> errorList) {
this.errorList = errorList;
}
}
Web Service Toolkit 的结果如下所示:
Public Sub wsm_createWorkItems()
'*****************************************************************
'Proxy subroutine created from http://localhost:8080/gbswebsvcs/seiwebsvcs?wsdl.
'*****************************************************************
'Error Trap
On Error GoTo wsm_createWorkItemsTrap
sc_SEIWebServiceImplServ.createWorkItems
Exit Sub
wsm_createWorkItemsTrap:
SEIWebServiceImplServErrorHandler "wsm_createWorkItems"
End Sub
但显然它应该更像这样:
Public Function wsm_createWorkItems(ByVal any_CreateWorkOrderItemRequest As MSXML2.IXMLDOMNodeList) As MSXML2.IXMLDOMNodeList
'*****************************************************************
'Proxy function created from http://localhost:8080/gbswebsvcs/seiwebsvcs?wsdl.
'"wsm_createWorkItems, any_CreateWorkOrderItemRequest" is defined as XML. See Complex Types: XML Variables in
'Microsoft Office 2003 Web Services Toolkit Help for details on implementing XML variables.
'*****************************************************************
'Error Trap
On Error GoTo wsm_createWorkItemsTrap
Set wsm_createWorkItems = sc_DataServicesServer.createWorkItems(any_CreateWorkOrderItemRequest)
Exit Function
wsm_createWorkItemsTrap:
DataServicesServerErrorHandler "wsm_createWorkItems"
End Function
我如何做到这一点?非常感谢你的帮助。