Service Virtualization

  • 1.  Live recording Raw Traffic file has Escaped strings in Response Body

    Posted Jul 13, 2018 10:28 AM

    Hi All,

     

    While live recording, the raw traffic export file shows escaped strings (<, >) in the Response Payload body instead of XML tags. However the response in the VSI has actual xml tags.

     

    Raw Traffic File Response: 

    <body charset="UTF-8">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ServiceResult version="2.0"&gt;&lt;ResultHeader&gt;&lt;ServiceName&gt;ServiceFrameworkException&lt;/ServiceName&gt;&lt;/ResultHeader&gt;&lt;ResultBody/&gt;&lt;ResultStatus&gt;&lt;ReturnCode&gt;1&lt;/ReturnCode&gt;&lt;ResultMessage&gt;&lt;MessageCode&gt;SLFC0999&lt;/MessageCode&gt;&lt;MessageSeverity&gt;E&lt;/MessageSeverity&gt;&lt;MessageInformation&gt;XML_PARSE_EXCEPTION_ERROR&lt;/MessageInformation&gt;&lt;MessageDescription&gt;com.slfc.framework.service.ServiceFrameworkException: ServiceMessageFactory.createServiceRequest .. Unmarshalling ServiceRequest .. org.xml.sax.SAXException: Parsing Error : Premature end of file.

     

    VSI Response:

    <ServiceResult version="2.0">
    <ResultHeader>
    <ServiceName>ServiceFrameworkException</ServiceName>
    </ResultHeader>
    <ResultBody/>
    <ResultStatus>
    <ReturnCode>1</ReturnCode>
    <ResultMessage>
    <MessageCode>SLFC0999</MessageCode>
    <MessageSeverity>E</MessageSeverity>
    <MessageInformation>XML_PARSE_EXCEPTION_ERROR</MessageInformation>
    <MessageDescription>com.slfc.framework.service.ServiceFrameworkException: ServiceMessageFactory.createServiceRequest .. Unmarshalling ServiceRequest .. org.xml.sax.SAXException: Parsing Error : Premature end of file.
    Line : -1
    Column : -1</MessageDescription>
    </ResultMessage>
    </ResultStatus>
    </ServiceResult>

     

    Thanks,

    John



  • 2.  Re: Live recording Raw Traffic file has Escaped strings in Response Body

    Broadcom Employee
    Posted Jul 13, 2018 10:38 AM

    I believe that would be expected behaviour. It's invalid in XML to have multiple stanzas, so your request stanza needs to be quoted.

     

    If your response included a stanza rather than a SAXException, I would expect that to be quoted too.



  • 3.  Re: Live recording Raw Traffic file has Escaped strings in Response Body

    Posted Jul 13, 2018 02:15 PM

    Hi Rick, This's GET request, so there's so request payload, I'm not getting what's being referred as request stanza.

     

    The VSI response is below, with Unescape Characters...

    ?xml version="1.0" encoding="UTF-8"?>
    <ServiceResult version="2.0"><ResultHeader><ServiceName>ServiceFrameworkException</ServiceName></ResultHeader><ResultBody/><ResultStatus><ReturnCode>1</ReturnCode><ResultMessage><MessageCode>SLFC0999</MessageCode><MessageSeverity>E</MessageSeverity><MessageInformation>XML_PARSE_EXCEPTION_ERROR</MessageInformation><MessageDescription>com.slfc.framework.service.ServiceFrameworkException: ServiceMessageFactory.createServiceRequest .. Unmarshalling ServiceRequest .. org.xml.sax.SAXException: Parsing Error : Premature end of file.
    Line : -1
    Column : -1
    </MessageDescription></ResultMessage></ResultStatus></ServiceResult>

     

    The same response from raw traffic export xml is below, Escape characters..

    <body charset="UTF-8">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ServiceResult version="2.0"&gt;&lt;ResultHeader&gt;&lt;ServiceName&gt;ServiceFrameworkException&lt;/ServiceName&gt;&lt;/ResultHeader&gt;&lt;ResultBody/&gt;&lt;ResultStatus&gt;&lt;ReturnCode&gt;1&lt;/ReturnCode&gt;&lt;ResultMessage&gt;&lt;MessageCode&gt;SLFC0999&lt;/MessageCode&gt;&lt;MessageSeverity&gt;E&lt;/MessageSeverity&gt;&lt;MessageInformation&gt;XML_PARSE_EXCEPTION_ERROR&lt;/MessageInformation&gt;&lt;MessageDescription&gt;com.slfc.framework.service.ServiceFrameworkException: ServiceMessageFactory.createServiceRequest .. Unmarshalling ServiceRequest .. org.xml.sax.SAXException: Parsing Error : Premature end of file.
    Line : -1
    Column : -1
    &lt;/MessageDescription&gt;&lt;/ResultMessage&gt;&lt;/ResultStatus&gt;&lt;/ServiceResult&gt;</body>

     

    I can see response with stanza (xml tags) in SOAP response and VSI but not in raw traffic export.

     

    Thanks,

    John



  • 4.  Re: Live recording Raw Traffic file has Escaped strings in Response Body
    Best Answer

    Broadcom Employee
    Posted Jul 13, 2018 09:06 PM

    Hi John --

     

    I don't understand the problem, I'm afraid.

     

    If the problem is that the XML in the raw traffic is that it's escaped, that is not a problem. It needs to be escaped because it would be invalid XML if the exact string <?xml version="1.0" encoding="UTF-8"?> is embedded inside the message, rather than as a top element (and it's invalid to have more than one of them in an XML file). Look at the top of your raw traffic XML, and you should see that it starts with that declaration.

     

    So, I would always expect a raw recorded message to be escaped in a raw traffic file, starting with &lt;?xml version="1.0" encoding="UTF-8"?&gt;, and I would expect DevTest to automatically translate the whole escaped message into XML in a VSI, which is what I believe I'm seeing in your VSI extract.

     

    The problem that I think I see in your extracts is that a SAX parser has choked during the recording process, on some invalid XML presented to it, and so DevTest has stored what it can, and has presented that to you. It might be that it was the SAX parser in DevTest that saw invalid XML, but it looks to me that the real back-end uses the SAX parser which responded with an error code and a MessageDescription including the embedded parser error and DevTest correctly recorded that.

     

     

    Rick



  • 5.  Re: Live recording Raw Traffic file has Escaped strings in Response Body

    Posted Jul 16, 2018 12:05 PM

    Thank you, Rick. I was wondering, why the message in the raw body is not in proper format. Thanks for the explanation. The reason I ask is, in future if I need to refer/copy the response message from the raw traffic, thought it's not` 



  • 6.  Re: Live recording Raw Traffic file has Escaped strings in Response Body

    Posted Jul 16, 2018 12:05 PM

    thought it's not with escape chars.