?
Solved

Java/Web Services Question Convert SOAP response to String

Posted on 2011-02-11
5
Medium Priority
?
1,359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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