Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
XML and Related Technologies
How to parse SOAP Xml using java code ?
Prabhat Ranjan
Ranch Hand
Posts: 397
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am able to prase normal xml using
java
.
but
SOAP
XML , i am not able to parse.
Please nay one help me out how to do it in java.
My SOAP XMl is strating with the tag:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
java code for parsing:
public class parseXml { public static void main(String args[]) throws IOException, XmlException { String fileRequestInput = "REQUEST_MCI_UC_41.xml"; File xmlFileRequest = new File(fileRequestInput); File file = new File(fileRequestInput); FileInputStream fstreamRequest = new FileInputStream(xmlFileRequest); DoProcessRequestDocument doProcessRequestDoc = null; try { doProcessRequestDoc = DoProcessRequestDocument.Factory .parse(fstreamRequest); } catch (XmlException e) { e.printStackTrace(); } Writer output = null; output = new BufferedWriter(new FileWriter(file)); output.write(doProcessRequestDoc.toString()); System.out.println("Request xml generated Parsed succesffully " + fileRequestInput); output.close(); } }
Saurabh Joshi
Ranch Hand
Posts: 37
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Prabhat,
Try this,
DocumentBuilderFactory docFactory = null; DocumentBuilder docBuilder = null; Document document = null; try { docFactory = DocumentBuilderFactory.newInstance(); docBuilder = docFactory.newDocumentBuilder(); document = docBuilder.parse(FilePath); . . .
this works for my SOAP message.
Hope it helps.
Prabhat Ranjan
Ranch Hand
Posts: 397
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks yaar its working fine for me.
import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.xmlbeans.XmlException; import org.w3c.dom.Document; public class parseXml { public static void main(String args[]) throws IOException, XmlException { String fileRequestInput = "D:/ParseXml/REQUEST_MCI_UC_41.xml"; File xmlFileRequest = new File(fileRequestInput); File file = new File(fileRequestInput); FileInputStream fstreamRequest = new FileInputStream(xmlFileRequest); DocumentBuilderFactory docFactory = null; DocumentBuilder docBuilder = null; Document document = null; try { docFactory = DocumentBuilderFactory.newInstance(); docBuilder = docFactory.newDocumentBuilder(); document = docBuilder.parse(fstreamRequest); } catch(Exception e){ } System.out.println("Request xml generated Parsed succesffully "); } }
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
writing data to CSV file
resolving external DTD
Problem reading a file
How do I make the image Display on my PDf Document
Uploading xls files with JSF
More...