Hi Tejpal
When MTOM/XOP is used to optimize a SOAP message, it is serialized into a MIME Multipart/Related message using XOP processing. The Java callout we are discussing, handles that kind of message. If you don’t have that, then this callout won’t help you.
In a multipart related message, there are outer HTTP message headers, and then also headers that apply to the individual parts. The outer headers are like this:
Content-Type: Multipart/Related; boundary=1beaad94-5c5b-4965-a0dc-be74ad5ef661
start="<11a1a188-72e5-4390-bcd3-282c9af5d835>";
type="application/xop+xml"
(other HTTP Headers here)
The important pieces there:
- multipart/related means the message content (stuff that follows the headers) will have multiple parts, and those parts are related.
- the boundary parameter specifies the separator between the different parts
- the start parameter specifies the content-id of the first part
- the type parameter specifies the content-type of the first part. (When the outer content-type is multipart/related, there are also additional content-type headers that apply to each of the following parts)
The inner structure is like this:
--1beaad94-5c5b-4965-a0dc-be74ad5ef661
Content-Type: application/soap+xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <11a1a188-72e5-4390-bcd3-282c9af5d835>
<soapenv:Body
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
...
<ns2:AttachmentData64Binary>
<xop:Include href='cid:b68d5d837c4a0f3d30c410@apache.org'
xmlns:xop='http://www.w3.org/2004/08/xop/include'/>
</ns2:AttachmentData64Binary>
....
</soapenv:Body>
--1beaad94-5c5b-4965-a0dc-be74ad5ef661
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <b68d5d837c4a0f3d30c410@apache.org>
%PDF-1.4
...
%%EOF
--1beaad94-5c5b-4965-a0dc-be74ad5ef661--
Notice there are two parts to the inner structure, and the parts are related. (Hence the name “multipart/related”). Notice each part gets its own headers! including content-type and content-id. The first part is the XML that includes a xop:Include element. That element refers to the second part, via the href attribute, which uses the cid: URI scheme, as defined in IETF RFC 2392. Folding these two related parts together is one of the things the Xop handler callout does. It looks at the href in the xop:Include element, finds the part which is identified by that content-id, base64-encodes that part content, and replaces the xop:Include element with that data. The only way this will work is if there are two parts to begin with.
Request body will have only xml payload. Its doesn’t have any other data (In callout its expecting multipart as request header and other two content type as well in body for xml payload and for pdf data but I don’t have anything like this in my scenario. In my case I have application/xop+xml as request header and in body there will be only xml payload and no Content-Type).
In that case, you have an incomplete message, and obviously it is not possible to resolve the xop:Include, right? In the supported scenario, the href in the xop:Include points to content elsewhere in the message. You’re telling me you have a xop:Include element, but no other content. That reference cannot be resolved. The href points to … an unknown location.
The xop:Include element in the SOAP body example you provided is this:
<xop:Include href='cid:b68d5d837c4a0f3d30c410@apache.org'
xmlns:xop='http://www.w3.org/2004/08/xop/include'/>
The href points to something. How do you propose to de-reference that href, if there is no second part? The href, by definition, points to A DIFFERENT PART in the multipart message. You’re telling me there is just one part. Well then you cannot de-reference the xop:Include. It’s not possible. The information is missing.
I think you are trying to solve a problem which is unsolvable. Or I have failed to understand what you’re asking. I’ve done my best to try to help you, without success. We’ve gone round and round on the desired input and output. The confusion I had at the beginning, just trying to understand your goal, remains. I think you might need another set of eyes to look at the situation with you. Good luck!