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

My SOAP call returns null or empty response. I followed all steps from PTC white paper.

SOLVED
Highlighted
Newbie

My SOAP call returns null or empty response. I followed all steps from PTC white paper.

Here is my code for calling external SOAP service. I included first getXML snippet then createInfoTableFromDataShape then createInfoTableEntryFromDataShape then addRow()

 

var params = {
proxyScheme: undefined /* STRING */,
headers: undefined /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: "http://www.webservicex.net/uszip.asmx/GetInfoByAreaCode?USAreaCode=209" /* STRING */,
timeout: undefined /* NUMBER */,
proxyPort: undefined /* INTEGER */,
password: undefined /* STRING */,
domain: undefined /* STRING */,
username: undefined /* STRING */
};

// result: XML
var xmlPage = Resources["ContentLoaderFunctions"].GetXML(params);

var params2 = {
infoTableName : "InfoTable",
dataShapeName : "AreaCode_SOAP"
};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(AreaCode_SOAP)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params2);

for each(var item in xmlPage.channel.item){
    // AreaCode_SOAP entry object
var newEntry = new Object();
newEntry.TIME_ZONE = item.TIME_ZONE; // STRING
newEntry.CITY = item.CITY; // STRING
newEntry.STATE = item.STATE; // STRING
newEntry.AREA_CODE = item.AREA_CODE; // STRING
   
   result.AddRow(yourRowObjectHere);
}

 

 

 

 

My result is emty infotable. Can you please help me on this issue.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Rishikesh Salunkhe​,

Is this issue resolved? If yes, please mark correct and helpful answers to help other members know that this Thread has a solution.

View solution in original post

9 REPLIES 9
Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Rishikesh Salunkhe​,

It seems that the xml received contains the <!DOCTYPE> tag.

You must be getting following error in script logs while running this service:

Execution error in service script [Thing1 Readxml] : Wrapped org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true. Cause: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.

In order to prevent XML External Entity (XXE) attacks, ThingWorx explicitly restricts the use of the <!DOCTYPE> tag in XML processing calls.

Any XML document retrieved by the ContentLoaderFunctions.GetXML() service must not contain a <!DOCTYPE> tag.


I hope it helps.

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Ankit,

Thanks for your valuable reply but I called some other service which does not included >!DOCTYPE> tag, but it also returns empty response. Can I add WSDL description in above snippet? I paste my updated code with WSDL. I also try below code without WSDL. But doesn't work for me. Please add your comments.

var content = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hs="http://www.holidaywebservice.com/HolidayService_v2/">\
<soapenv:Body>\
<hs:GetHolidaysAvailable>\
<hs:countryCode>UnitedStates</hs:countryCode>\
</hs:GetHolidaysAvailable>\
</soapenv:Body>\
</soapenv:Envelope>';


var params = {
proxyScheme: undefined /* STRING */,
headers: undefined /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: "http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl" /* STRING */,
timeout: undefined /* NUMBER */,
proxyPort: undefined /* INTEGER */,
password: undefined /* STRING */,
domain: undefined /* STRING */,
username: undefined /* STRING */
};

// result: XML
var result = Resources["ContentLoaderFunctions"].GetXML(params);

//var result = xmlPage.*::soapenv.GetHolidaysAvailable.countryCode;

var params2 = {
infoTableName : "InfoTable",
dataShapeName : "SOAP_DataShape"
};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(SOAP_DataShape)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params2);

for each(var tag in xmlPage.channel.item){
    // SOAP_DataShape entry object
var newEntry = new Object();
newEntry.Description = item.Description; // STRING
newEntry.HolidayCode = item.HolidayCode; // STRING
    result.AddRow(yourRowObjectHere);
}

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Rishikesh Salunkhe​,

I tried this a bit and i was able to read some data using following code. Please make changes as per your requirement.

StringDataShape is a datashape with a String field named StringValue

var params = {

proxyScheme: undefined /* STRING */,

headers: undefined /* JSON */,

ignoreSSLErrors: undefined /* BOOLEAN */,

useNTLM: undefined /* BOOLEAN */,

workstation: undefined /* STRING */,

useProxy: undefined /* BOOLEAN */,

withCookies: undefined /* BOOLEAN */,

proxyHost: undefined /* STRING */,

url: "http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl" /* STRING */,

timeout: undefined /* NUMBER */,

proxyPort: undefined /* INTEGER */,

password: undefined /* STRING */,

domain: undefined /* STRING */,

username: undefined /* STRING */

};

