troubleshooting Question

Create xml element /soap message with an input stream memory question

Avatar of ICPooreman
ICPooreman asked on
Java
1 Comment1 Solution730 ViewsLast Modified:
So I'm trying to create a soapMessage and the data I'm adding to the message could get very large.  However as far as I can tell I can only add the data as a string when constructing the object when I'd like to use some type of inputstream to read it from a file or something and avoid using strings if possible.

I've read that I can create the soap message from the inputstream like so if my inputstream is a valid soap message however I want to build my message dynamically to include my data is there a way to do this without using file IO?
 // compose a request message
        MessageFactory mf = MessageFactory
                .newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
       
        // Create a message. This example works with the SOAPPART.
        SOAPMessage request = mf.createMessage(null,inputstream);

// compose a request message
        MessageFactory mf = MessageFactory
                .newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        
        // Create a message. This example works with the SOAPPART.
        SOAPMessage request = mf.createMessage();
        SOAPPart part = request.getSOAPPart();
      
        // Obtain the SOAPEnvelope and header and body elements.
        SOAPEnvelope env = part.getEnvelope();
        SOAPBody body = env.getBody();
 
        // Construct the message payload.
        SOAPElement operation = body.addChildElement("something", "something",
                "something");
        SOAPElement value = operation.addChildElement("data");
        value.addTextNode(data);
//the data I have is currently a string I want to be able to add data to a soapmessage as an inputStream or something of the sort for memory reasons
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros