On Thu, Jan 7, 2010 at 7:25 AM, Pascal Kesseli <pascal_kess...@hotmail.com>wrote:
> Hi everyone > > Just a second ago, I tried creating a client interface using Axis2 and the > following WSDL: > > <?xml version="1.0" encoding="UTF-8"?> > <wsdl:definitions name="emc-remote" > targetNamespace="http://www.example.org/emc-remote/" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:emc="http://www.example.org/emc-remote/" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> > <wsdl:types> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > targetNamespace="http://www.example.org/emc-remote/"> > <xsd:complexType name="MeterType"> > <xsd:sequence> > <xsd:element name="id" > type="xsd:int" /> > <xsd:element name="name" > type="xsd:string" /> > </xsd:sequence> > </xsd:complexType> > <xsd:complexType name="Meter"> > <xsd:sequence> > <xsd:element name="id" > type="xsd:int" /> > <xsd:element name="name" > type="xsd:string" /> > <xsd:element name="address" > type="xsd:string" /> > <xsd:element name="meterType" > type="emc:MeterType" /> > </xsd:sequence> > </xsd:complexType> > <xsd:complexType name="MeteringPoint"> > <xsd:sequence> > <xsd:element name="id" > type="xsd:int" /> > <xsd:element name="name" > type="xsd:string" /> > <xsd:element > name="multiplicatorFactor" type="xsd:double" /> > <xsd:element name="meters" > type="emc:Meter" minOccurs="0" > maxOccurs="unbounded" /> > </xsd:sequence> > </xsd:complexType> > <xsd:element name="sayHelloRequest" > type="xsd:string" /> > <xsd:element name="sayHelloResponse" > type="xsd:string" /> > <xsd:element name="getMeteringPointsResponse"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="item" > type="emc:MeteringPoint" > minOccurs="0" > maxOccurs="unbounded" /> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:schema> > </wsdl:types> > <wsdl:message name="sayHelloRequest"> > <wsdl:part name="name" element="emc:sayHelloRequest" /> > </wsdl:message> > <wsdl:message name="sayHelloResponse"> > <wsdl:part name="message" element="emc:sayHelloResponse" /> > </wsdl:message> > <wsdl:message name="getMeteringPointsRequest" /> > <wsdl:message name="getMeteringPointsResponse"> > <wsdl:part name="metering_points" > element="emc:getMeteringPointsResponse" /> > </wsdl:message> > <wsdl:portType name="remote"> > <wsdl:operation name="sayHello"> > <wsdl:input message="emc:sayHelloRequest" /> > <wsdl:output message="emc:sayHelloResponse" /> > </wsdl:operation> > <wsdl:operation name="getMeteringPoints"> > <wsdl:input message="emc:getMeteringPointsRequest" > /> > <wsdl:output message="emc:getMeteringPointsResponse" > /> > </wsdl:operation> > </wsdl:portType> > <wsdl:binding name="remote" type="emc:remote"> > <soap:binding style="document" > transport="http://schemas.xmlsoap.org/soap/http" /> > <wsdl:operation name="getMeteringPoints"> > <soap:operation > soapAction="http://www.example.org/emc-remote/getMeteringPoints" /> > <wsdl:input> > <soap:body use="literal" /> > </wsdl:input> > <wsdl:output> > <soap:body use="literal" /> > </wsdl:output> > </wsdl:operation> > <wsdl:operation name="sayHello"> > <soap:operation > soapAction="http://www.example.org/emc-remote/sayHello" /> > <wsdl:input> > <soap:body use="literal" /> > </wsdl:input> > <wsdl:output> > <soap:body use="literal" /> > </wsdl:output> > </wsdl:operation> > </wsdl:binding> > <wsdl:service name="emc-remote"> > <wsdl:port name="port" binding="emc:remote"> > <soap:address > location="http://localhost/emc-remote.exe" /> > </wsdl:port> > </wsdl:service> > </wsdl:definitions> > > > The important part represents the getMeteringPointsRequest, as it does not > take any arguments. Consequently, I would expect Axis2 to generate a class > GetMeteringPointsRequest without any constructor arguments. Unfortunately, > it turns out that Axis does not generate any such class and the stub method > does not take any parameters at all, so I can use the generated interface > like this: > > EmcRemoteStub server = new EmcRemoteStub(); > SayHelloRequest sayHelloRequest = new SayHelloRequest(); > sayHelloRequest.setSayHelloRequest("Tom"); > > System.out.println(server.sayHello(sayHelloRequest).getSayHelloResponse()); > System.out.println(server.getMeteringPoints()); // Very > convenient, but probably wrong... > > While I would find that extraordinarily convenient, I just don't think > that's how Axis works. The following exception thrown when I try to execute > the above code assures me on this suspicion: > > Hello Tom! > org.apache.axis2.AxisFault: No XML element tag > at > > org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:435 > ) > at > > org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAx > isOperation.java:371) > I can't see any problem with what you do. use tcpmon[1] to check the request and response. thanks, Amila. [1] http://ws.apache.org/commons/tcpmon/ > at > > org.apache.axis2.desycription.OutInAxisOperationClient.send(OutInAxisOperatio > n.java:417) > at > > org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisO > peration.java:229) > at > org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) > at > > org.example.www.emc_remote.EmcRemoteStub.getMeteringPoints(EmcRemoteStub.jav > a:309) > at org.example.Runner.main(Runner.java:13) > > My question to you would thus be: How to correctly implement a web service > without any input parameters? And, of course, how to describe such a > service > in WSDL? > > Thanks for any help on this issue and best regards > Pascal Kesseli > > > -- Amila Suriarachchi WSO2 Inc. blog: http://amilachinthaka.blogspot.com/