通过参数将 XML 对象发送到 WebLogic 服务器上发布的 WebService
Send XML object by parameter to a WebService published on a WebLogic server
我正在尝试将一个 XML 对象发送到我在 WebLogic 服务器上发布的 WebService,但即使我发送这个对象,它也始终被接收为 null。
这是 WebService 的代码以及我发送 XML 的方式。
有什么想法吗?
代码JAVA
服务方式:
@WebMethod(operationName = "ConsultarRecibosPendientes")
@WebResult(name = "ConsultarRecibosPendientesResult")
public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(@WebParam( name = "oReq")
ConsultarRecibosPendientesReq objeto) {
ConsultarRecibosPendientesRes recibosRes = new ConsultarRecibosPendientesRes();
String LlaveAcceso = objeto.getStrLlaveAcceso();
recibosRes.setStrIdentificacion(LlaveAcceso);
return recibosRes;
}
Class参数接收的对象:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ConsultarRecibosPendientesReq")
public class ConsultarRecibosPendientesReq {
@XmlElement(name = "strLlaveAcceso")
protected String strLlaveAcceso;
public ConsultarRecibosPendientesReq(){ }
public String getStrLlaveAcceso() {
return strLlaveAcceso;
}
public void setStrLlaveAcceso(String strLlaveAcceso) {
this.strLlaveAcceso = strLlaveAcceso;
}
}
QueryReceivePendientesReq 对象始终为空。有人知道怎么解决吗?
首先我对参数接收的对象的class做了一些修改:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "consultarRecibosPendientesReq", propOrder = {
"strLlaveAcceso"
})
public class ConsultarRecibosPendientesReq {
protected String strLlaveAcceso;
public String getStrLlaveAcceso() {
return strLlaveAcceso;
}
public void setStrLlaveAcceso(String value) {
this.strLlaveAcceso = value;
}
}
我对 WebService 方法进行了更改:
@WebMethod(operationName = "ConsultarRecibosPendientes")
@WebResult(name = "ConsultarRecibosPendientesResult")
public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(
@WebParam(name = "oReq", targetNamespace = "")
ConsultarRecibosPendientesReq oReq) {...}
最后,我对发送的 XML 进行了更改,我将 "web" 子句添加到 "method" 和 "target name space" 标记中,例如:
<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<web:ConsultarRecibosPendientes xmlns:web="http://websercice.fi.co/">
<oReq>
<strLlaveAcceso>llave de acceso</strLlaveAcceso>
</oReq>
</web:ConsultarRecibosPendientes>
</soap:Body>
</soap:Envelope>
我正在尝试将一个 XML 对象发送到我在 WebLogic 服务器上发布的 WebService,但即使我发送这个对象,它也始终被接收为 null。
这是 WebService 的代码以及我发送 XML 的方式。 有什么想法吗?
代码JAVA 服务方式:
@WebMethod(operationName = "ConsultarRecibosPendientes")
@WebResult(name = "ConsultarRecibosPendientesResult")
public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(@WebParam( name = "oReq")
ConsultarRecibosPendientesReq objeto) {
ConsultarRecibosPendientesRes recibosRes = new ConsultarRecibosPendientesRes();
String LlaveAcceso = objeto.getStrLlaveAcceso();
recibosRes.setStrIdentificacion(LlaveAcceso);
return recibosRes;
}
Class参数接收的对象:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ConsultarRecibosPendientesReq")
public class ConsultarRecibosPendientesReq {
@XmlElement(name = "strLlaveAcceso")
protected String strLlaveAcceso;
public ConsultarRecibosPendientesReq(){ }
public String getStrLlaveAcceso() {
return strLlaveAcceso;
}
public void setStrLlaveAcceso(String strLlaveAcceso) {
this.strLlaveAcceso = strLlaveAcceso;
}
}
QueryReceivePendientesReq 对象始终为空。有人知道怎么解决吗?
首先我对参数接收的对象的class做了一些修改:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "consultarRecibosPendientesReq", propOrder = {
"strLlaveAcceso"
})
public class ConsultarRecibosPendientesReq {
protected String strLlaveAcceso;
public String getStrLlaveAcceso() {
return strLlaveAcceso;
}
public void setStrLlaveAcceso(String value) {
this.strLlaveAcceso = value;
}
}
我对 WebService 方法进行了更改:
@WebMethod(operationName = "ConsultarRecibosPendientes")
@WebResult(name = "ConsultarRecibosPendientesResult")
public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(
@WebParam(name = "oReq", targetNamespace = "")
ConsultarRecibosPendientesReq oReq) {...}
最后,我对发送的 XML 进行了更改,我将 "web" 子句添加到 "method" 和 "target name space" 标记中,例如:
<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<web:ConsultarRecibosPendientes xmlns:web="http://websercice.fi.co/">
<oReq>
<strLlaveAcceso>llave de acceso</strLlaveAcceso>
</oReq>
</web:ConsultarRecibosPendientes>
</soap:Body>
</soap:Envelope>