Topic
2 replies Latest Post - ‏2012-12-04T13:20:51Z by Daviiid
SystemAdmin
SystemAdmin
6772 Posts
ACCEPTED ANSWER

Pinned topic Processing HTTP MIME Multipart using Xslt

‏2012-12-03T15:06:05Z |
Hi,

I have to convert the HTTP MIME Multipart message into soap message using xslt.

HTTP MIME Multipart message:

POST /core/eligibility HTTP/1.1
Host: server_host:server_port
Content-Length: 2408
Content-Type: multipart/form-data; boundary=XbCY
--XbCY
Content-Disposition: form-data; name=“PayloadType“
X12_270_Request_005010X279A1
--XbCY
Content-Disposition: form-data; name=“ProcessingMode"
RealTime
--XbCY
Content-Disposition: form-data; name=“PayloadID"
e51d4fae-7dec-11d0-a765-00a0c91e6da6
--XbCY
Content-Disposition: form-data; name=“TimeStamp"
2007-08-30T10:20:34Z
--XbCY
Content-Disposition: form-data; name=“UserName"
hospa
--XbCY
Content-Disposition: form-data; name=“Password"
8y6dt3dd2
--XbCY
Content-Disposition: form-data; name=“SenderID“
HospitalA
--XbCY
Content-Disposition: form-data; name=“ReceiverID"
PayerB
--XbCY
Content-Disposition: form-data; name=“CORERuleVersion"
2.1.0
--XbCY
Content-Disposition: form-data; name=“Payload" filename="name.txt“
<contents of file go here -- 1674 bytes long as specified above>
XbCY

From the Above message have to extract the data under Payload and palce it in the soap message.

Output Soap message:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header/>
<soapenv:Body>
<Payload> Payload data from the HTTP MIME Multipart message to be send in this filed </Payload>
</soapenv:Body>
</soapenv:Envelope>

Is there any xslt to process the HTTP MIME Multipart message?

Can any one help regarding this Xslt which can convert HTTP MIME Multipart message into above soap message.

Thanks in advance.
Updated on 2012-12-04T13:20:51Z at 2012-12-04T13:20:51Z by Daviiid
  • HermannSW
    HermannSW
    4394 Posts
    ACCEPTED ANSWER

    Re: Processing HTTP MIME Multipart using Xslt

    ‏2012-12-03T18:07:06Z  in response to SystemAdmin
    Please try "Convert Query Params to XML" action with Non-XML request type.
    This will work if the file (name.txt) in "Payload" section consists of XML characters.
    The result of that action is XML and you can build your SOAP from that.

    If "Payload" contains Non-XML/binary data, then you need to
    • use swaform tool
    • think on what you will do with the Non-XML data as that cannot go unchanged into your SOAP file.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    • Daviiid
      Daviiid
      282 Posts
      ACCEPTED ANSWER

      Re: Processing HTTP MIME Multipart using Xslt

      ‏2012-12-04T13:20:51Z  in response to HermannSW
      Hello

      You can use this stylesheet which convert all param (include input type file)

      
      <xsl:stylesheet version=
      "1.0" xmlns:xsl=
      "http://www.w3.org/1999/XSL/Transform" xmlns:str=
      "http://exslt.org/strings" xmlns:dp=
      "http://www.datapower.com/extensions" extension-element-prefixes=
      "dp" exclude-result-prefixes=
      "str"> <dp:input-mapping href=
      "store:///pkcs7-convert-input.ffd" type=
      "ffd"/> <xsl:variable name=
      "boundaryHex" select=
      "concat('2D2D',dp:radix-convert(dp:encode(substring-after(dp:http-request-header('Content-Type'),'boundary='),'base-64'),64,16))"/> <xsl:output omit-xml-declaration=
      "yes" method=
      "xml" indent=
      "yes"/> <xsl:template match=
      "/"> <xsl:variable name=
      "fluxComplet" select=
      "dp:radix-convert(dp:binary-encode(/object/message/node()),64,16)"/> <xsl:variable name=
      "Header" select=
      "dp:variable('var://service/header-manifest')"/> <ConvertToXml> <header> <xsl:for-each select=
      "$Header//headers//header"> <xsl:element name=
      "{.}"> <xsl:value-of select=
      "dp:http-request-header(.)"/> </xsl:element> </xsl:for-each> </header> <DataBody> <xsl:for-each select=
      "str:split($fluxComplet,$boundaryHex)"> <xsl:variable name=
      "value" select=
      "."/> <xsl:choose> <xsl:when test=
      ".='2D2D0D0A'"/> <xsl:when test=
      ".=''"/> <xsl:otherwise> <xsl:element name=
      "part"> <xsl:for-each select=
      "str:split(substring-after(substring-before(.,'0D0A0D0A'),'0D0A'),'0D0A')"> <xsl:choose> <xsl:when test=
      "contains(.,'3B')"> <xsl:for-each select=
      "str:split(.,'3B')"> <xsl:choose> <xsl:when test=
      "contains(.,'3A20')"> <xsl:element name=
      "{substring-before(dp:decode(dp:radix-convert(.,16,64),'base-64'),': ')}"> <xsl:value-of select=
      "substring-after(dp:decode(dp:radix-convert(.,16,64),'base-64'),': ')"/> </xsl:element> </xsl:when> <xsl:when test=
      "contains(.,'2066696C656E616D653D22')"> <xsl:element name=
      "fileName"> <xsl:value-of select=
      "substring-before(substring-after(dp:decode(dp:radix-convert(.,16,64),'base-64'),'filename=&quot;'),'&quot;')"/> </xsl:element> <file> <xsl:value-of select=
      "substring-after($value,'0D0A')"/> </file> </xsl:when> <xsl:when test=
      "contains(.,'206E616D653D22')"> <xsl:element name=
      "inputName"> <xsl:value-of select=
      "substring-before(substring-after(dp:decode(dp:radix-convert(.,16,64),'base-64'),'name=&quot;'),'&quot;')"/> </xsl:element> <xsl:
      
      if test=
      "not(contains($value,'2066696C656E616D653D22'))"> <inputValue> <xsl:value-of select=
      "dp:decode(dp:radix-convert(substring-before(substring-after($value,'0D0A0D0A'),'0D0A'),16,64),'base-64')"/> </inputValue> </xsl:if> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:for-each> </DataBody> </ConvertToXml> </xsl:template> </xsl:stylesheet>