Topic
8 replies Latest Post - ‏2013-12-22T23:39:00Z by HermannSW
dp_techdev
dp_techdev
44 Posts
ACCEPTED ANSWER

Pinned topic url-open tcp call with non-xml data

‏2013-12-19T15:31:26Z |

Hello,

I have a requirement where I need to call some external system on tcp call with Raw data(Fixed Length string).

I am reading the raw message from MPG mq front side handler,And in my request rule i am converting incoming message into XML using transform binary action( using String.utf-8.ffd),

<object><message>test</message></object>

After i am using xslt transform action with below code to make tcp call

<xsl:variable name="targetURL" select="'tcp://10.11.50.76:22342'" />

<xsl:template match="/">     
        <xsl:variable name="response">
            <dp:url-open target="{$targetURL}" response="binaryNode">
                  <xsl:value-of select="/object/message/text()" disable-output-escaping="yes"/>
            </dp:url-open>
        </xsl:variable>          
           <dp:set-variable name="'var://context/sadad/response'" value="dp:decode(dp:binary-encode($response/result/binary),'base-64')" />
          <xsl:copy-of select="/" />
</xsl:template>

My server is not able to receive my data..and in the prob i am not able to see anything after my stylesheet action(Check attachment) and in log also(check attachment) i am not able to see what is the error.

I have did the packet capture while sending data after Intial handshake it giving below error.(Check attached file for reference)

Checksum: 0x62f2 [incorrect, should be 0xdc24 (maybe caused by "TCP checksum offload"?)]

I am not sure what is the exact issue  whether i am doing the right thing ..

Can anyone help me on this..

Thank You

Updated on 2013-12-19T15:32:45Z at 2013-12-19T15:32:45Z by dp_techdev
  • dp_techdev
    dp_techdev
    44 Posts
    ACCEPTED ANSWER

    Re: url-open tcp call with non-xml data

    ‏2013-12-21T12:47:38Z  in response to dp_techdev

    Hello Team

    Still i am working on this issue can any one help me on this..

     

    Thanks in advance..

    • kenhygh
      kenhygh
      1340 Posts
      ACCEPTED ANSWER

      Re: url-open tcp call with non-xml data

      ‏2013-12-21T14:49:00Z  in response to dp_techdev

      You might have to open a PMR with IBM support to get a definitive answer on this one.

      • dp_techdev
        dp_techdev
        44 Posts
        ACCEPTED ANSWER

        Re: url-open tcp call with non-xml data

        ‏2013-12-21T17:45:02Z  in response to kenhygh

        Hi

        Thank you I will raise a PMR on this before that can you confirm me whether i am in right direction or not I mean url-open will support tcp with raw data or not.

        Thanks

         

        • kenhygh
          kenhygh
          1340 Posts
          ACCEPTED ANSWER

          Re: url-open tcp call with non-xml data

          ‏2013-12-21T17:57:30Z  in response to dp_techdev

          url-open supports raw tcp according to the docs, but I've never tried it.

  • ted.jump
    ted.jump
    228 Posts
    ACCEPTED ANSWER

    Re: url-open tcp call with non-xml data

    ‏2013-12-21T21:50:21Z  in response to dp_techdev

    I found it easiest in a case like this to take the input and do the simple binary transform on it, generating base64 data.

    Then using data-type base64 on url-open the original payload gets sent without any mutation.

    In the attached sample I'm sending to an MQ back-end, but it works equivalently for HTTP with the appropriate url and headers.

     

    Attachments

  • HermannSW
    HermannSW
    4239 Posts
    ACCEPTED ANSWER

    Re: url-open tcp call with non-xml data

    ‏2013-12-22T00:27:57Z  in response to dp_techdev

    No need for a PMR.

    techdev.xsl (attached) is complete stylesheet built from original above.

    Please first try "tcp://..." connections against a TCP server you can rely on and you know to work.

    I use netcat command for that, "nc -l 22342"

    • listens on port 22342
    • receives any data and displays it
    • returns standard input as response
    • then closes connection and terminates

    So this is basically a one-shot TCP server (you can restart).

    Here you can see that stylesheet techdev.xsl can access that service, and displays the response received:

    $ echo "Merry ..." | coproc2 techdev.xsl - http://firestar:2224
    ¡sɐɯʇsᴉɹɥƆ ˙˙˙
    $

    This is the raw TCP server execution:

    $ echo "¡sɐɯʇsᴉɹɥƆ ˙˙˙" | nc -l 22342
    Merry ...
    $


    Just for completeness stylesheet:

    $ cat techdev.xsl
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:dp="http://www.datapower.com/extensions"
      extension-element-prefixes="dp"
    >
      <dp:input-mapping  href="http://9.152.93.14/String.utf-8.ffd" type="ffd"/>

      <xsl:output omit-xml-declaration="yes" />

      <xsl:variable name="targetURL" select="'tcp://9.152.92.85:22342'" />

      <xsl:template match="/">     
        <xsl:variable name="response">
          <dp:url-open target="{$targetURL}" response="binaryNode">
            <xsl:value-of select="/object/message/text()"
              disable-output-escaping="yes"
            />
          </dp:url-open>
        </xsl:variable>          

        <xsl:value-of select="dp:decode(
                                dp:binary-encode($response/result/binary),
                                'base-64'
                              )"
        />
      </xsl:template>
     
    </xsl:stylesheet>
    $

     

    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>

    Attachments

    • dp_techdev
      dp_techdev
      44 Posts
      ACCEPTED ANSWER

      Re: url-open tcp call with non-xml data

      ‏2013-12-22T22:03:48Z  in response to HermannSW

      Thank you Herman,

      I have found the issue my msg format not match with server expected format so even though I am sending it Is not accepted by server.Now it is resolved but i have another issue here.

      My requirement is before sending the payload first i need to send APPLICATION START message(not a TCP START) so then server acknowledge the START message.I have done this by below code.

      <xsl:variable name="targetURL" select="'tcp://10.11.50.76:22342'" />
      <xsl:variable name="STARTMsgResponse">
           <dp:url-open target="{$targetURL}" response="binaryNode">
                        <xsl:value-of select="'START'" disable-output-escaping="yes"/>
            </dp:url-open>
      </xsl:variable>
      <xsl:variable name="MsgResponse">
           <dp:url-open target="{$targetURL}" response="binaryNode">
                        <xsl:value-of select="/object/message/text()" disable-output-escaping="yes"/>
                </dp:url-open>
      </xsl:variable>

      I have limitation here, with START message server opening a new connection and waiting for to receive payload from client when i send data using url-open instead of using connection object which is opened from START message it is creating a new one.

      Is there any option to control the number of connections from client i mean same connection object I want to use till I send STOP message.I hope we have option in MQ manger for number of connections and persistence connections.

      I have enabled persistence connections in advanced parameters still server taking as new connection for my second url-open.

      Can any one help me on this..

      Thanks