• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need help with XML Parsing on SOAP

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm writing this web service client that gets me the response wrapped in a SOAP Envelope as follows:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Header>
</env:Header>
<env:Body>
<employee xmlns="http://something.someone.com">
<employee_name>Srinvias</employee_name>
<emp_no>484020</emp_no>
</employee>
</env:Body>
</env:Envelope>

The mentioned SOAP request comes in as String.

Can Someone please help me how do I 'extract' the employee xml as a string or Document?

All that I'm interested is:

<employee xmlns="http://something.someone.com">
<employee_name>Srinvias</employee_name>
<emp_no>484020</emp_no>
</employee>


Please help me... I really need this soon...


Thanks,
SriPos.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SOAP is XML - any XML parser will do. Both DOM and SAX can parse XML from a Reader. The classes that help with this are java.io.StringReader and org.xml.sax.InputSource.
 
Sri Pos
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that SOAP is xml.... I tried using the DOM method to parse the xml... how ever, what method should I use to get me the xml in the soap-body? I guess I'm lost... any help on this will really be appreciated..

- thanks.....
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if you have a DOM Document, you can use it to find the "Body" element, and then copy its first (or all) child elements.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, From <env:Body> get all child tags which are the data you need.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the XML passed as a String to my web method, then I use JAXB to unmarshall it into the appropriate Java class. If you've got a schema defined (and it appears you do), then there shouldn't be any reason to write any parser code. Just use JAXB to generate the classes from your schema and let JAXB do the work.

At least, that's what *I* do....
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sri pro...(i hope i wrote your name right)..

Sri i am working to send a soap message over an existing web service(Implemented in .NET,IIS) but i am not able to set the content type of my message..
Just help me to create my SOAP message and set its content as text/XML.

Now i am using a stringBuffer and converting it to input stream. From this stream i am creating my soap message Using SAAJ

thank you in advance.
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic