java - Webservice-Client: Use plain-text xml instead of object hierarchy -


I am programming a simple proxy in Java:

  1. Read the XML file

  2. Send a request for web service
  3. Read web service feedback
  4. Write a response to the file

My first attempt is to use JAXB Read XML-file and generate Java-objects then I send objects with Jacques-WS (IBM WebSpace). I got a response in the form of "ResponseObject" which was then generated in the XML code, I write the XML-code in a file

This setup works well but ...

When sending Java objects to the website, the XML is generated, and the response again creates the Java object. I do not really need those requests and feedback items. Is there any way to straighten the website with SideText XML? And to read responses in the form of sandbox XML instead of reactive objects?

(XML files always accept valid.)

thanks

One Java) which runs at lower levels compared to JADS-WS. I hope this is to use less system resources than JAX-WS

See the following example (copied)

At this time more of SOAP message Do not have dynamic build, use a simple text editor and we want to send soap message to send.

Example 1-13 The SOAP message created in a text file: ready.msg

  & lt; SOAP-ENV: Envelope SOAP-ENV: Encoding Style = "http://schemas.xmlsoap.org/ Soap / Encoding / XMLNS: SOAP-ENV =" http://schemas.xmlsoap.org/soap/envelope/ " Xmlns: enc = "http://schemas.xmlsoap.org/soap/encoding/" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns: xsi = "http: // www. W3.org/2001/XMLSchema-instance "& gt; & Lt; Soap-ENV: Header / & gt; & Lt; Soap-ENV: Body & gt; & Lt; Ans1: readLS xmlns: ans1 = "http://phonedirlux.homeip.net/types" & gt; & Lt; String_1 xsi: type = "xsd: string" & gt; Your message or e-mail & lt; / String_1 & gt; & Lt; / Ans1: readLS & gt; & Lt; / SOAP-ENV: Body & gt; & Lt; / SOAP-ENV: envelope & gt;  

Now the code will be small and you can easily use it for testing purposes.

Example 1-14 Post a SOAP message to a text file for web service using SAAJ

  import javax.xml.soap.SOAPConnectionFactory ; Import javax.xml.soap.SOAPConnection; Import javax.xml.soap.MessageFactory; Import javax.xml.soap.SOAPMessage; Import javax.xml.soap.SOAPPart; Import java.io.FileInputStream; Import javax.xml.transform.stream.StreamSource; Import javax.xml.transform.TransformerFactory; Import javax.xml.transform.Transformer; Import javax.xml.transform.Source; Import javax.xml.transform.stream.StreamResult; Public class client {public static zero main (string [] args) {try {// connection SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance (); SOAPConnection conn = scf.createConnection (); // Create message message FFMf = MessageFactory.newInstance (); SOAPMessage msg = mf.createMessage (); // part for the message body SOAPPart sp = msg.getSOAPPart (); Streamers premong = new streamsource (new file inputstream ("Path / Ready. MSG")); Sp.setContent (prepMsg); // Save Message msg.saveChanges (); // View Input System.out.println ("\ n soap request: \ n"); Msg.writeTo (System.out); Println (); // send string urlval = "http://www.pascalbotte.be/rcx-ws/rcx"; SOAPMessage rp = conn.call (msg, urlval); // View the output system. Out.println ("\ nXML response \ n"); // Create Transformer Transformer. Ftftf = transformerfacture.Newinstance (); Transformer TF = TFF NEU Transformers (); // Answer Get content source sc = rp.getSOAPPart (). GetContent (); // Set output conversion streamer result result = new stream result (system.out); Tf.transform (sc, result); Println (); // conn.close off connection (); } Hold (exception e) {System.out.println (e.getMessage ()); }}}  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -