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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Odata Client Generator for the WRS

tm-4
11-Garnet

Odata Client Generator for the WRS

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 ?

6 REPLIES 6

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)

BjoernRueegg
17-Peridot
(To:tm-4)

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. 

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

BjoernRueegg
17-Peridot
(To:tm-4)

@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. 

Hi Bjoern,

I was able to check client code generated from the openapi generator. I tried to fix some initial glitches like , the odata response is having "@PTC.AppliedContainerContext.LocalTimeZone", but the openapi spec generated from the WRS is not having any reference to this and it is getting failed. 

After fixing the initial issues i was able to do the get request, but  I am not able to create a part with subtype using the models it has generated.

 

Example:

The codegen generates a service method

"public okhttp3.Call postPartCall(String CSRF_NONCE, CreatePTCProdMgmtPart body, final ApiCallback _callback) throws ApiException" to create the WTPart. But the parameter is constrained to pass only the parent Part model and not the subtype. We have defined attributes at the subtype level, so as expected the getters and setters for these attributes are not available at the parent model level. 

 

Have you encountered this issue ?

BjoernRueegg
17-Peridot
(To:tm-4)

@tm-4 

Yes I did but couldn't find any "fast" solution, so I added a jacksons  @JsonAnySetter to the class to have a map to store additional properties. This is bad, since I need to modify the generated code. This code never went to production. It was a simple test.

Another way could be, to create an entity.json file for this type. See https://support.ptc.com/help/windchill/r13.0.2.0/en/index.html#page/Windchill_Help_Center/WCRESTFramework/WCCG_RESTAPIsCustomizingExamplesSoftType.html%23

 

Announcements

Top Tags