Forum Discussion

Apoorva6's avatar
Apoorva6
Frequent Contributor
8 years ago

How to load and get Mock response with CDATA string (CDATA string to be loaded from separate file)

Hi All.

 

Below is the sample MOCK response which has a CDATA string. I want to load that sting from external file named TEMP.xml at below path. when I submit request, its not loading CDATA from the file.
Can anyone help ? . My CDATA content keeps on changing and hence I want to load via separate file.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <dis:retrieveSiteIdSiteNameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:dis="http://edb.mt.com/nbipvpn/dispatcher">
         <result xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><![CDATA[${("C:/Users/ADMIN/Desktop/doc/MOCK/GDB/BP3/SiteService/TEMP.xml")}]]></result>
      </dis:retrieveSiteIdSiteNameResponse>
   </soapenv:Body>
</soapenv:Envelope>

I am getting only below response

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <dis:retrieveSiteIdSiteNameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:dis="http://edb.mt.com/nbipvpn/dispatcher">
         <result xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
      </dis:retrieveSiteIdSiteNameResponse>
   </soapenv:Body>
</soapenv:Envelope>

3 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    Apoorva6, you can insert a file content into a message request with the following code:

     

     

    ${=new File("C:/Users/MyUser/Desktop/testFile.txt").text}

     

     

    In your case the request might look like this:

     

     

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header/>
       <soapenv:Body>
          <dis:retrieveSiteIdSiteNameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:dis="http://edb.mt.com/nbipvpn/dispatcher">
             <result xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
             <![CDATA[${=new File("C:/Users/MyUser/Desktop/testFile.txt").text}]]>
          </dis:retrieveSiteIdSiteNameResponse>
       </soapenv:Body>
    </soapenv:Envelope>

     

     

    Karel

     

    • nmrao's avatar
      nmrao
      Champion Level 3
      Do you want to send the file path as part of response?