首页 > 解决方案 > 用于在 Windchill 中创建新工作区的 Rest API

问题描述

我想在 Windchill 中创建一个工作区,从我们的 Web 应用程序调用 Rest API。但在任何 Windchill Rest API 文档中都找不到此类 API 端点。

是否可以使用 rest API 创建工作区,如果没有,是否有任何替代方法可以实现它。

标签: ptc-windchill

解决方案


您在哪个 Windchill 版本上工作?

当我在 REST 服务中找不到标准端点时,我自己编写它们。从 Windchill 11.1 开始,我使用 Spring 来创建它们。为此,您需要在 codebase/WEB-INF/web.xml 中输入一个条目,例如:

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

在同一个文件夹中,您需要一个名为 Servletname-servlet 的文件,例如 ConnectorName-servlet.xml,其内容如下:

<?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 />

在此之后,您可以在组件扫描中定义的包中创建一个 Spring RestController 类。


推荐阅读