Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 602565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:50:11+00:00 2026-05-13T16:50:11+00:00

I am programming a simple proxy in java: Read XML File Send request to

  • 0

I am programming a simple proxy in java:

  1. Read XML File
  2. Send request to Web-Service
  3. Read Web-Service response
  4. Write response to file

My first attempt is using JAXB to read the xml-file and generating Java-Objects.
Then I send the objects with JAX-WS (IBM WebSphere).
I receive the response as a “ResponseObject” which is then generated into xml code. I write the XML-Code to a file.

This setup works good. But…

When sending the java objects to the WebService, xml is generated, and the response agains creates java objects. I really would not need those request and response objects.
Is there a way to directly invoke the WebService with plaintext xml? And to read the response as plaintext xml, instead of those response objects?

(Lets assume the xml files are always valid.)

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:50:11+00:00Added an answer on May 13, 2026 at 4:50 pm

    One could use SAAJ (SOAP with Attachments API for Java) which runs at a lower level than JAX-WS. I expect it to use less system resources than JAX-WS.

    See the following example (copied from users.skynet.be/pascalbotte/rcx-ws-doc/saajpost.htm)

    No more dynamic construction of the SOAP message this time, let’s use a simple text editor and type the soap message we want to send.

    Example 1-13. The formated SOAP message in a text file: prepared.msg

    <SOAP-ENV:Envelope 
     SOAP-ENV:encodingStyle="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">
     <SOAP-ENV:Header/><SOAP-ENV:Body>
      <ans1:readLS xmlns:ans1="http://phonedirlux.homeip.net/types">
       <String_1 xsi:type="xsd:string">your message or e-mail</String_1>
      </ans1:readLS>
     </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    Now the code will be shorter and you can easily use it for testing purpose.

    Example 1-14. Post a SOAP message in a text file, to a 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 void main(String[] args) {
    
          try {
     // Create the connection
     SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
     SOAPConnection conn = scf.createConnection();
    
     // Create message
     MessageFactory mf = MessageFactory.newInstance();
     SOAPMessage msg = mf.createMessage();
    
     // Object for message parts
     SOAPPart sp = msg.getSOAPPart();
     StreamSource prepMsg = new StreamSource(
       new FileInputStream("path/prepared.msg"));
     sp.setContent(prepMsg);
    
     // Save message
     msg.saveChanges();
    
     // View input
     System.out.println("\n Soap request:\n");
     msg.writeTo(System.out);
     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
     TransformerFactory tff = TransformerFactory.newInstance();
     Transformer tf = tff.newTransformer();
    
     // Get reply content
     Source sc = rp.getSOAPPart().getContent();
    
     // Set output transformation
     StreamResult result = new StreamResult(System.out);
     tf.transform(sc, result);
     System.out.println();
    
     // Close connection
     conn.close();
    
          }
          catch (Exception e) {
     System.out.println(e.getMessage());
          }
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 313k
  • Answers 313k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer PayPal works like this: You have a form with a… May 13, 2026 at 10:45 pm
  • Editorial Team
    Editorial Team added an answer I couldn't find anyone who actually used the mobile SDK,… May 13, 2026 at 10:45 pm
  • Editorial Team
    Editorial Team added an answer To start from the end - and sorry, 20 or… May 13, 2026 at 10:45 pm

Related Questions

During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
I know what a proxy is, and the basics of how they work. What
I am programming a simple C# console application. The spec is: A game consists
I am programming a simple game in Java but I am trying to do
I am programming a small game for my school assignment, the game is a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.