Prezados,
Bom dia. Sou novo por aqui e também em java, mas a necessidade me fez escolher java. Não que não goste de java, mas que estava evitando até os dias atuais.
Estou desenvolvendo um sistema em Tomcat + Axis2 e minha dúvida encontra-se na hora de fazer um return. Preciso ver no xml de retorno o resultado ao invés de tag uma tag customizada, tipo . Para que me ajudem, segue meus códigos:
WSDL:
<wsdl:definitions targetNamespace=“SPG/SoapServer”
xmlns:wsdl=“<a href="http://schemas.xmlsoap.org/wsdl/">http://schemas.xmlsoap.org/wsdl/</a>”
xmlns:soapenc=“<a href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</a>”
xmlns:http=“<a href="http://schemas.xmlsoap.org/wsdl/http/">http://schemas.xmlsoap.org/wsdl/http/</a>”
xmlns:s=“<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>”
xmlns:soap=“<a href="http://schemas.xmlsoap.org/wsdl/soap/">http://schemas.xmlsoap.org/wsdl/soap/</a>”
xmlns:mime=“<a href="http://schemas.xmlsoap.org/wsdl/mime/">http://schemas.xmlsoap.org/wsdl/mime/</a>”
xmlns:soap12=“<a href="http://schemas.xmlsoap.org/wsdl/soap12/">http://schemas.xmlsoap.org/wsdl/soap12/</a>”
xmlns:tns=“SPG/SoapServer”>
<a>wsdl:types</a>
<s:schema elementFormDefault=“qualified” targetNamespace=“SPG/SoapServer”>
<s:element name=“Calc”>
<s:complexType>
<s:sequence>
<s:element minOccurs=“0” name=“var1” type=“s:int”/>
<s:element minOccurs=“0” name=“var2” type=“s:int”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“CalcResponse”>
<s:complexType>
<s:sequence>
<s:element minOccurs=“0” name=“return” type=“s:int”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“processResponse”>
<s:complexType>
<s:sequence>
<s:element minOccurs=“1” maxOccurs=“1” name=“header” nillable=“true” type=“s:string”/>
<s:element minOccurs=“1” maxOccurs=“1” name=“xmlMessage” nillable=“true” type=“s:string”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“processResponseResponse”>
<s:complexType>
<s:sequence>
<s:element minOccurs=“1” maxOccurs=“1” name=“processResponseResult” type=“s:anyType”/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name=“processResponseSoapIn”>
<wsdl:part name=“parameters” element=“tns:processResponse”/>
</wsdl:message>
<wsdl:message name=“processResponseSoapOut”>
<wsdl:part name=“parameters” element=“tns:processResponseResponse”/>
</wsdl:message>
<wsdl:message name=“CalcSoapIn”>
<wsdl:part name=“parameters” element=“tns:Calc”/>
</wsdl:message>
<wsdl:message name=“CalcSoapOut”>
<wsdl:part name=“parameters” element=“tns:CalcResponse”/>
</wsdl:message>
<wsdl:portType name=“SOABDOServiceSoap”>
<wsdl:operation name=“processResponse”>
<wsdl:input message=“tns:processResponseSoapIn”/>
<wsdl:output message=“tns:processResponseSoapOut”/>
</wsdl:operation>
<wsdl:operation name=“Calc”>
<wsdl:input message=“tns:CalcSoapIn”/>
<wsdl:output message=“tns:CalcSoapOut”/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=“SOABDOServiceSOAP11Binding” type=“tns:SOABDOServiceSoap”>
<soap:binding transport=“<a href="http://schemas.xmlsoap.org/soap/http">http://schemas.xmlsoap.org/soap/http</a>” style=“document”/>
<wsdl:operation name=“processResponse”>
<soap:operation soapAction=“SPG/SoapServer/processResponse” style=“document”/>
<a>wsdl:input</a>
<soap:body use=“literal”/>
</wsdl:input>
<a>wsdl:output</a>
<soap:body use=“literal”/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name=“Calc”>
<soap:operation soapAction=“SPG/SoapServer/Calc” style=“document”/>
<a>wsdl:input</a>
<soap:body use=“literal”/>
</wsdl:input>
<a>wsdl:output</a>
<soap:body use=“literal”/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name=“SOABDOServiceSOAP12Binding” type=“tns:SOABDOServiceSoap”>
<soap12:binding transport=“<a href="http://schemas.xmlsoap.org/soap/http">http://schemas.xmlsoap.org/soap/http</a>” style=“document”/>
<wsdl:operation name=“processResponse”>
<soap12:operation soapAction=“SPG/SoapServer/processResponse” style=“document”/>
<a>wsdl:input</a>
<soap12:body use=“literal”/>
</wsdl:input>
<a>wsdl:output</a>
<soap12:body use=“literal”/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name=“Calc”>
<soap12:operation soapAction=“SPG/SoapServer/Calc” style=“document”/>
<a>wsdl:input</a>
<soap12:body use=“literal”/>
</wsdl:input>
<a>wsdl:output</a>
<soap12:body use=“literal”/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name=“SOABDOServiceHttpBinding” type=“tns:SOABDOServiceSoap”>
<wsdl:operation name=“processResponse”>
<http:operation location=“SOABDOService/processResponse”/>
<a>wsdl:input</a>
<mime:content type=“text/xml” part=“processResponse”/>
</wsdl:input>
<a>wsdl:output</a>
<mime:content type=“text/xml” part=“processResponse”/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name=“Calc”>
<http:operation location=“SOABDOService/Calc”/>
<a>wsdl:input</a>
<mime:content type=“text/xml” part=“Calc”/>
</wsdl:input>
<a>wsdl:output</a>
<mime:content type=“text/xml” part=“Calc”/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=“SOABDOService”>
<wsdl:port name=“SOABDOServiceSOAP11port_http” binding=“tns:SOABDOServiceSOAP11Binding”>
<soap:address location=“<a href="http://localhost:8080/axis2/services/SOABDOService">http://localhost:8080/axis2/services/SOABDOService</a>”/>
</wsdl:port>
<wsdl:port name=“SOABDOServiceSOAP12port_http” binding=“tns:SOABDOServiceSOAP12Binding”>
<soap12:address location=“<a href="http://localhost:8080/axis2/services/SOABDOService">http://localhost:8080/axis2/services/SOABDOService</a>”/>
</wsdl:port>
<wsdl:port name=“SOABDOServiceHttpport” binding=“tns:SOABDOServiceHttpBinding”>
<http:address location=“<a href="http://localhost:8080/axis2/services/SOABDOService">http://localhost:8080/axis2/services/SOABDOService</a>”/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Classe com objeto de retorno:
package soapserver.spg;
public class ResultCodes {
public int idCod;
public ResultCodes() {
}
public ResultCodes(int id){
this.idCod = id;
System.out.println(this.idCod);
}
}
Webservices:
package soapserver.spg;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public class ProcessResponse {
@WebMethod(operationName =“processResponse”)
public ResultCodes processResponse(@WebParam(name=“header”) String header,
@WebParam(name=“xmlMessage”) String xmlMessage){
ResultCodes processResponseResult = new ResultCodes(0);
return processResponseResult;
}
public int Calc(int var1, int var2){
int result=0;
result = var1 + var2;
return result;
}
}
Estou chamando o método processResponse e o xml de retorno é o seguinte:
<ns:processResponseResponse xmlns:ns=“SPG/SoapServer”>
<ns:return />
</ns:processResponseResponse>
Desde já, agradeço a ajuda de todos.
Atenciosamente,
Rodrigo R Passos