Customer raised question on developerWorks DataPower forum on how to convert client SOAP With Attachmnt (SWA) request on DataPower to REST. Yesterday's posting specifically raised the question on how to convert SWA to JSON-WSP attachment service request format.
The response attachment .zip contains sample service export, sample files and quite some useful tools for dealing with SWA files and DataPower. Besides the swa2json-wsp.xsl stylesheet these tools are useful for dealing with SWA files:
a bash script for creating a SWA file with dummy root part and all passed files as attachments
auxiliary program for detemining ContentType of an arbitrary file
auxiliary bash script that determines the boundary of a given SWA file
tool that determines SWA boundary and populates the header variable before sending request by curl
With these tools sending some attachments to DataPower SWA service is just two commands (see posting above for sample executions):
and did numerous postings on develoerWorks DataPower forum making use of coproc2 service for demonstration.
The coproc2 service itself (MPGW export attached in this posting) is unchanged since first posting.
A one-line (bash) shell-script client (coproc2) and a Java client (coproc2.java) are available.
Today I posted new coproc2 client coproc2swa, another (bash) shell-script client usable in Linux and Cygwin under Windows (tested!). http://www.ibm.com/developerworks/forums/thread.jspa?threadID=387511 ... # This file is an all-in-one solution in that it # # 1) is the coproc2swa client for processing SWA data with coproc2 service # ("bash" script, in "preamble") # # 2) is a SWA file itself(!) and can be used as sample input # # 3) allows to inspect SWAfile by -preamble/-epilogue/-print (cids) # # 4) contains four demo stylesheets which may be referenced by "cid..." # # attman.xsl # - accessing attachment manifest and content-types # # pgm1st.xsl # - output first "image/x-portable-greymap" attachment (binary data!) # # xml1st.xsl # - output first "text/xml" attachment # # zipit.xsl # - return zip of all "text/xml" and "image/x-portable-greymap" attachments ...
The demo I like most is cid:zipit.xsl (invoked by "coproc2swa cid:zipit.xsl ~/bin/coproc2swa http://dp3-l3:2223 -s >z.zip").
It just determines all attachments of type "text/xml" and "image/x-portable-greymap" from SWA file,
adds them to archive "archive-zip" and returns that archive as result (binary data) !
This post is on little tool mimeswacurl for sending an arbitrary file as attachment of a SOAP with Attachments file to a service endpoint. This is really useful if developing a DataPower service dealing with SOAP with Attachments.
On DataPower the so called attachment-manifest gives details of the SOAP document as well as all atachments.
Stylesheet manifest.xsl which just outputs var://local/attachment-manifest for demo application below:
The service accepts Non-XML traffic, attaches the binary input to a dummy SOAP document and therefore creates the SWA file needed for further processing.
The binary input of Non-XML transformations needs to be "consumed", otherwise the default behavior is that it will be copied to the output. Attaching the input to the dummy SOAP file does not consume the input.
Therefore stylesheet "bin.xsl" needs to invoke a <dp:input-mapping>, whose output is just discarded. In the posting above a separate FFD file is provided and used. Because its output is not used at all bin.xsl's line
<dp:input-mapping href="bin.ffd" type="ffd"/>
can be simplified to refer to a FFD file that is offically shipped as part of the DataPower product: