Web Space/Liferay : Expose SOAP & JSON services through Service Builder

Posted: May 29, 2009 in NetBeans

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.

Advertisements
Comments
  1. Tony Lim says:

    Thanks for the manual work around. When do you plan to have this automated in portal pack?
    Thanks for the great work!

  2. Heri Parid Pardian says:

    Hi Satya,
    this very cool stuff.
    now I’m learning about webservice in liferay.
    I’m using liferay 5.2.2
    I’m still confuse to develop webservice.
    is it the same way (article above) applied in liferay 5.2.2?
    can u give me some reference how to develop webservice using service builder.
    thank you.
    I’m looking forward for your expertise.

  3. satya says:

    >>is it the same way (article above) applied in liferay 5.2.2?
    AFAIK, this is the same way but with some manual steps here because we are developing a webservice which is an external portlet using service builder.
    But I think if you use Liferay Ext environment, then you don’t need those manual steps.
    >>can u give me some reference how to develop webservice using service builder.
    thank you.
    You can follow this blog or can also use liferay ext env.

  4. Anonymous says:

    thanks for your respond
    I have some question?
    1. do the methods in serviceXXXServiceSoap is generated from XXServiceSoapBindingImpl.java by servicebuilder?
    because I’m confuse to analyze where the methods come from inside serviceXXXServiceSoap class after building wsdd by servicebuilder.
    2 why we need to copy-paste some files to tomcat-bundle manually?
    how about ant? can we use it?
    thank you very much

  5. Arun Ramachandran says:

    Hi Ranjan,
    I saw your tutorial in Link . I need more help from your tutorial. I need to do more functionality like add more entity and write query to fetch,store and update. Can you help me do this? What are the files i need to change for the above need. And also i need some tutorial for liferay with web services.
    Please help me sir! i am a fresher for this liferay and web services technology.

    Thanks
    Arun(arunkumarinfo@gmail.com)

  6. That was remarkable post. I like to read articles that are edifying for they enriched my mind with different knowledge that makes me a better person. These articles especially about recent events, technologies, news, tips and technical skills are the topics that I adore. Keep it up and more power to your website. I look forward for your next article.Thanks Jennifer Liferay Portal Development

    • Arun Kumar says:

      hello sir,
      I need your guide to study web services in liferay. where to learn this and how to implement it? can you provide any tutorial to do this.

      Thanks
      Arun

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s