Results 1 to 4 of 4
Thread: Help with a SOAP message
- 01-13-2010, 01:43 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 5
- Rep Power
- 0
Help with a SOAP message
I have a servlet that sends a SOAP message to a web service.
Wondering if it's possible to send a byte array in a SOAP message?
This is what I originally have, but now I need to send an additional variable that's a byte array.
Thanks!Java Code://create connection SOAPConnectionFactory soapConnFact = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnFact.createConnection(); //create message MessageFactory msgFact = MessageFactory.newInstance(); SOAPMessage msg = msgFact.createMessage(); //add SOAP action to header MimeHeaders headers = msg.getMimeHeaders(); headers.addHeader("SOAPAction", "url"); //create objects for message parts SOAPPart soapPart = msg.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); //populate body and create main element and namespace SOAPElement bodyElement = body.addChildElement(envelope.createName("Name", "Name", "http://tempuri.org/")); //add content bodyElement.addChildElement("username").addTextNode(_user); bodyElement.addChildElement("password").addTextNode(_password); bodyElement.addChildElement("xmlStr").addTextNode(_xml); //save message msg.saveChanges();
- 01-13-2010, 08:11 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
What is the byte array? Is it a file? If so, send it as an attachment.
The web service itself should be looked on from the point of view of XML. If it looks like a silly thing to stick in XML (and I'd argue that a byte[] is a silly thing to stick in XML in almost every situation) then it's probably an idea to look at attachments.
- 01-13-2010, 07:29 PM #3
Member
- Join Date
- Sep 2009
- Posts
- 5
- Rep Power
- 0
Yes it is a file, but I had to put the content of the file into a byte array since that's what the web service is expecting. And I don't have any control over the web service because a vendor is actually doing that part.
But just in case, I'll search the forum on how to send it as an attachment.
Thanks!
- 01-14-2010, 08:52 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
SOAP Client
By sathish_2111 in forum Advanced JavaReplies: 2Last Post: 01-27-2010, 07:08 AM -
Sending MTOM Attachment through SOAP message
By suchismitasuchi in forum Advanced JavaReplies: 0Last Post: 01-19-2009, 01:22 PM -
Sending [CDATA] element with SOAP message
By suchismitasuchi in forum Advanced JavaReplies: 0Last Post: 01-19-2009, 10:59 AM -
Redirect Page in SOAP Message Handler
By bluesheeva in forum Advanced JavaReplies: 0Last Post: 12-28-2008, 12:43 PM -
SOAP Message Factory response error in an Applet
By Buglish in forum XMLReplies: 0Last Post: 06-30-2008, 09:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks