Wednesday, August 6, 2014

Java SOAP with Attachment in WebLogic

This is some code which more or less works:

import javax.xml.soap.*;

String POSTTOURL = "http://yourhost:yourport/yourservice";

MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
set the body content here
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection(); endpoint = new URL(POSTTOURL);
SOAPMessage soapResponse =, endpoint);
out.write("soapResponse=" + soapResponse.getSOAPBody().toString());

The above code without any "body content" will generate this:
<soapenv:Body xmlns:soapenv=""/>"
 attachments="<con:attachments xmlns:con=""/>"
 inbound="<con:endpoint name="BLA" xmlns:con="">
 header="<soapenv:Header xmlns:soapenv=""/>

I got this error message:
This class does not support SAAJ 1.1

Adding this in the for JAVA_OPTIONS seems to fix it:

See also document "Receive the Error "This Class Does Not Support SAAJ 1.1" when Running a P6 Web Services Application (Doc ID 1297252.1)" where they recommend:

No comments: