File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Use the simpliest web server ever Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Use the simpliest web server ever" Watch "Use the simpliest web server ever" New topic
Author

Use the simpliest web server ever

Remi Desreumaux
Greenhorn

Joined: Sep 23, 2010
Posts: 19
Well not the simpliest but very easy

I want to be able to add two integers.
Here is my wsdl : http://intevit.com/ws/ex4/WebService.wsdl

My java code starts with :


How do I define the callbackhandler?
I guess I have to do that later :
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
The callback mechanism is used for asynchronous call and depends on the SOAP stack you are using.
In case of axis2 you have to pass callback handler class as second argument while calling an operation, same as mentioned in your code. You need to implement abstract callback handler class generated by axis2 as well, to pass it as second argument.


SCJP 1.5(97%) My Blog
Remi Desreumaux
Greenhorn

Joined: Sep 23, 2010
Posts: 19
and nothing special in the inmplementation ? Just an empty class?
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
You may implement onComplete, onError method defined in abstract class, based on what you want to do on getting result/error form remote service.
Remi Desreumaux
Greenhorn

Joined: Sep 23, 2010
Posts: 19
shivendra tripathi wrote:The callback mechanism is used for asynchronous call and depends on the SOAP stack you are using.
In case of axis2 you have to pass callback handler class as second argument while calling an operation, same as mentioned in your code. You need to implement abstract callback handler class generated by axis2 as well, to pass it as second argument.


Hi, I can see an example right here of implementation of a callbackhandler, it seems complicated.
How do I can do to not use the async mod? thank you.

Here is my callbackhandletimpl :



and my client :


I still wonder how to display the result please.

this seems much more complicated than a .net client with the same webservice :


Remi Desreumaux
Greenhorn

Joined: Sep 23, 2010
Posts: 19
I read some documentation :
http://ws.apache.org/axis2/1_1_1/userguide-creatingclients.html#choosingclient

And I regenerated the stub calling :

C:\axis2-1.5.1-bin\axis2-1.5.1\bin>wsdl2java -uri http://intevit.com/ws/ex4/WebS
ervice.wsdl -p org.apache.axis2.axis2userguide -d adb -s
Using AXIS2_HOME: C:\axis2-1.5.1-bin\axis2-1.5.1
Using JAVA_HOME: C:\j\
Retrieving document at 'http://intevit.com/ws/ex4/WebService.wsdl'.
C:\axis2-1.5.1-bin\axis2-1.5.1\bin>wsdl2java -uri http://intevit.com/ws/ex4/WebS
ervice.wsdl -p org.apache.axis2.axis2userguide -d adb -s




Then in my client :


Unfortunately :

at the execution :


org.apache.axis2.AxisFault: First Element must contain the local name, Envelope , but found definitions
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:118)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.axis2userguide.Service1Stub.add(Service1Stub.java:312)
at namespace.webservice._new.Client.main(Client.java:24)
Caused by: org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found definitions
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:267)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:224)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:196)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:207)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:161)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:110)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:682)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:210)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:140)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:103)
... 7 more


thanks for help!
Remi Desreumaux
Greenhorn

Joined: Sep 23, 2010
Posts: 19
Using tcp/ip monitor , I got this as request :



This looks good but the response is the wsdl itself ! Why ?


As a reminder, my client 's code is :

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use the simpliest web server ever
 
Similar Threads
Bodgit and Scraper Transfer object
Arrays
How to invoke a WS with authentication?
Https and wsdl
[ERROR] More than one part for message AddRequest