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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Create a custom REST service based on SOAP service

BRAHIM
6-Contributor

Create a custom REST service based on SOAP service

I'm looking to create a custom REST service that performs the same function as my current SOAP service in Windchill 12, which retrieves the Windchill version. Can anyone provide guidance on how to achieve this.

 

Here are some details :

 

  • This link below shows the steps to create a custom REST service in Windchill.

https://support.ptc.com/help/windchill_rest_services/r2.5/en/#page/windchill_rest_services/WCCG_RESTAPIsCustomizingExamplesCreateDomain.html#

 

  • My code is a JSP-based SOAP service that retrieves the version of Windchill installed. It imports necessary Java classes, creates an output group, and attempts to fetch the Windchill version using WindchillVersion.getInstalledAssemblyReleaseIdFor("wnc"). If successful, it adds the version string to an element and then to the output group. The final part uses an InfoEngine webject to return this group as the SOAP response. This service ensures that the Windchill version is retrieved and returned in a structured format.

I attempted to create one REST service and tested it using Postman, but I encountered an error. The error message stated :

"Failed to get the search results using Windchill search service: Info resource not found for wt.util.version.WindchillVersion."

BRAHIM_0-1721922023376.png

This indicates that the REST service was unable to locate the necessary Windchill version resource, causing the operation to fail.

5 REPLIES 5
HelesicPetr
22-Sapphire I
(To:BRAHIM)

Hi @BRAHIM 

My first thought is if your JS custom function contains correct import with the WindchillVersion class

 

var WindchillVersion = Java.type('wt.util.version.WindchillVersion');

 

 PetrH

BRAHIM
6-Contributor
(To:HelesicPetr)

Hi @HelesicPetr 

Thank you for your response. I have already ensured that my JS custom function imports the correct WindchillVersion class. Below is my js code :

BRAHIM_0-1721982301091.png

I doubt this file does not contains the correct type !!

BRAHIM_1-1721982468395.png

 

HelesicPetr
22-Sapphire I
(To:BRAHIM)

Hi @BRAHIM 

Check the methodserver log. There could be useful information where the error is thrown, on which row. 

Also check if the class and method really exists in your Windchill installation.

There could be a change sure the case can be anything

PetrH. 

There is an OOTB endpoint that outputs Windchill Version:

 

<hostname>Windchill/servlet/odata/v4/PTC/GetWindchillVersion()

 

image.png

@BRAHIM you are using JS Hooks in OData which has a different purpose, I didn't understand what you want to achieve!

 

+ There is an info engine domain in OData from which you can invoke tasks, please don't use it unless necessarily: /Windchill/servlet/odata/v1/IE

Top Tags