Search code examples
ptc-windchill

Rest API for creating new workspace in Windchill


I want to create a workspace in Windchill calling Rest API from our web application. But no where to find such API end point in any of the Windchill Rest API documentation.

Is it possible to create workspace using rest API, if not is there any alternative way to achieve it.


Solution

  • On which Windchill version do you work?

    When I don't find standard endpoints in the REST Services, I write them myself. Since Windchill 11.1 I use Spring to create them. For that you need an entry in codebase/WEB-INF/web.xml like:

    <servlet>
        <servlet-name>ConnectorName</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>ConnectorName</servlet-name>
        <url-pattern>/servlet/connector/*</url-pattern>
    </servlet-mapping>
    

    In the same folder you need a file named like the Servletname-servlet like ConnectorName-servlet.xml with following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop = "http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd ">
    <context:component-scan base-package="packagename" />
    <mvc:annotation-driven />
    

    After this you can create a Spring RestController Class in the package defined above in component-scan.