Solved

Java/Web Services Question Convert SOAP response to String

Posted on 2011-02-11
5
1,201 Views
Last Modified: 2012-05-11
Here is what I am looking to do. I have some java code that calls a web service. I know the response, at some point, is a SOAP message. Is there some way to extract this soap message as a string. Something like

WebServiceResponse res  = ws.getWebServiceInfo()
String targetString = res.SOAPString()

Where targetString would be a string containing the SOAP message.

Thanks in advance for the help,
Matt




0
Comment
Question by:mattjankowski
  • 3
5 Comments
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 34877242
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34883632

Well, if above links work for you, then it is fine, though it does not look
that they give all the eaxct instructions.

Below is the inforamtion about what seems to be much more painful way to do it
using mule. It looks like it is a big deal, but
there seem to be enough instructions.
Don't know maybe someone would suggest a much simpler solution.
If not, maybe it is worth playing with mule, if there is a real need to do it.

It looks like this mule software could help you with this.

This is where you get the library - click on .jars to download - it
is only about  4 MB
http://www.mulesoft.org/download-mule-esb-community-edition

And this is the post which describes it more or less
and points to particular code example:
(from http://mule.1045714.n5.nabble.com/Extracting-a-SOAP-Body-from-a-FILE-td2678533.html)

-------------------------
In reply to this post by tha
Hey Thomas,

This might help you out:

http://www.mulesource.org/display/SAAJ/Home

It provides a pair of transformers to extract the contents of and populate SOAP messages.  I'm still working on putting a proper release together, but  you should be able to checkout trunk from here:

http://svn.muleforge.org/saaj/trunk/

and use "mvn clean package" to get a JAR file to drop in $MULE_HOME/lib/user.

I added an example that illustrates how to extract the payload from SOAP messages in a directory here:

http://www.mulesource.org/display/SAAJ/Extracting+XML+from+SOAP+Messages

This will pull the SOAP headers out of your messages, set them as message properties and set the message payload as the SOAP body's XML.

I hope to have the release ready in the next few days..

Cheers,
-jd
---------------------------------




0
 

Author Comment

by:mattjankowski
ID: 34888387
Ok,

Specific instructions are always better, but I am looking into both of the previous posts as possible solutions. Hopefully I can get back to EE later today with which one works out the easiest.

Thanks,
Matt
0
 

Accepted Solution

by:
mattjankowski earned 0 total points
ID: 34897861
A colleague pointed out this solution to me:

System.out.println(res.getOMElement(null,null).toString());

The entire soap message is not printed out, but all the elements and their associated tags are.  
0
 

Author Closing Comment

by:mattjankowski
ID: 34936410
Thank you both for your help with the comments. The solution wound up to be the cleanest and easiest way to do it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 98
topping1 challenge 7 72
for i loop in grovy 1 44
Java SE 8u111  Lot of stuff broke 11 53
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now