// result: XML

var resultXML = Resources["ContentLoaderFunctions"].GetXML(params);

var params = {

  infoTableName : "InfoTable",

  dataShapeName : "StringDataShape"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(StringDataShape)

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var newRow = new Object();

for each (var tag in resultXML.*::portType.*::operation.*::documentation) {

    newRow.StringValue = tag;

    result.AddRow(newRow);

}

I hope it helps.

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Ankit Gupta​,

Thanks for your valuable reply. Your code is very helpful. But data comes with xml tag. Following is my code. I created SOAP_DataShape and create infotable from that datashape. In for each I parse xml according to tags. You can see xml directly hitting url in browser.

 

 

var params = {

 

proxyScheme: undefined /* STRING */,

 

headers: undefined /* JSON */,

 

ignoreSSLErrors: undefined /* BOOLEAN */,

 

useNTLM: undefined /* BOOLEAN */,

 

workstation: undefined /* STRING */,

 

useProxy: undefined /* BOOLEAN */,

 

withCookies: undefined /* BOOLEAN */,

 

proxyHost: undefined /* STRING */,

 

url: "http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx/GetCountriesAvailable" /* STRING */,

 

timeout: undefined /* NUMBER */,

 

proxyPort: undefined /* INTEGER */,

 

password: undefined /* STRING */,

 

domain: undefined /* STRING */,

 

username: undefined /* STRING */

 

};

 

// result: XML

 

var resultXML = Resources["ContentLoaderFunctions"].GetXML(params);

 

 

var params = {

 

  infoTableName : "InfoTable",

 

  dataShapeName : "SOAP_DataShape"

 

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(StringDataShape)

 

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

for each (var tag in resultXML.*::CountryCode.*::Code) {

 

    var newRow = new Object();

 

    newRow.HolidayCode = tag;

 

    newRow.Description=tag;

 

    result.AddRow(newRow);

 

}

 

Your reply is valuable for me.

 

 

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Rishikesh Salunkhe​,

Try this:

var params1 = {

proxyScheme: undefined /* STRING */,

headers: undefined /* JSON */,

ignoreSSLErrors: undefined /* BOOLEAN */,

useNTLM: undefined /* BOOLEAN */,

workstation: undefined /* STRING */,

useProxy: undefined /* BOOLEAN */,

withCookies: undefined /* BOOLEAN */,

proxyHost: undefined /* STRING */,

url: "http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx/GetCountriesAvailable" /* STRING */,

timeout: undefined /* NUMBER */,

proxyPort: undefined /* INTEGER */,

password: undefined /* STRING */,

domain: undefined /* STRING */,

username: undefined /* STRING */

};

// result: XML

var resultXML = Resources["ContentLoaderFunctions"].GetXML(params1);

var params2 = {

  infoTableName : "InfoTable",

  dataShapeName : "SOAP_DataShape"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(StringDataShape)

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params2);

for each (var tag in resultXML.*::CountryCode) {

    var newRow = new Object();

    newRow.HolidayCode = tag.*::Code;

    newRow.Description=tag.*::Description;

    result.AddRow(newRow);

}

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Here is my output.

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Rishikesh Salunkhe​,

Is this issue resolved? If yes, please mark correct and helpful answers to help other members know that this Thread has a solution.

View solution in original post

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Ankit Gupta​,

Can we consume xml from localhost. i.e if our Thingworx application and source machine in same network, in such case can we consume XML from localhost?

I am trying to call my local xml file on at "http://localhost:8087/ws/hello?wsdl" in same network but following error occurred:

Wrapped org.apache.http.conn.HttpHostConnectException: Connect to localhost:8087 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) Cause: Connect to localhost:8087 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

Highlighted

Re: My SOAP call returns null or emty response. I followed all steps from PTC white paper.

Hi Ankit Gupta​,

Can we consume xml from localhost. i.e if our Thingworx application and source machine in same network, in such case can we consume XML from localhost?

I am trying to call my local xml file on at "http://localhost:8087/ws/hello?wsdl" in same network but following error occurred:

Wrapped org.apache.http.conn.HttpHostConnectException: Connect to localhost:8087 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) Cause: Connect to localhost:8087 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!