Follow the below steps to write sample rest Agile PLM webService Program.
1) Install Eclipse IDE from below URL.
2) Create a new project. File -> New -> Java Project
3) Include AgileAPI.jar in the project class path.
4) Use java version greater than 1.8.
5) Create a class file. New -> Class -> DemoWebService
6) Paste the below code to the new class file. Update the targetNamespace url as per your environment.
4) Use java version greater than 1.8.
5) Create a class file. New -> Class -> DemoWebService
6) Paste the below code to the new class file. Update the targetNamespace url as per your environment.
package com.test;
import javax.jws.WebService;
import com.agile.api.AgileSessionFactory;
import com.agile.api.IAgileSession;
import com.agile.api.IItem;
@WebService(portName="DemoWebServicePort" , serviceName = "DemoWebService", targetNamespace = "http://www.test.com/ws/DemoWebService",wsdlLocation = "")
public class DemoWebService
{
String itemNumber = "";
public String getItem (String item) throws Exception{
try {
AgileSessionFactory factory = AgileSessionFactory.getInstance(null);
IAgileSession session = factory.createSession(null);
IItem itemObj= (IItem) session.getObject(IItem.OBJECT_TYPE, item);
itemNumber = itemObj.toString();
} catch (Exception e){
e.printStackTrace();
throw e;
}
return itemNumber;
}
}
7) Create com.agile.wsx.WebService file under META/INF -> services folder .
8) Provide the complete package path with class name in the file “com.agile.wsx.WebService”. e.g com.test.DemoWebService.
9) Your Sample rest agile webservice is created.
This comment has been removed by the author.
ReplyDelete