Topic
  • 8 replies
  • Latest Post - ‏2013-01-10T14:47:00Z by mdindagur
mdindagur
mdindagur
41 Posts

Pinned topic SOAP with attachment from inline file content(base64Binary)

‏2013-01-07T21:19:09Z |
Hello,

I am working on converting from inline attachment to SOAP with attachment. The following two forum threads provided a lot of information in my approach.

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14878439&#14878439
http://www.ibm.com/developerworks/forums/thread.jspa?threadID=465866

However, for some reason, I am not able to see the attachment before the next step. I am doing this because of bad hand-shake between datapower and symantec antivirus(incompatible ICAP - malformed container error).

I have attached the key transformation file as an attachment. Appreciate it for any help from the forum in this regard. Please do let me know if more information is needed.
thanks
-Mahesh M
Updated on 2013-01-10T14:47:00Z at 2013-01-10T14:47:00Z by mdindagur
  • HermannSW
    HermannSW
    4645 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-08T15:56:07Z  
    You do use data-type="base64" option of <dp:url-open ...>
    That means that you have to pass (Non-XML) input base64 encoded.

    But you seem to pass normal, not base64-encoded text:
    <xsl:variable name="documentContent" select="dp:variable('var://context/requestDoc')//document//documentContent//text()"/>
    


    If that is the case, then this should do what you want (see the added "dp:encode(_,'base-64')" in 3rd line):
    <xsl:variable name="v" select="'attachment://swa/cid:Attach'" />
    <dp:url-open target="{$v}" data-type="base64" response="ignore">
      <xsl:copy-of select="dp:encode($documentContent,'base-64')" />
    </dp:url-open>
    


     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:42:53Z at 2014-03-25T02:42:53Z by iron-man
  • mdindagur
    mdindagur
    41 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-08T15:56:23Z  
    Hello,

    I have attached a sample request(inlineRequest.xml) and expected transformed request(attachmentRequest.xml). The inline data needs to be appended as an attachment.
    Appreciate any pointers to this problem.
    thanks,
  • HermannSW
    HermannSW
    4645 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-08T16:16:01Z  
    • mdindagur
    • ‏2013-01-08T15:56:23Z
    Hello,

    I have attached a sample request(inlineRequest.xml) and expected transformed request(attachmentRequest.xml). The inline data needs to be appended as an attachment.
    Appreciate any pointers to this problem.
    thanks,
    OK, your original code is correct, since your data is already base64 encoded:
    $ xpath++ "//document//documentContent//text()" inlineRequest.xml 
    -------------------------------------------------------------------------------
    UEsDBAoAAAAAADKs6yjRINsxuAAAALgAAAANAAAAZWljYXJfY29tLnppcFBLAwQKAAAAAADgmLgoPM9RaEQAAABEAAAACQAAAGVpY2FyLmNvbVg1TyFQJUBBUFs0XFBaWDU0KFBeKTdDQyk3fSRFSUNBUi1TVEFOREFSRC1BTlRJVklSVVMtVEVTVC1GSUxFISRIK0gqUEsBAhQACgAAAAAA4Ji4KDzPUWhEAAAARAAAAAkAAAAAAAAAAQAgAP+BAAAAAGVpY2FyLmNvbVBLBQYAAAAAAQABADcAAABrAAAAAABQSwECFAAKAAAAAAAyrOso0SDbMbgAAAC4AAAADQAAAAAAAAAAACAAtoEAAAAAZWljYXJfY29tLnppcFBLBQYAAAAAAQABADsAAADjAAAAAAA=
    $
    


    > However, for some reason, I am not able to see the attachment before the next step.
    >
    Is "swa" the input context of the next step?
    If not, then please insert a (dummy) Results action before next step, with input context "swa" and output context "NULL".
    Then you will see the "swa" context in Probe, and clicking on "attachments" tab for "swa" context will show you the "cid:Attach" attachment.

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:42:45Z at 2014-03-25T02:42:45Z by iron-man
  • mdindagur
    mdindagur
    41 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-08T19:19:18Z  
    • HermannSW
    • ‏2013-01-08T16:16:01Z
    OK, your original code is correct, since your data is already base64 encoded:
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">$ xpath++ "//document//documentContent//text()" inlineRequest.xml ------------------------------------------------------------------------------- UEsDBAoAAAAAADKs6yjRINsxuAAAALgAAAANAAAAZWljYXJfY29tLnppcFBLAwQKAAAAAADgmLgoPM9RaEQAAABEAAAACQAAAGVpY2FyLmNvbVg1TyFQJUBBUFs0XFBaWDU0KFBeKTdDQyk3fSRFSUNBUi1TVEFOREFSRC1BTlRJVklSVVMtVEVTVC1GSUxFISRIK0gqUEsBAhQACgAAAAAA4Ji4KDzPUWhEAAAARAAAAAkAAAAAAAAAAQAgAP+BAAAAAGVpY2FyLmNvbVBLBQYAAAAAAQABADcAAABrAAAAAABQSwECFAAKAAAAAAAyrOso0SDbMbgAAAC4AAAADQAAAAAAAAAAACAAtoEAAAAAZWljYXJfY29tLnppcFBLBQYAAAAAAQABADsAAADjAAAAAAA= $ </pre>

    > However, for some reason, I am not able to see the attachment before the next step.
    >
    Is "swa" the input context of the next step?
    If not, then please insert a (dummy) Results action before next step, with input context "swa" and output context "NULL".
    Then you will see the "swa" context in Probe, and clicking on "attachments" tab for "swa" context will show you the "cid:Attach" attachment.

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Hi Hermann,

    Thank you. Appreciate your quick response in this regard. I inserted the result action suggested by you. I still couldnt see the attachment.
    Please find the packet capture from the gateway for a sample request.

    I am trying this approach to separate inline (base64 encoded) document as an attachment and scan using antivirus scanner using ICAP protocol.
    Since Symantec protection engine is unable to scan entire message for messages with attachment, I would want to just scan the attachment only,
    by using corresponding configuration. I need your valuable input in this regard.
    thanks,
    -Mahesh
  • HermannSW
    HermannSW
    4645 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-09T09:30:28Z  
    • mdindagur
    • ‏2013-01-08T19:19:18Z
    Hi Hermann,

    Thank you. Appreciate your quick response in this regard. I inserted the result action suggested by you. I still couldnt see the attachment.
    Please find the packet capture from the gateway for a sample request.

    I am trying this approach to separate inline (base64 encoded) document as an attachment and scan using antivirus scanner using ICAP protocol.
    Since Symantec protection engine is unable to scan entire message for messages with attachment, I would want to just scan the attachment only,
    by using corresponding configuration. I need your valuable input in this regard.
    thanks,
    -Mahesh
    Hi Mahesh,

    you do have (at least) two issues here:
    1) The output context of the 2nd Transform action is "swa" -- that will overwrite what you did store there by
    <dp:set-variable name="'var://context/swa'" value="$soap" />
    

    please change output context of 2nd transform action to eg. NULL

    2) As you can see, the "swa" context contains your <dp:set-variable ...> and <dp:url-open ...> instructions, they do not get executed.
    Reason is that "dp" is not known to be an extension element.

    You have a typo in your <xsl:stylesheet ... extensions-Element-prefixes="dp">, should be small letter 'e', not 'E'.
    "Unexpected attribute 'extension-Element-prefixes' on element 'xsl:stylesheet'" should be somewhere in your logs.



     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:42:42Z at 2014-03-25T02:42:42Z by iron-man
  • mdindagur
    mdindagur
    41 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-09T11:57:25Z  
    • HermannSW
    • ‏2013-01-09T09:30:28Z
    Hi Mahesh,

    you do have (at least) two issues here:
    1) The output context of the 2nd Transform action is "swa" -- that will overwrite what you did store there by
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><dp:set-variable name="'var://context/swa'" value="$soap" /> </pre>
    please change output context of 2nd transform action to eg. NULL

    2) As you can see, the "swa" context contains your <dp:set-variable ...> and <dp:url-open ...> instructions, they do not get executed.
    Reason is that "dp" is not known to be an extension element.

    You have a typo in your <xsl:stylesheet ... extensions-Element-prefixes="dp">, should be small letter 'e', not 'E'.
    "Unexpected attribute 'extension-Element-prefixes' on element 'xsl:stylesheet'" should be somewhere in your logs.



     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Hi Hermann,

    Thank you for pointing out the typo - error. I am sorry about that. I have corrected it.
    Regarding the first error, I have had issues in completing the rule. For eg. when I set the output for 2nd transform as NULL,
    I see the following in the logs.
    05:46:08 mpgw error 16871279 error 168.38.103.250 0x00c3000c mpgw (TestAMFMPGW): Context does not exist
    Also,the flow breaks at the 2nd transform action.

    Please do let me know if you need more details.
    thanks,
    -Mahesh
  • mdindagur
    mdindagur
    41 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-09T14:42:48Z  
    • mdindagur
    • ‏2013-01-09T11:57:25Z
    Hi Hermann,

    Thank you for pointing out the typo - error. I am sorry about that. I have corrected it.
    Regarding the first error, I have had issues in completing the rule. For eg. when I set the output for 2nd transform as NULL,
    I see the following in the logs.
    05:46:08 mpgw error 16871279 error 168.38.103.250 0x00c3000c mpgw (TestAMFMPGW): Context does not exist
    Also,the flow breaks at the 2nd transform action.

    Please do let me know if you need more details.
    thanks,
    -Mahesh
    Hi Hermann,

    My understanding is that the stylesheet "inlineToSwA.xsl" I have coded does everything i.e., writing the SOAP message and the attachment into 'var://context/swa' in the following lines...
    <dp:set-variable name="'var://context/swa'" value="$soap" />
    <dp:set-http-request-header name="'Content-Type'" value="'application/soap+xml'" />
    <xsl:variable name="v" select="'attachment://swa/cid:Attach'" />
    <dp:url-open target="{$v}" data-type="base64" response="ignore">
    <xsl:copy-of select="$documentContent" />
    </dp:url-open>
    I am thinking I don't have to configure a 'RESULT' action to specifically take input as 'swa' or 'var://context/swa' except for debugging purpose.
    If this is true,
    If I am using an input dpvar_4 in the action next to the transform using "inlineToSwA.xsl", I can as well use either
    a.dpvar_4 in <dp:set-variable name="'var://context/swa'" value="$soap" />
    or
    b.use 'var://context/swa' as input in the next action after the transform.
    Otherwise, 'RESULT' action must be doing extra from what my understanding is. Could you please clarify?

    thanks,
    -Mahesh
  • mdindagur
    mdindagur
    41 Posts

    Re: SOAP with attachment from inline file content(base64Binary)

    ‏2013-01-10T14:47:00Z  
    • mdindagur
    • ‏2013-01-09T14:42:48Z
    Hi Hermann,

    My understanding is that the stylesheet "inlineToSwA.xsl" I have coded does everything i.e., writing the SOAP message and the attachment into 'var://context/swa' in the following lines...
    <dp:set-variable name="'var://context/swa'" value="$soap" />
    <dp:set-http-request-header name="'Content-Type'" value="'application/soap+xml'" />
    <xsl:variable name="v" select="'attachment://swa/cid:Attach'" />
    <dp:url-open target="{$v}" data-type="base64" response="ignore">
    <xsl:copy-of select="$documentContent" />
    </dp:url-open>
    I am thinking I don't have to configure a 'RESULT' action to specifically take input as 'swa' or 'var://context/swa' except for debugging purpose.
    If this is true,
    If I am using an input dpvar_4 in the action next to the transform using "inlineToSwA.xsl", I can as well use either
    a.dpvar_4 in <dp:set-variable name="'var://context/swa'" value="$soap" />
    or
    b.use 'var://context/swa' as input in the next action after the transform.
    Otherwise, 'RESULT' action must be doing extra from what my understanding is. Could you please clarify?

    thanks,
    -Mahesh
    Hello,

    After working with my stylesheet for quite some time, I went back to xml2swa.xsl explained in other thread and started building up incrementally. As mentioned in the previous post, I had messed up on configurations on individual actions. Now, I have a working stylesheet which accomplishes the set goal.

    I am glad I got so much support from the community & Hermann in particular. Appreciate the guidance..
    thanks again,
    -Mahesh M