Windchill Customization Using Windchill REST Services (WRS)
The Windchill REST Services (WRS) API provides a flexible way for customers to customize and interact with Windchill. The WRS API operates over HTTP, allowing for a wide range of requests and responses.
A new utility class WRSCaller has been introduced for use in customizations.
WRSCaller is a Java wrapper for calling any WRS endpoint available in your Windchill release. This wrapper serves as an HTTP client and automatically handles various functionalities, such as authentication and nonce tokens, directly within the class
WRS calls made through WRSCaller operate as if they were triggered from a standard HTTP client:
• A parent Transaction encapsulating a WRSCaller invocation cannot roll back a data modification made by WRSCaller (POST, PUT, PATCH, DELETE).
• The access controls of the current principal are honored.
|
Do not use WRSCaller when creating custom data utilities, event listeners or when customizing WRS, such as creating new domains or extending PTC domains.
|
Each HTTP verb (GET, POST, PATCH, PUT, DELETE) has its own method signature in
WRSCaller and will return the response in a JSON format. For POST, PATCH and PUT, the request body is in the JSON format. Additionally, batch requests (
$batch) and schema requests (
$metadata) have their own methods (
batch() and
edm(), respectively). The
edm() method returns a response in the XML format. The
batch() method requires the batch body to adhere to the
OData specifications, specifically the multipart/mixed format.
HTTP responses are encapsulated in an ODataSerializableResponse object. This object holds the response status code (for example, HTTP 200, HTTP 404, and so on) that the client can use to handle errors or successes. The ODataSerializableResponse object has the following methods to obtain the response body and response headers:
• getContent()—Returns the response body in the form of a byte array. The byte array can be transformed into various formats such as String or binary, depending on the value of the response header Content-Type.
• getHeader(<Header_Name>)—Retrieves the header value for the header name passed as a parameter.
• getSkipToken()—Returns the $skiptoken value if it is present in the response.
• getContentAsJSON()—Returns the response as an org.json.JSONObject. If the content type of the response is not JSON, it generates an UnsupportedOperationException.
Parent topic