• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Axis2 - Print Message Text

 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have access to the SOAPMessage object? It has a writeTo(Stream) method for this.
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For debugging purposes Axis 2 SOAP Monitor, Apache TCPMon(Tutorial), or java.net tcpmon) may be more effective.
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic