Hello there,
I'm trying to to use jax-ws on the client side to access a webservice with soap::lite on the server side. Manually (also with Pod::WSDL) I created the appropriate WSDL for this service, which is successfully tested on perl.
I took this webservice as sample for test, which is found on http://guide.soaplite.com/#passing%20values. The soap address is at http://services.soaplite.com/temper.cgi. The content of generated WSDL looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!-- WSDL for http://services.soaplite.com/temper.cgi created by Pod::WSDL version: 0.05 on Wed Aug 8 10:33:43 2007 -->
<wsdl:definitions targetNamespace="http://services.soaplite.com/Temperatures"
xmlns:impl="http://services.soaplite.com/Temperatures"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns1="http://services.soaplite.com/Temperatures">
<wsdl:message name="c2fRequest">
<wsdl:part name="celcius" type="xsd:float" />
</wsdl:message>
<wsdl:message name="c2fResponse">
<wsdl:part name="c2fReturn" type="xsd:float" />
</wsdl:message>
<wsdl:portType name="TemperaturesHandler">
<wsdl:operation name="c2f">
<wsdl:documentation>Convert from celcius to fahrenheit</wsdl:documentation>
<wsdl:input message="impl:c2fRequest" name="c2fRequest" />
<wsdl:output message="impl:c2fResponse" name="c2fResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TemperaturesSoapBinding" type="impl:TemperaturesHandler">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="c2f">
<wsdlsoap:operation soapAction="temper.cgi#c2f" />
<wsdl:input name="c2fRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://services.soaplite.com/Temperatures" use="encoded" />
</wsdl:input>
<wsdl:output name="c2fResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://services.soaplite.com/Temperatures" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TemperaturesHandlerService">
<wsdl:port binding="impl:TemperaturesSoapBinding" name="Temperatures">
<wsdlsoap:address location="http://services.soaplite.com/temper.cgi" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Now I try to use this WSDL on my java application using jax-ws on my netbeans 5.5 (+java 1.5). By importing it, I find several Problems:
1.
rpc/encoded wsdls are not supported in JAXWS 2.0, so I changed the style as document/encoded.
2.
Invalid wsdl:operation "c2f": its a document-literal operation, message part must refer to a schema element declaration. This time I defined a schema element for input/output data type.
<wsdl:types>
<xsd:schema targetNamespace="http://services.soaplite.com/Temperatures">
<xsd:element name="testing" type="xsd:float"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="c2f*">
<wsdl:part name="celcius" element="tns1:testing" />
</wsdl:message>
The WSDL was imported without any error messages. Then I use this codes to implement a client.
try { // Call Web Service Operation
src.TemperaturesHandlerService service = new src.TemperaturesHandlerService();
src.TemperaturesHandler port = service.getTemperatures();
// TODO initialize WS operation arguments here
float celcius = Float.parseFloat("37.5");
// TODO process result here
float result = port.c2F(celcius);
System.out.println("Result = "+result);
} catch (Exception ex) {
ex.printStackTrace();
}
3.
Failed to locate method (testing) in class (Temperatures) at /home/soaplite/lib/SOAP/Lite.pm line 2195.. I defined
testing not as a method, but as a data type element. How could it be recognized as a method?
Can anyone help me? Thanks