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 Axis2 - Print Message Text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 - Print Message Text" Watch "Axis2 - Print Message Text" New topic
Author

Axis2 - Print Message Text

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Is there an easy way to print (to String or file) an Axis2 request/response message as text?

I noticed I could get this effect if I added System.out.println(env.toString()) to the generated stub after the SOAPEnvelope's been created. Is there a simple command to get the same effect without modifying the generated code? I tried add toString() to the input message, but I just got the object reference information instead of the message contents.
[ May 02, 2008: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41106
    
  45
Do you have access to the SOAPMessage object? It has a writeTo(Stream) method for this.


Ping & DNS - my free Android networking tools app
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

I don't think so. I've constructed a request object for my WebService which implements "org.apache.axis2.databinding.ADBBean". From there I seem only be able to pass it to the web service. It isn't clear to me how to convert it to a Soap Message outside the stub class.
[ May 02, 2008: Message edited by: Scott Selikoff ]
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
For debugging purposes Axis 2 SOAP Monitor, Apache TCPMon(Tutorial), or java.net tcpmon) may be more effective.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Well the thing is I don't want to actually send the message. The service I'm working with involves validating WSDL-generated messages for a yet-to-be-implemented web service. In other words, there's no transmission to monitor. I just need to be able to generate valid sample messages.
[ May 02, 2008: Message edited by: Scott Selikoff ]
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Scott Selikoff:
The service I'm working with involves validating WSDL-generated messages for a yet-to-be-implemented web service. In other words, there's no transmission to monitor. I just need to be able to generate valid sample messages.


If this was my project I would feel much better if I had a faux version of that web service handy for testing ...
I presume that you won't be validating anything once it goes live - that would require a Handler in the handler chain.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Not really, I'm not in the group implementing the Web Service. Besides, I need to be able to generate sample response messages too, and for this I copy&paste request methods and modify them for the response input message. In no case do I send a message.

I just want to be able to generate sample messages that are validated against the WSDL-generated spec. It seems like the only way to do this is to hijack the generated code to output the envelope after its been created. Not really an elegant solution though, no one has anything better?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Scott Selikoff:
Not really, I'm not in the group implementing the Web Service.


Nobody is talking about the fullblown web service. Simply one that accepts the message (possibly logs it, if desired) and then shoots out a canned/scripted response.

I just want to be able to generate sample messages that are validated against the WSDL-generated spec.


Aren't you using WSDL-to-Java code generation? In that case you are simply validating the code generator. If the generated messages are off then you may have to "adjust" the source WSDL to get the "right" SOAP requests and responses.

Not really an elegant solution though, no one has anything better?


The root of your grievance is in how the WSDL/SOAP specification affects the design of web service (and client) frameworks. The Java method responsible for web service invocation only generally covers what goes into the body of the SOAP envelope. SOAP headers are typically added and processed by the handlers on both the consumer and provider side and those handlers can be configured at deployment time. The WSDL spec covers the entire SOAP envelope, i.e. headers and body. So the only way you can test the client is by testing both the code and the deployment - so a dummy web service is still your best option.

The alternative is that you give up on code generation and implement everything manually, envelope, body and headers with something like SAAJ - in that case you have access to the final SOAP message.

Seems to me implementating a dummy web service is less work ...
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

I just want a way to generate sample messages for a proposed WSDL file, one whose details are still being fleshed out. Axis2 provides me a way to generate the messages, but only if I hijack the files. This isn't about code implementation, its about planning, and Axis2 seems limited in this capacity.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Scott Selikoff:
This isn't about code implementation, its about planning, and Axis2 seems limited in this capacity.


Maybe - but you are using a code generation tool so in the end it is about code. Can you get a preview of the binary message that is prepared by an SLSB client stub?

As you can see the SOAP request isn't actually realized until the MessageContext hits the "Transport Sender" (Axis 2.0 Architecture guide: SOAP Processing Model). Until that point any pertinent information is scattered over different parts of the MessageContext. Furthermore a client stub would only have the logic to unmarshal any provider responses - it wouldn't contain the logic to marshal, i.e. create, the SOAP responses that it expects.

So with a pre-existing WSDL have WSDL2Java generate both the client stub and the server side skeleton (-ss) and then perform a tracer bullet/spike to get the information your want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis2 - Print Message Text
 
Similar Threads
Axis2 plugin
Axis Vs Axis2
Axis2 ParseError
Printing a text file on remote IP
Axis 2 tutorial - client class compliation error