Hi rzemmali,
if you follow PTC's guideline to create a Java based webservice, they say that you need to launch a command to create the WS related files. For example:
<WT_HOME> > ant -Dproject.dir=E:\ptc\Windchill_11.1\Windchill\prog_examples\jws\MyProject -Dservlet.name=MyWService -Dsecurity.policy=webServerAuthenticated -Dmain.class=org.myorg.MyClient -Dservice.type=java -Dservice.class=org.myorg.MyWService -f bin\adminTools\WebServices\new-project.xml create
Note: this command will create a webserver authenticated WS. So, you will need to pass user/password from the client to invoke it. You can create a WS that will be authenticated with keystores if you want to avoid user/pass
Basically, this command will create different files inside the folder E:\ptc\Windchill_11\Windchill\prog_examples\jws\MyProject:
- %WT_HOME%\prog_examples\jws\MyProject\src\build.xml --> ant script to compile and deploy the WS
- %WT_HOME%\prog_examples\jws\MyProject\src\org\myorg\MyWService.java --> main class of your WS
- %WT_HOME%\prog_examples\jws\MyProject\src_client\build.xml --> ant script to compile and generate a java client for tyour WS
- %WT_HOME%\prog_examples\jws\MyProject\src_client\org\myorg\MyClient.java --> main class for the client of the WS
And you should write the code in the java file generated. Anyway, if you already have you WS main java class and you want to use it, you just need to create the ant script to compile and deploy it. So, for example, if you have created in you typical src folder a class org.myorg.MyWSservice.java file, you need to create the ant script inside your src folder. You can call it, for example, MyWSservice.xml and the contents should be similar to:
<?xml version="1.0"?>
<!DOCTYPE project [
<!ENTITY ws_env SYSTEM "..\Windchill\bin\adminTools\WebServices\common\common-env.jws_xml">
<!ENTITY ws_server SYSTEM "..\Windchill\bin\adminTools\WebServices\common\common-server.jws_xml">
]>
<project name="MyWService" default="all">
<property name="webservice.class" value="org.myorg.MyWService" />
<property name="security.policy" value="webServerAuthenticated" />
&ws_env;
&ws_server;
</project>
NOTE: if you copy the content, please take care with the paths to the xml files referenced at the beginning of it. It should be the relative path from the location where the xml file is stored.
Once you have the ant script you can call it with the command:
<WT_HOME> > ant -f src/MyWService.xml
This command should compile and deploy your webservice, generating:
- A new jar file in <WT_HOME>/codebase/WEB-INF/lib with the necessary compiled files of the WS
- A block of code added to the file <WT_HOME>/codebase/WEB-INF/sun-jaxws.xml referencing the new WS available
Restarting Windchill will do your WS available and you can check it accessing to the url:
http://<HOST_NAME>/Windchill/servlet/MyWService?wsdl
If you have problems editing manually the xml file or compilation errors, use the first method to let Windchill create all the necessary files and then add your code to the generated class.
Regards