This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Services and the fly likes Convert String into SOAP envelope object. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Web Services
Bookmark "Convert String into SOAP envelope object." Watch "Convert String into SOAP envelope object." New topic

Convert String into SOAP envelope object.

Dave Ersk

Joined: Dec 28, 2002
Posts: 6
Hi - How do you convert a String object into a soap envelope with
org.apache.soap.*; ??

Receive soap message =
Envelope env = msg.receiveEnvelope();
Body retbody = env.getBody();
java.util.Vector v = retbody.getBodyEntries();

The avbove code works great when I receivce the envelope over http, but I'm trying to build a developemnt tool that can use a hard coded String like the below to test/develop with. Having a hard time getting into proper object type. Please advise??

String soapText =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<soap:Envelope "
+ "xmlns:soap=\"\">"
+ "<soap:Body>"
+ "<TpclCommareaMethodResponse "
+ "xmlns=\"$ZL#D001\">"
+ "FULL-DATE-OUT=\"10/08/2007\" "
+ "FULL-TIME-OUT=\"10:32:22\" "
+ "EIBTASKN-NBR-OUT=\"0004516\" "
+ " /> "
+ "</TpclCommareaMethodResponse>"
+ "</soap:Body>"
+ "</soap:Envelope>";

Best Regards,<br />Dave Ersk<br />SCJP 1.4
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13001
Glancing at the Axis 1.4 JavaDocs for Message, it appears that there is a set of constructors that take an "initialConents Object" where:

initialContents - may be String, byte[], InputStream, SOAPEnvelope, or AxisFault.

Therefore you should be able to get that Message directly constructed from the String instead of the InputStream.

Dave Ersk

Joined: Dec 28, 2002
Posts: 6
Thanks a lot Bill !

I'll convert from org.apache.soap to org.apache.axis and give it a whirl.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Convert String into SOAP envelope object.
It's not a secret anymore!