Skip to Content
author's profile photo Former Member
Former Member

Not able to send attachments from Sourcing W9 to PI web service


We have a requirement to extract some details of Suppliers, including an extension Attachment field and pass these values to PI/PO. There is a SOAP web service at PI/PO side. I am able to send test data to this web service from an independent java program. The same logic is deployed in Sourcing as custom JAR. I have written a prepublish script in Sourcing. If the attachment is not passed, I am able to get a successful response from the web service. But when I try to pass the attachment, the message send itself fails.

I am using javax,xml.soap.SOAPMessage class to create the request. The web service is in SOAP 1.1

This is the code in my custom jar for processing attachment:

File attch = vendorData.getW9Attach();

FileDataSource fds = new FileDataSource(attch.getName());

DataHandler dh = new DataHandler(fds);

AttachmentPart attachment = message.createAttachmentPart();




Without this code to add attachment, I get a successful response. When I add the above code, I get the error message:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to internalize message

The stackTrace is:, com.*****.custom.WebClientForVendorPublish.getResponseForVendorData(, sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(, sun.reflect.DelegatingMethodAccessorImpl.invoke(, java.lang.reflect.Method.invoke(, bsh.Reflect.invokeOnMethod(Unknown Source), bsh.Reflect.invokeObjectMethod(Unknown Source), bsh.Name.invokeMethod(Unknown Source), bsh.BSHMethodInvocation.eval(Unknown Source), bsh.BSHPrimaryExpression.eval(Unknown Source), bsh.BSHPrimaryExpression.eval(Unknown Source), bsh.BSHBlock.evalBlock(Unknown Source), bsh.BSHBlock.eval(Unknown Source), bsh.BSHBlock.eval(Unknown Source), bsh.BSHTryStatement.eval(Unknown Source), bsh.Interpreter.eval(Unknown Source), bsh.Interpreter.eval(Unknown Source), bsh.Interpreter.eval(Unknown Source),,,,,,,,,

If anyone has successfully used SOAP 1.1 with attachment from Sourcing, please help

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 03, 2014 at 11:37 AM

    I tried out different suggestions given in various java forums and finally made it work by including the following changes:

    1. Removed calls to message.saveChanges() throughout my custom JAR code, following the advice on this thread -

    SAP Sourcing W9 uses Java 6 (u33) and the above change resulted in an update in error message!

    2. Downloaded the latest SAAJ implementation jar (saaj-impl-1.3.19.jar), deployed it as a custom jar in Sourcing and added this line in my script:


    This tip is from

    3. I was using a FileDataSource object to read the attachment file and creating DataHandler from this FileDataSource Updated the code to use a

    URL fileUrl = attachmentFile.toURL();

    DataHandler dh = new DataHandler(fileUrl);

    AttachmentPart attachment = message.createAttachmentPart(dh);

    4. Removed the setContentId method. Somehow Sourcing was not liking the fact that I am setting a Content-Id header for my attachment!

    A combination of all the above 4 steps is required to make attachment sending via web service work from sourcing.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.