Steps to publish a SOAP web-service in liferay.
1) Create a portlet called "web-service-publishing-portlet" in liferay.
2) Put the service.xml in the web-inf folder. In the service.xml remote-service="true".
Code-Snippet:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<service-builder package-path="com.aalap.sample.webservice">
<namespace>WebServiceDemoSample</namespace>
<entity name="Sample" local-service="true" remote-service="true">
<column name="id" type="long" primary="true"></column>
<column name="name" type="String" primary="true"></column>
<column name="groupId" type="long"></column>
<finder return-type="Collection" name="groupId">
<finder-column name="groupId"></finder-column>
</finder>
</entity>
</service-builder>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<service-builder package-path="com.aalap.sample.webservice">
<namespace>WebServiceDemoSample</namespace>
<entity name="Sample" local-service="true" remote-service="true">
<column name="id" type="long" primary="true"></column>
<column name="name" type="String" primary="true"></column>
<column name="groupId" type="long"></column>
<finder return-type="Collection" name="groupId">
<finder-column name="groupId"></finder-column>
</finder>
</entity>
</service-builder>
3) Now clean and run the command ant clean-build-service command.By this command appropriate methods has been generated.
4) Form the local service impl class write a method
public List<Sample> getUsers(long groupId) throws SystemException{
return samplePersistence.findBygroupId(groupId);
}
again run the build-service task. Make sure your build task run successful.return samplePersistence.findBygroupId(groupId);
}
5) Now put a method in the serviceImpl class.
public class SampleServiceImpl extends SampleServiceBaseImpl {
public List<Sample> getUsers(long groupId) throws SystemException{
return SampleLocalServiceUtil.getUsers(groupId);
}
}
Again run the command ant clean build-service.Verify the task has been run successfully.
6) Now run the task build-wsdd.Verify tha task has run successfully.Then run the task ant clean deploy ant. Check in the concel the message one "web-service-publishing-portlet" is available for use.
7) After this command one wsdd(Web Service Deployment Descriptor) file has been generated.In this file the tag <service name> defines the name of the wsdl(Web Service Description Language). In our example name of the wsdl file is "Plugin_WebServiceDemoSample_SampleService". To access this file hit the url "http://127.0.0.1:8080/web-service-publishing-portlet/api/axis/Plugin_WebServiceDemoSample_SampleService?wsdl" . If some one want to access methods published url hit above mention url.
In the wsdl file the tag <wsdl:operation> define the name of the methods we have published. In our example we have nethod "getUsers" which is in the tag "<wsdl:operation name="getUsers">".
No comments:
Post a Comment