Leave feedback
  • Question

    cURL Execute() and StreamServe application crash

Enter a new topic
  • Krister Spjut Krister Spjut
    0 likes 1322 views

    Hello StreamShare,

     

    I’m having trouble with handling a WS response received through cURL with the Execute() function. The result is that the StreamServe service/application crashes randomly.

    In more detail I use cURL to call a WS. The WS returns an XML, with a header containing code page UTF-8. But one element in the XML contains XML that is of type iso-8859-1. This is an example of how it looks:

    <?xml version="1.0" encoding="utf-8"?>

    <contractData>

       <ContractData>

          <element1>value1</element1>

          <element2>value2</element2>

          <element3><?xml version="1.0" encoding="ISO-8859-1" ?><SubElementData></ SubElementData ></element3>

       <ContractData>

          <element1>value1</element1>

          <element2>value2</element2>

          <element3><?xml version="1.0" encoding="ISO-8859-1" ?><SubElementData></ SubElementData ></element3>

       </ContractData>

    <contractData>

     

    cURL runs as an executable, a resource, in the project in question. The received data is stored in the standard output variable. As soon as I try to do anything, for instance printing the variable to the log file in Control Center, the service/application crashes without warning. The same goes for doing something to the variable in question, like using function substr() or substrrepl().

     

    If I write the response to a file directly from cURL it is coded as UTF-8. If I create a file in StreamServe, through filewrite, it’s ANSI. So it seems that StreamServe converts the response in question. If I use the function Utf8EncodeString() on the variable and then use filewrite the file is coded as UTF-8 but the StreamServe service/application still crashes when using for example log().

    Has anyone encountered this or have any idea what might be the problem here?

    Friday 21 February, 2014
  • David Bares David Bares OpenText Employee Administrator StreamServe Employee
    0 likes

    First of all, your returned XML is not valid.

    Error    1    Unexpected XML declaration. The XML declaration must be the first node in the document and no white space characters are allowed to appear before it.

    And is it at all possible to mix encoding inside one XML document?

    Can you by chance attach the respoinse saved directly from cURL? We can try to emulate the process by using some other Execute process to play it on stdout.

    Friday 21 February, 2014
  • Krister Spjut Krister Spjut
    0 likes

    Thank you for your response.

    Regarding the invalid XML, this was just an example to illustrate what i meant with XML inside XML (with a separate codepage). I'll attach the real response from cURL asap.

    And for the record, the response is generated by an external system and is out of my controll.

    Friday 21 February, 2014
  • Krister Spjut Krister Spjut
    0 likes

    Sorry for the late response!

    Sadly I wasn't allowed to post the XML on an open forum but I've investigated the problem a little more and as it turns out it's not the actual XML/content that causes StreamServe to crash. It seems like it is the StreamServe function StrTok, that's used to separate the actual xml response from a http-code in my case, that causes the application/service to crash. I don't know whether it's due to the content itself or the sheer amount of information though. When using StridX + SubStr, to divide the XML response and the http-code, it works perfectly.

    Does anyone know if there's a limit for the size of content or something for the StrTok function?

    Friday 14 March, 2014
  • David Bares David Bares OpenText Employee Administrator StreamServe Employee
    0 likes

    Can you scramble the actual data so that we wouild see the stream structure that is feeding the strtok?

    What was it that you used as a separator for strtok? Perhaps you can show us the strtok script line?

    Friday 14 March, 2014
  • Krister Spjut Krister Spjut
    1 likes

    I've been using "|" as separator.

    $varNumOfTokens = StrTok($output,"|",$arrOutput); It seems like the problem is due to the size of the variable, in my case $output. I filled the variable with a huge amount of "A"-characters and the application crashed.

    Friday 14 March, 2014