java - instalar - El eje 1.4 no puede deserializar la respuesta
org apache axis wsdl wsdl2java (1)
Estoy implementando un cliente que accede a un servicio antiguo, después de algunas investigaciones descubrí que necesitaba que el usuario Axis 1.4 se comunicara con este servicio. Después de generar el código java desde wsdl, puedo ver que Axis no está deserializando la respuesta de forma correlativa, parece que está leyendo el elemento como si fuera otro.
Esto es de wsdl del servicio:
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="PC_Precoservice" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="urn:uResultadoPreco" xmlns:ns2="urn:uRequisicao" xmlns:ns3="urn:uPreco">
<types>
<xs:schema targetNamespace="urn:uResultadoPreco" xmlns="urn:uResultadoPreco">
<xs:complexType name="TResultadoPreco">
<xs:sequence>
<xs:element name="StatusRetorno" type="ns2:TRequisicaoPreco"/>
<xs:element name="Dados" type="ns3:TArrayPreco"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema targetNamespace="urn:uRequisicao" xmlns="urn:uRequisicao">
<xs:complexType name="TRequisicaoPreco">
<xs:sequence>
<xs:element name="Codigo" type="xs:int"/>
<xs:element name="Mensagem" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema targetNamespace="urn:uPreco" xmlns="urn:uPreco">
<xs:complexType name="TArrayPreco">
<xs:complexContent>
<xs:restriction base="soapenc:Array">
<xs:sequence/>
<xs:attribute ref="soapenc:arrayType" n1:arrayType="ns3:TPreco[]" xmlns:n1="http://schemas.xmlsoap.org/wsdl/"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TPreco">
<xs:sequence>
<xs:element name="codigo_produto" type="xs:int"/>
<xs:element name="preco_venda" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="Pesquisar0Request">
<part name="Codigo_Produto" type="xs:int"/>
</message>
<message name="Pesquisar0Response">
<part name="return" type="ns1:TResultadoPreco"/>
</message>
<message name="PesquisarPorRegiao1Request">
<part name="Codigo_Produto" type="xs:int"/>
<part name="Numero_Regiao" type="xs:int"/>
</message>
<message name="PesquisarPorRegiao1Response">
<part name="return" type="ns1:TResultadoPreco"/>
</message>
<message name="PesquisarPorRegiaoPorFilial2Request">
<part name="Codigo_Produto" type="xs:int"/>
<part name="Numero_Regiao" type="xs:int"/>
<part name="Codigo_Filial" type="xs:string"/>
</message>
<message name="PesquisarPorRegiaoPorFilial2Response">
<part name="return" type="ns1:TResultadoPreco"/>
</message>
<portType name="PC_Preco">
<operation name="Pesquisar">
<input message="tns:Pesquisar0Request"/>
<output message="tns:Pesquisar0Response"/>
</operation>
<operation name="PesquisarPorRegiao">
<input message="tns:PesquisarPorRegiao1Request"/>
<output message="tns:PesquisarPorRegiao1Response"/>
</operation>
<operation name="PesquisarPorRegiaoPorFilial">
<input message="tns:PesquisarPorRegiaoPorFilial2Request"/>
<output message="tns:PesquisarPorRegiaoPorFilial2Response"/>
</operation>
</portType>
<binding name="PC_Precobinding" type="tns:PC_Preco">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Pesquisar">
<soap:operation soapAction="urn:uPCPrecoIntf-PC_Preco#Pesquisar" style="rpc"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uPCPrecoIntf-PC_Preco"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uPCPrecoIntf-PC_Preco"/>
</output>
</operation>
<operation name="PesquisarPorRegiao">
<soap:operation soapAction="urn:uPCPrecoIntf-PC_Preco#PesquisarPorRegiao" style="rpc"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uPCPrecoIntf-PC_Preco"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uPCPrecoIntf-PC_Preco"/>
</output>
</operation>
<operation name="PesquisarPorRegiaoPorFilial">
<soap:operation soapAction="urn:uPCPrecoIntf-PC_Preco#PesquisarPorRegiaoPorFilial" style="rpc"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uPCPrecoIntf-PC_Preco"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uPCPrecoIntf-PC_Preco"/>
</output>
</operation>
</binding>
<service name="PC_Precoservice">
<port name="PC_PrecoPort" binding="tns:PC_Precobinding">
<soap:address location="http://192.168.1.13/PCSIS2699.EXE/soap/PC_Preco"/>
</port>
</service>
</definitions>
cuando llamo al método
TResultadoPreco Pesquisar(int Codigo_Produto)
el servicio devuelve la siguiente respuesta (la obtuve usando SoapUI):
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return>
<StatusRetorno>
<Codigo>0</Codigo>
<Mensagem>OK</Mensagem>
</StatusRetorno>
<Dados>
<item>
<codigo_produto>63768</codigo_produto>
<preco_venda>8.35</preco_venda>
</item>
</Dados>
</return>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Sin embargo, mi cliente está recibiendo este error:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Invalid element in com.brevleq.padrao_taf.clients.pc_preco.uResultadoPreco.TResultadoPreco - Codigo
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Invalid element in com.brevleq.padrao_taf.clients.pc_preco.uResultadoPreco.TResultadoPreco - Codigo
No puedo entender qué pasa con mi cliente, ya que el código se generó automáticamente, se supone que funciona correctamente.
Estos son algunos de los archivos generados por wsdl2java:
PC_PrecobindingStub
public class PC_PrecobindingStub extends org.apache.axis.client.Stub implements PC_Preco {
private java.util.Vector cachedSerClasses = new java.util.Vector();
private java.util.Vector cachedSerQNames = new java.util.Vector();
private java.util.Vector cachedSerFactories = new java.util.Vector();
private java.util.Vector cachedDeserFactories = new java.util.Vector();
static org.apache.axis.description.OperationDesc[] _operations;
static {
_operations = new org.apache.axis.description.OperationDesc[3];
_initOperationDesc1();
}
private static void _initOperationDesc1() {
org.apache.axis.description.OperationDesc oper;
org.apache.axis.description.ParameterDesc param;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("Pesquisar");
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "Codigo_Produto"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
oper.addParameter(param);
oper.setReturnType(new javax.xml.namespace.QName("urn:uResultadoPreco", "TResultadoPreco"));
oper.setReturnClass(TResultadoPreco.class);
oper.setReturnQName(new javax.xml.namespace.QName("", "return"));
oper.setStyle(org.apache.axis.constants.Style.RPC);
oper.setUse(org.apache.axis.constants.Use.ENCODED);
_operations[0] = oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("PesquisarPorRegiao");
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "Codigo_Produto"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
oper.addParameter(param);
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "Numero_Regiao"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
oper.addParameter(param);
oper.setReturnType(new javax.xml.namespace.QName("urn:uResultadoPreco", "TResultadoPreco"));
oper.setReturnClass(TResultadoPreco.class);
oper.setReturnQName(new javax.xml.namespace.QName("", "return"));
oper.setStyle(org.apache.axis.constants.Style.RPC);
oper.setUse(org.apache.axis.constants.Use.ENCODED);
_operations[1] = oper;
oper = new org.apache.axis.description.OperationDesc();
oper.setName("PesquisarPorRegiaoPorFilial");
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "Codigo_Produto"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
oper.addParameter(param);
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "Numero_Regiao"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
oper.addParameter(param);
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "Codigo_Filial"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, false, false);
oper.addParameter(param);
oper.setReturnType(new javax.xml.namespace.QName("urn:uResultadoPreco", "TResultadoPreco"));
oper.setReturnClass(TResultadoPreco.class);
oper.setReturnQName(new javax.xml.namespace.QName("", "return"));
oper.setStyle(org.apache.axis.constants.Style.RPC);
oper.setUse(org.apache.axis.constants.Use.ENCODED);
_operations[2] = oper;
}
public PC_PrecobindingStub() throws org.apache.axis.AxisFault {
this(null);
}
public PC_PrecobindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
this(service);
super.cachedEndpoint = endpointURL;
}
public PC_PrecobindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
if (service == null) {
super.service = new org.apache.axis.client.Service();
} else {
super.service = service;
}
((org.apache.axis.client.Service) super.service).setTypeMappingVersion("1.2");
java.lang.Class cls;
javax.xml.namespace.QName qName;
javax.xml.namespace.QName qName2;
java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;
java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class;
java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class;
java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class;
java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class;
java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class;
java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class;
java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class;
java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class;
java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;
qName = new javax.xml.namespace.QName("urn:uPreco", "TArrayPreco");
cachedSerQNames.add(qName);
cls = TPreco[].class;
cachedSerClasses.add(cls);
qName = new javax.xml.namespace.QName("urn:uPreco", "TPreco");
qName2 = null;
cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2));
cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory());
qName = new javax.xml.namespace.QName("urn:uPreco", "TPreco");
cachedSerQNames.add(qName);
cls = TPreco.class;
cachedSerClasses.add(cls);
cachedSerFactories.add(beansf);
cachedDeserFactories.add(beandf);
qName = new javax.xml.namespace.QName("urn:uRequisicao", "TRequisicao");
cachedSerQNames.add(qName);
cls = TRequisicao.class;
cachedSerClasses.add(cls);
cachedSerFactories.add(beansf);
cachedDeserFactories.add(beandf);
qName = new javax.xml.namespace.QName("urn:uResultadoPreco", "TResultadoPreco");
cachedSerQNames.add(qName);
cls = TResultadoPreco.class;
cachedSerClasses.add(cls);
cachedSerFactories.add(beansf);
cachedDeserFactories.add(beandf);
}
protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
try {
org.apache.axis.client.Call _call = super._createCall();
if (super.maintainSessionSet) {
_call.setMaintainSession(super.maintainSession);
}
if (super.cachedUsername != null) {
_call.setUsername(super.cachedUsername);
}
if (super.cachedPassword != null) {
_call.setPassword(super.cachedPassword);
}
if (super.cachedEndpoint != null) {
_call.setTargetEndpointAddress(super.cachedEndpoint);
}
if (super.cachedTimeout != null) {
_call.setTimeout(super.cachedTimeout);
}
if (super.cachedPortName != null) {
_call.setPortName(super.cachedPortName);
}
java.util.Enumeration keys = super.cachedProperties.keys();
while (keys.hasMoreElements()) {
java.lang.String key = (java.lang.String) keys.nextElement();
_call.setProperty(key, super.cachedProperties.get(key));
}
// All the type mapping information is registered
// when the first call is made.
// The type mapping information is actually registered in
// the TypeMappingRegistry of the service, which
// is the reason why registration is only needed for the first call.
synchronized (this) {
if (firstCall()) {
// must set encoding style before registering serializers
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
for (int i = 0; i < cachedSerFactories.size(); ++i) {
java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i);
javax.xml.namespace.QName qName =
(javax.xml.namespace.QName) cachedSerQNames.get(i);
java.lang.Object x = cachedSerFactories.get(i);
if (x instanceof Class) {
java.lang.Class sf = (java.lang.Class)
cachedSerFactories.get(i);
java.lang.Class df = (java.lang.Class)
cachedDeserFactories.get(i);
_call.registerTypeMapping(cls, qName, sf, df, false);
} else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) {
org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory)
cachedSerFactories.get(i);
org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory)
cachedDeserFactories.get(i);
_call.registerTypeMapping(cls, qName, sf, df, false);
}
}
}
}
return _call;
} catch (java.lang.Throwable _t) {
throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t);
}
}
public TResultadoPreco pesquisar(int codigo_Produto) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("urn:uPCPrecoIntf-PC_Preco#Pesquisar");
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("urn:uPCPrecoIntf-PC_Preco", "Pesquisar"));
setRequestHeaders(_call);
setAttachments(_call);
try {
java.lang.Object _resp = _call.invoke(new java.lang.Object[]{new java.lang.Integer(codigo_Produto)});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException) _resp;
} else {
extractAttachments(_call);
try {
return (TResultadoPreco) _resp;
} catch (java.lang.Exception _exception) {
return (TResultadoPreco) org.apache.axis.utils.JavaUtils.convert(_resp, TResultadoPreco.class);
}
}
} catch (org.apache.axis.AxisFault axisFaultException) {
throw axisFaultException;
}
}
public TResultadoPreco pesquisarPorRegiao(int codigo_Produto, int numero_Regiao) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[1]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("urn:uPCPrecoIntf-PC_Preco#PesquisarPorRegiao");
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("urn:uPCPrecoIntf-PC_Preco", "PesquisarPorRegiao"));
setRequestHeaders(_call);
setAttachments(_call);
try {
java.lang.Object _resp = _call.invoke(new java.lang.Object[]{new java.lang.Integer(codigo_Produto), new java.lang.Integer(numero_Regiao)});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException) _resp;
} else {
extractAttachments(_call);
try {
return (TResultadoPreco) _resp;
} catch (java.lang.Exception _exception) {
return (TResultadoPreco) org.apache.axis.utils.JavaUtils.convert(_resp, TResultadoPreco.class);
}
}
} catch (org.apache.axis.AxisFault axisFaultException) {
throw axisFaultException;
}
}
public TResultadoPreco pesquisarPorRegiaoPorFilial(int codigo_Produto, int numero_Regiao, java.lang.String codigo_Filial) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[2]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("urn:uPCPrecoIntf-PC_Preco#PesquisarPorRegiaoPorFilial");
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("urn:uPCPrecoIntf-PC_Preco", "PesquisarPorRegiaoPorFilial"));
setRequestHeaders(_call);
setAttachments(_call);
try {
java.lang.Object _resp = _call.invoke(new java.lang.Object[]{new java.lang.Integer(codigo_Produto), new java.lang.Integer(numero_Regiao), codigo_Filial});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException) _resp;
} else {
extractAttachments(_call);
try {
return (TResultadoPreco) _resp;
} catch (java.lang.Exception _exception) {
return (TResultadoPreco) org.apache.axis.utils.JavaUtils.convert(_resp, TResultadoPreco.class);
}
}
} catch (org.apache.axis.AxisFault axisFaultException) {
throw axisFaultException;
}
}
}
TResultadoPreco: la respuesta esperada del servicio
public class TResultadoPreco implements java.io.Serializable {
private TRequisicao statusRetorno;
private TPreco[] dados;
public TResultadoPreco() {
}
public TResultadoPreco(
TRequisicao statusRetorno,
TPreco[] dados) {
this.statusRetorno = statusRetorno;
this.dados = dados;
}
/**
* Gets the statusRetorno value for this TResultadoPreco.
*
* @return statusRetorno
*/
public TRequisicao getStatusRetorno() {
return statusRetorno;
}
/**
* Sets the statusRetorno value for this TResultadoPreco.
*
* @param statusRetorno
*/
public void setStatusRetorno(TRequisicao statusRetorno) {
this.statusRetorno = statusRetorno;
}
/**
* Gets the dados value for this TResultadoPreco.
*
* @return dados
*/
public TPreco[] getDados() {
return dados;
}
/**
* Sets the dados value for this TResultadoPreco.
*
* @param dados
*/
public void setDados(TPreco[] dados) {
this.dados = dados;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof TResultadoPreco)) return false;
TResultadoPreco other = (TResultadoPreco) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.statusRetorno==null && other.getStatusRetorno()==null) ||
(this.statusRetorno!=null &&
this.statusRetorno.equals(other.getStatusRetorno()))) &&
((this.dados==null && other.getDados()==null) ||
(this.dados!=null &&
java.util.Arrays.equals(this.dados, other.getDados())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getStatusRetorno() != null) {
_hashCode += getStatusRetorno().hashCode();
}
if (getDados() != null) {
for (int i=0;
i<java.lang.reflect.Array.getLength(getDados());
i++) {
java.lang.Object obj = java.lang.reflect.Array.get(getDados(), i);
if (obj != null &&
!obj.getClass().isArray()) {
_hashCode += obj.hashCode();
}
}
}
__hashCodeCalc = false;
return _hashCode;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(TResultadoPreco.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("urn:uResultadoPreco", "TResultadoPreco"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("statusRetorno");
elemField.setXmlName(new javax.xml.namespace.QName("", "StatusRetorno"));
elemField.setXmlType(new javax.xml.namespace.QName("urn:uRequisicao", "TRequisicao"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("dados");
elemField.setXmlName(new javax.xml.namespace.QName("", "Dados"));
elemField.setXmlType(new javax.xml.namespace.QName("urn:uPreco", "TPreco"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
Intenté implementar el cliente utilizando JAX-RPC, pero obtuve el mismo error. Intenté modificar la forma en que el cliente estaba procesando la respuesta, pero estaba recibiendo algunos otros errores. Así que abandoné el uso de terceros SOAP clientes e implementé un cliente http enviando y recibiendo los datos como String:
@Component
public class PCPrecoClient {
private final Logger log = LoggerFactory.getLogger(PCPrecoClient.class);
private final HttpHeaders defaultHeaders = new HttpHeaders();
private final RestTemplate restTemplate = new RestTemplate();
public PCPrecoClient() {
defaultHeaders.setContentType(MediaType.TEXT_XML);
defaultHeaders.set("SOAPAction","urn:uPCPrecoIntf-PC_Preco#Pesquisar");
defaultHeaders.setAcceptCharset(Collections.singletonList(Charset.forName("UTF-8")));
}
public BigDecimal pesquisar(int codigoProduto){
String requestBody="<soapenv:Envelope xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/" xmlns:soapenv=/"http://schemas.xmlsoap.org/soap/envelope//" xmlns:urn=/"urn:uPCPrecoIntf-PC_Preco/">/n" +
" <soapenv:Header/>/n" +
" <soapenv:Body>/n" +
" <urn:Pesquisar soapenv:encodingStyle=/"http://schemas.xmlsoap.org/soap/encoding//">/n" +
" <Codigo_Produto xsi:type=/"xsd:int/">"+codigoProduto+"</Codigo_Produto>/n" +
" </urn:Pesquisar>/n" +
" </soapenv:Body>/n" +
"</soapenv:Envelope>";
HttpEntity<String> httpEntity = new HttpEntity<String>(requestBody, defaultHeaders);
String finalUrl = "http://192.168.1.13/PCSIS2699.EXE/soap/PC_Preco";
try {
ResponseEntity<String> response = restTemplate.exchange(finalUrl, HttpMethod.POST, httpEntity, String.class);
return extrairPreco(response.getBody());
} catch (Exception e) {
log.error(e.getLocalizedMessage());
return null;
}
}
private BigDecimal extrairPreco(String responseBody) {
String tagAbertura="<preco_venda>";
int startIndex=responseBody.indexOf(tagAbertura)+tagAbertura.length();
int endIndex=responseBody.indexOf("</preco_venda>");
if(startIndex==-1 || endIndex==-1)
return null;
return new BigDecimal(responseBody.substring(startIndex,endIndex));
}
}
Al menos está funcionando ahora.