Basically what I'm trying to do is to create a simple Web Service that will receive a String and retun the same string, i.e. basically an "echo" web service. I tried using the sample on the Axis2 documentation page with OMElement - it works fine.
My problem is that I want to use String instead of OMElement on both sides (server as well as client). Apparently, I cant do this unless I use the RPC
So what I have is a services.xml that looks like this:
A MyService2.java that looks like this:
public class MyService2 {
public String echo(String echostring) {
return echostring;
}
}
I can deploy this using axis2.war on JBoss. It deploys fine, and I get the following WSDL:
<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:axis2="http://ws.apache.org/axis2"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http:///xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:ns1="http://org.apache.axis2/xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://ws.apache.org/axis2"><wsdl:types><xs:schema
xmlns:stn_3="http:///xsd" targetNamespace="http:///xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:element name="echo">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="param0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="echoResponse">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="return" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema></wsdl:types>
<wsdl:message name="echoMessage"><wsdl:part element="ns0:echo" name="part1" /></wsdl:message><wsdl:message name="echoResponse"><wsdl:part element="ns0:echoResponse" name="part1" /></wsdl:message><wsdl:portType name="MyService2PortType"><wsdl:operation name="echo"><wsdl:input message="axis2:echoMessage" /><wsdl:output message="axis2:echoResponse" /></wsdl:operation></wsdl:portType><wsdl:binding type="axis2:MyService2PortType" name="MyService2SOAP11Binding"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /><wsdl:operation name="echo"><soap:operation style="document" soapAction="urn:echo" /><wsdl:input><soap:body use="literal" /></wsdl:input><wsdl:output><soap:body use="literal" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding type="axis2:MyService2PortType" name="MyService2SOAP12Binding"><soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /><wsdl:operation name="echo"><soap12:operation style="document" soapAction="urn:echo" /><wsdl:input><soap12:body use="literal" /></wsdl:input><wsdl:output><soap12:body use="literal" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding type="axis2:MyService2PortType" name="MyService2HttpBinding"><http:binding verb="POST" /><wsdl:operation name="echo"><http:operation location="echo" /><wsdl:input><mime:content type="text/xml" /></wsdl:input><wsdl:output><mime:content type="text/xml" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="MyService2"><wsdl:port binding="axis2:MyService2SOAP11Binding" name="MyService2SOAP11port_http"><soap:address location="http://localhost:8080/axis2/services/MyService2" /></wsdl:port><wsdl:port binding="axis2:MyService2SOAP12Binding" name="MyService2SOAP12port_http"><soap12:address location="http://localhost:8080/axis2/services/MyService2" /></wsdl:port><wsdl:port binding="axis2:MyService2HttpBinding" name="MyService2Httpport0"><http:address location="http://localhost:8080/axis2/rest/MyService2" /></wsdl:port></wsdl:service></wsdl:definitions>
I then try to use WSDL2Java to create client stubs based on this WSDL. It does generate them, but when I try to run the client I get the following error:
Exception in thread "main" java.lang.RuntimeException:
java.lang.RuntimeException: Unexpected subelement return
at org.apache.axis2.MyService2Stub.fromOM(MyService2Stub.java:665)
at org.apache.axis2.MyService2Stub.echo(MyService2Stub.java:144)
at org.apache.axis2.Client.main(Client.java:16)
Caused by: java.lang.RuntimeException: Unexpected subelement return
at
org.apache.axis2.MyService2Stub$EchoResponse$Factory.parse (MyService2Stub.java:419)
at org.apache.axis2.MyService2Stub.fromOM(MyService2Stub.java:657)
... 2 more
I googled this and this page (
http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/[EMAIL PROTECTED]) claims
that this error message appears because axis2 does not support RPC Bindings.
I'm confused - how do I generate a client for this WSDL?