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.
SOAPConnectionFactory soapConnFact = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFact.createConnection();
MessageFactory msgFact = MessageFactory.newInstance();
SOAPMessage msg = msgFact.createMessage();
//add SOAP action to header
MimeHeaders headers = msg.getMimeHeaders();
//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/"));
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.
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.
It needs to be setup at both ends.
Here's the jax-ws doc, scroll down to find the section on SAAJ.