cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

when parse xml with postxml(),how to make the content accept variable?

向郭
7-Bedrock

when parse xml with postxml(),how to make the content accept variable?

hello,everyone.

I encounter one question when parse xml, the webservice need input parameter, one is current system time,the format like "2017-01-18T00:02:00", the other one is two minutes before the current system time,like "2017-01-18T00:00:00".

how should i make the input variable into the content?

var url =  "https://companyurl.com/eProxy/service/MOSC_INI_SNA_SERVICE_Router";

var content =

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://www.informatica.com/dis/ws/"  targetNamespace="http://www.informatica.com/dis/ws/">

  <soapenv:Body>

      <ws:Operation>

          <ws:SNA_SERVICE_INPUT>

            <ws:SGTIN>00300744339023</ws:SGTIN>

            <ws:LOT_NUMBER>23456AA</ws:LOT_NUMBER>

            <ws:EXPIRY_DATE>170630</ws:EXPIRY_DATE> // I hope here turn to some variable,for example,abc,out the content define the variable abc=170630;

            <ws:USER_ID></ws:USER_ID>

            <ws:USER_DEVICE_ID>65787656576787</ws:USER_DEVICE_ID>

            <ws:USER_GPS_LATITUDE>121</ws:USER_GPS_LATITUDE>

            <ws:USER_GPS_LONGITUDE>654</ws:USER_GPS_LONGITUDE>

            <ws:USER_GPS_ALTITUDE>56</ws:USER_GPS_ALTITUDE>

        </ws:SNA_SERVICE_INPUT>

      </ws:Operation>

  </soapenv:Body>

</soapenv:Envelope>

var headers={ "Content-Type": "text/xml","SOAPAction":"https://companyurl.com/eProxy/service/MOSC_INI_SNA_SERVICE_Router"};

var params = {

timeout : 60,

headers : headers,

ignoreSSLErrors : true,

url : url,

content : content

};

var returnContent = Resources['ContentLoaderFunctions'].PostXML(params);

2 REPLIES 2

Hi, Xiang.  I was facing the same, here is what i did:

var content = "Here goes the XML content";

var newXML = new XML(content);

I try the method ,while the output remind me :Cannot set property "matolcode" of undefined to"'111111111'".

but always ,thanks you.

Announcements


Top Tags