Web Space/Liferay : Expose SOAP & JSON services through Service Builder
By ranjansatya on May 29, 2009
As you know Portal Pack 3.0.1 provides a nice service builder editor where you can add/remove services and also generate service classes from NetBeans IDE. These services can be deployed on Liferay/Web Space server. To know more about how the services can be generated using Portal Pack, check this blog.
If all your portlets are deployed on the same liferay instance, then they can consume those services through normal java calls. But what about exposing a service as remote service, so that it can be consumed by remote clients. But currently the service builder plug-in in Portal Pack doesn't generate SOAP, JSON classes which are required to expose a remote service as SOAP and JSON and hence can not be consumed by remote clients.
So if you are using service builder plugin in NetBeans, here are some steps provided by Ilya Zverev in this forum post to generate soap/http/json classes for the services in your service.xml . I am just doing the copy paste of those steps here in this blog
- Create service using ServiceBuilder.
- Create new package apart from your portlet and create an interface there with all service methods.
- Use Apache Axis' Java2WSDL and WSDL2Java to create all soap classes and deploy.wsdd .(You can also manually call the build-wsdd target)
- Find YourServiceSoapBindingImpl.java and write implementations for all methods to call corresponding YourServiceUtil methods, generated by ServiceBuilder.
- Build this package and put it into tomcat/webapps/ROOT/WEB-INF/lib folder;
- Take <service> tag from generated deploy.wsdd file and copy-paste it into tomcat/webapps/tunnel-web/WEB-INF/server-config.wsdd near other services.
- Copy the jar generated with ServiceBuilder into tomcat/common/lib/ext
- Stop, then start tomcat, deploy your portlet.
- Check http://localhost:8080/tunnel-web/axis for your service. It should be there.
Thanks to Ilya Zverev for these steps.
Meanwhile we are trying to automate these steps in Portal Pack Service Builder and hope you won't need to follow all these manual steps in next update release of Portal Pack.