Skip to Main Content

How to add a Soap header to a Java client using MTOM messages

John23Apr 17 2013 — edited Apr 30 2013
Hi, I am using WebLogic 11g and have a web service that uploads attachment using MTOM. The service can be invoked via SoapUI successfully. I also need to call the service via a Java client, and that also works without any issues. To do that, I use the auto-generated classes by JAXWS and generate and send a message like below:
FileService service = new FileService(new URL(FileEndpoint), new QName("", "FileService"));
MTOMFeature features = new MTOMFeature();
FileServicePortType port = service.getFileServicePort(features);
Map<String, Object> ctxt=((BindingProvider)port).getRequestContext();
//Create request
UploadFileWithAttachmentRequest request = new UploadFileWithAttachmentRequest();
//Instantiate and add all required objects including the binary file to the request
FileXMLType fileXml = port.uploadFileWithAttachment(request);
Now, the above code generates the required Soap message and uploads the file successfully. However, I also need to create a Soap header and add it to the Soap message to send over some metadata that the service requires. Before using MTOM, I used SAAJ in my client and I could construct the Soap header and add it to the envelope without any issue. However, With the provided JAXWS classes at above, I can only send a message Body and there is no object to attach the Soap header to. So I need to know how I can send Soap Headers with MTOM messages in a Java client. I don't know how to use SAAJ and MTOM together to do that. This issue is really preventing me from progressing in a time sensitive project and I appreciate your help in resolving the issue.

Edited by: John23 on Apr 17, 2013 7:57 AM
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on May 28 2013
Added on Apr 17 2013