Skip to main content
13-Aquamarine
August 14, 2024
Solved

Odata Client Generator for the WRS

  • August 14, 2024
  • 2 replies
  • 1749 views

Version: Windchill 12.1

 

Use Case: Consume the Windchill Rest APIs externally


Description:

I am looking for a client generator based on the EDM of the Windchill Rest Services. The Apache Olingo client has a pojogen feature, it is not working for the WRS EDM as there are some inconsistency in it.

We have one from Microsoft but not based on JAVA. Also SAP is providing one which i have not used it.

Has anyone tried create (or) use the client generator for the WRS ?

Best answer by BjoernRueegg

Since PTC also uses swagger you can generate the openAPI. There is a utility to do this. 

This would produce the openAPI catalog for the ProdMgmt V7 domain

https://<WINC_SERVER>/Windchill/netmarkets/html/wrs/odata-to-swagger.jsp?v=7&d=ProdMgmt

 

this will produce the following output:


{
 "openapi" : "3.0.1",
 "info" : {
 "title" : "PTC.ProdMgmt",
 "description" : "PTC Product Management Domain",
 "version" : "7"
 },
 "servers" : [ {
 "url" : "https://<WINC_SERVER>/Windchill/servlet/odata/v7/ProdMgmt"
 } ],
 "tags" : [ {
 "name" : "Service Endpoints"
 } ],
 "paths" : {
 "" : { },
 "/CheckInParts" : {
 "post" : {
 "tags" : [ "Service Endpoints" ],
 "summary" : "Execute CheckInParts",
 "description" : "Execute CheckInParts",
 "operationId" : "Action_CheckInParts",
 "parameters" : [ {
 "name" : "$select",
 "in" : "query",
 "schema" : {
 "type" : "string"
 }
 }, {
 "name" : "$filter",
 "in" : "query",
 "schema" : {
 "type" : "string"
 }
 },
....

 With this you are able to generate all the classes.

My problem is, especially for the ProdMgmt Domain with MPMLink installed, that the classes are so long, that the IDE has some problems with it. Also the security is missing. You need to add following to the json if you are using basic auth:

"securityDefinitions": {
 "basicAuth": {
 "type": "basic"
 }
 },
 "security": [
 {
 "basicAuth": []
 }
 ],

Please provide afterwards your experience. It would help me also to figure out if my experience matches with yours. 

2 replies

14-Alexandrite
August 15, 2024

Swagger Codegen can generate clients SDK in many languages, but it expects a file written in OpenAPI spec (the file that generates the doc Swagger UI), not sure how to extract it from Windchill!

 

tarikwifakp_0-1723720775490.png

 

Similar questions exists: Article - CS395108 - Is it possible to import all Endpoints into Postman in Windchill REST Services (ptc.com)

17-Peridot
August 15, 2024

Since PTC also uses swagger you can generate the openAPI. There is a utility to do this. 

This would produce the openAPI catalog for the ProdMgmt V7 domain

https://<WINC_SERVER>/Windchill/netmarkets/html/wrs/odata-to-swagger.jsp?v=7&d=ProdMgmt

 

this will produce the following output:


{
 "openapi" : "3.0.1",
 "info" : {
 "title" : "PTC.ProdMgmt",
 "description" : "PTC Product Management Domain",
 "version" : "7"
 },
 "servers" : [ {
 "url" : "https://<WINC_SERVER>/Windchill/servlet/odata/v7/ProdMgmt"
 } ],
 "tags" : [ {
 "name" : "Service Endpoints"
 } ],
 "paths" : {
 "" : { },
 "/CheckInParts" : {
 "post" : {
 "tags" : [ "Service Endpoints" ],
 "summary" : "Execute CheckInParts",
 "description" : "Execute CheckInParts",
 "operationId" : "Action_CheckInParts",
 "parameters" : [ {
 "name" : "$select",
 "in" : "query",
 "schema" : {
 "type" : "string"
 }
 }, {
 "name" : "$filter",
 "in" : "query",
 "schema" : {
 "type" : "string"
 }
 },
....

 With this you are able to generate all the classes.

My problem is, especially for the ProdMgmt Domain with MPMLink installed, that the classes are so long, that the IDE has some problems with it. Also the security is missing. You need to add following to the json if you are using basic auth:

"securityDefinitions": {
 "basicAuth": {
 "type": "basic"
 }
 },
 "security": [
 {
 "basicAuth": []
 }
 ],

Please provide afterwards your experience. It would help me also to figure out if my experience matches with yours. 

tm-413-AquamarineAuthor
13-Aquamarine
August 15, 2024

Hi Bjoern,

Thanks for your response. Parallelly i was trying to change the Apache Olingo Pojogen based on the WRS metdata. I am now able to generate the client Pojos for the EDM and use the same in the Apache Olingo client (Still in prototype not sure whether it is working in all use cases). The problem is the olingo client is not properly documented, so we need to check the source code/test cases for the references. I will surely try this as well and get back to you on my experience.

 

Thanks,

Thiaga

17-Peridot
August 16, 2024

@tm-4 

I also tried that once with the OData POJO generator, but it's difficult since it's very poorly documented. I always got some errors because a type could not be found. The OpenAPI solution worked for me much better.