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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Executing a service by "Using a Custom Reports from Windchill" throws error in ThingWorx

vshanmugavelayu
11-Garnet

Executing a service by "Using a Custom Reports from Windchill" throws error in ThingWorx

I created a new service to execute Windchill Report Manager Report and fetch the result in ThingWorx. But when I execute the service, I get the following error. All out of the box services in "ptc-windchill-demo-thing" works without any issue. I do not see any error in Windchill logs as well. pls help.

Error Message:

Wrapped com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException - with linked exception: [com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character (NULL, unicode 0) encountered: not valid in any content at [row,col {unknown-source}]: [42,207]] Cause: Failed to read a response: javax.xml.bind.UnmarshalException - with linked exception: [com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character (NULL, unicode 0) encountered: not valid in any content at [row,col {unknown-source}]: [42,207]]

ACCEPTED SOLUTION
13 REPLIES 13

The error is caused by an illegal character in the response returned and is related to the source data. The XML library is halting its interpretation of the data because of the invalid data. The problem that causes these XmlExceptions is that the data being read or loaded contains characters that are illegal according to the XML specifications. Almost always, these characters are in the ASCII control character range (for example, characters like null, bell, backspace, etc). They’re illegal characters that should be removed, usually having found their way into the data from file format conversions, like when someone tries to create an XML file from Excel data, or export their data to XML from a format that may be stored as binary.

The above exception seems to occur because of string containing zeros in the last chunk. In the last continous zeros make null[as in ascii/utf-8] so it is throwing and exception . To troubleshoot I'd recommend the following:

  • Copy into a text editor
  • Enable the display of all extended characters
  • Review the data and determine where the malformed data is and remove it from the source data

Polina, Thank you so much for your reply. This really is helpful to understand why I get this error. My question with regards to your reply is


1. I am able to run the exact Windchill - Report Manager report with same exact input criteria and i get the result with no issue. I also did not see any error in Windchill error log. Does this fact change any of your rationale for this error?

2. The troubleshoot steps you mentioned is flying on top of my head . I could not understand. What should I copy in to the text editor? any help on how to copy will also help.

Thanks again for your help in this issue!

I'm honestly not too familiar with the nuances of Windchill, I'm just analyzing this particular error in general, from the XML perspective. I apologize for being unclear. Perhaps, Windchill Report Manager is not manipulating  XML and that's why the problem doesn't occur. I was thinking of copying the source data and, again judging by the error, looking at this line especially - [row,col {unknown-source}]: [42,207] to check for funky characters. I hope this helps!

No worries, and thanks for the clarifications!

Do you know how to get the XML response that ThingWorx is reading while throwing this error?

Perhaps, you could try fiddler Fiddler - Free Web Debugging Proxy - Telerik to see what is being returned? There also should be an entry in Apache access.log for Windchill - the URL can be used to call in the browser and should give the xml source.

Also, you open your browser tools (f12 in chrome) and watch activity in network and console tabs - are you able to see any errors that might give more details?

posipova
20-Turquoise
(To:posipova)

In addition, may I see your custom service (I've just noticed you mentioned it's not an out of the box one)?

I just tried with Fiddler web debugger and I do not see any XML response (pls refer to 1st image). I also tried using the URL on Chrome - Postman app with both request type as POST and GET and i could not see any XML response (refer 2nd & 3rd image).

Below is the service I have created & calling: it takes a Document Number in windchill as input.

//Fetch container

var containers = Things["ptc-windchill-demo-thing"].Query({

criteria:"name = 'Site'",

dataShape: 'WCContainerShape.wt.inf.container.WTContainer',

type: 'WCTYPE|wt.inf.container.WTContainer'

});

if(containers.getRowCount() > 0) {

var containerUfid = containers.getRow(0).ufid;

logger.debug("Using container UFID " + containerUfid);

}

//Fetch Report templates

var reportTemplates = Things["ptc-windchill-demo-thing"].Query({

criteria: "name = 'WTDOCSearch'",

dataShape: 'ReportTemplateShape.wt.query.template.ReportTemplate',

type: 'WCTYPE|wt.query.template.ReportTemplate',

containerUfid: containerUfid

});

if(reportTemplates.getRowCount() > 0) {

   var reportTemplateUfid = reportTemplates.getRow(0).ufid;

logger.debug('Using report template UFID ' + reportTemplateUfid);

}

//Execute Report

var properties = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({

infoTableName : "InfoTable",

dataShapeName : "IEProperty"

});

properties.AddRow({

name : 'object_ref',

value: reportTemplateUfid

});

properties.AddRow({

name : 'input',

value: "number='" + Number + "'"

});

var result = me.ExecuteTask({

params: properties,

dataShape: 'strykerDocumentSearchDataShape',

uri: 'com/ptc/windchill/enterprise/report/ExecuteReportTemplate.xml',

objects: undefined

});

1.JPG

2.JPG

3.JPG

Most of the services on the WindchillConnector are just using the out of the box Windchill SOAP Web Service (com.ptc.windchill.ws aka GWS).

I recommend you to test this Web Service outside ThingWorx, for example you can use SoapUI as SOAP client.

1. Create a SOAP Project using <windchill_app_url>/servlet/TwxIEWebService?wsdl as WSDL.

2. Invoke the ExecuteReportTemplate.xml task using the ExecuteTask service (you have to specify a wnc authentication):

Below a copy of the above request (the oid of my report is wt.query.template.ReportTemplate:148161 -  this report does not need inputs):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.windchill.ptc.com.service.jws.ptc.com/">

   <soapenv:Header/>

   <soapenv:Body>

      <ws:ExecuteTask>

         <!--Optional:-->

         <uri>com/ptc/windchill/enterprise/report/ExecuteReportTemplate.xml</uri>

         <!--Zero or more repetitions:-->

         <params>

            <!--Optional:-->

            <name>object_ref</name>

            <!--Optional:-->

            <value>OR:wt.query.template.ReportTemplate:148161</value>

         </params>

         <!--Zero or more repetitions:-->

      </ws:ExecuteTask>

   </soapenv:Body>

</soapenv:Envelope>

3. Check if you see something abnormal in the SOAP response : can be an error, or an attribute that contains a blob or XML, special characters ...

Hello Steve, Thanks for your help here. I followed the exact steps you mentioned above and I did not notice any error. While I do the same on Thing-Service, the error repeats

SoapUI.JPG

TWX Error.JPG

.By the way thanks for detailed steps.

Hi Varunraj, I see that you have opened a case, can you attach the full SOAPUI response in text format to it ?

I just attached the SoapUI Output to my case.

Dear Stephane, Thanks you so much for your help today. Really appreciate all your support

Announcements


Top Tags