Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Joel Peterson
Service Builder with non-DB data source
8. März 2010 15:20
Antwort

Joel Peterson

Rang: New Member

Nachrichten: 22

Eintrittsdatum: 18. Februar 2010

Neue Beiträge

Is there an equivalent tool to ServiceBuilder for web services that do not use Liferay's database as the datasource? We have web services with WSDL documents on a different server that we want to use for our datasource but we also want to be able to make use of the other features that ServiceBuilder provides, such as auto-generating the javascript proxy files and JSON wrappers for the services.

Essentially we want to generate everything that ServiceBuilder generates, but instead of using Hibernate to retrieve the data we just want empty stubs that we can implement on our own.

We are currently using Liferay 5.2.2 Community Edition.

Any information/help would be appreciated,

Joel Peterson
Joel Peterson
RE: Service Builder with non-DB data source
22. September 2011 12:00
Antwort

Joel Peterson

Rang: New Member

Nachrichten: 22

Eintrittsdatum: 18. Februar 2010

Neue Beiträge

In case anybody had the same question I will post the steps here.

Brett Swaim gave a presentation on web services at Liferay WCS 2011 that had the solution to this for at least the upcoming Liferay 6.1 and maybe earlier versions of 6.

1) Create a service.xml file in your plugin to use service builder
2) Create an entity for your service, but do not put any columns in it
3) Run ant build-service to generate the service layer. When Liferay sees an entity with no columns, it creates the service layer without the database/persistence/ORM layer
4) Add methods for your various services to the implementation in the YourServiceLocalServiceImpl class
5) Code the methods to make the data requests to wherever you plan on getting data from
6) Deploy your plugin, you can now make use of YourServiceLocalServiceUtil to fetch your data.

Also, if you create a remote-service through service builder and then generate a WSDD file from your service, Liferay will generate the JSON layer in a service.js file in your project that can be used to call your service from javascript code.
Stian Sigvartsen
RE: Service Builder with non-DB data source
22. September 2011 12:43
Antwort

Stian Sigvartsen

Rang: Regular Member

Nachrichten: 103

Eintrittsdatum: 27. August 2010

Neue Beiträge

Thanks for sharing this.
I'm sure I will have a need for this in the not too distant future because I work with an n-tier architecture with a powerful middle server providing web services and BPM capability.

-Stian
Gwowen Fu
RE: Service Builder with non-DB data source
24. Januar 2013 10:26
Antwort

Gwowen Fu

Rang: Expert

Nachrichten: 315

Eintrittsdatum: 27. Dezember 2010

Neue Beiträge

Joel Peterson:

1) Create a service.xml file in your plugin to use service builder
2) Create an entity for your service, but do not put any columns in it


I am having question about these two steps.

I created service.xml under "C:\liferay-plugins-sdk-6.1.1\portlets\testservice-portlet\docroot\WEB-INF" folder, is this the right place?

I want to create a JSON web service called "greeting". What's wrong with my service.xml?
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
3<service-builder package-path="com.testservice">
4    <author>user</author>
5    <namespace>testservice</namespace>
6    <entity name="greeting" local-service="true" remote-service="true" json-enabled="true"></entity>
7</service-builder>


When I run "build-service", no code is generated and there is NullPointerException:

[Console output redirected to file:C:\workspace-liferay\.metadata\.plugins\com.liferay.ide.eclipse.sdk\sdk.log]
Buildfile: C:\liferay-plugins-sdk-6.1.1\portlets\testservice-portlet\build.xml
build-service:
Loading jar:file:/C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
Jan 24, 2013 5:03:29 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Global shared lib directory /C:/liferay-plugins-sdk-6.1.1/lib/
Jan 24, 2013 5:03:29 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Global lib directory /C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/lib/ext/
Jan 24, 2013 5:03:29 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Portal lib directory /C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/
Jan 24, 2013 5:03:29 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Properties for portal loaded from [jar:file:/C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties, jar:file:/C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties]
Loading jar:file:/C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
Loading jar:file:/C:/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
java.lang.NullPointerException
at com.liferay.portal.tools.servicebuilder.ServiceBuilder._parseEntity(ServiceBuilder.java:4848)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:636)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:151)
Created dir: C:\liferay-plugins-sdk-6.1.1\portlets\testservice-portlet\docroot\WEB-INF\service-classes
compile-java:
Warning: skipping zip archive C:\liferay-plugins-sdk-6.1.1\portlets\testservice-portlet\docroot\WEB-INF\lib\testservice-portlet-service.jar because no files were included.
Deleting directory C:\liferay-plugins-sdk-6.1.1\portlets\testservice-portlet\docroot\WEB-INF\service-classes
BUILD SUCCESSFUL

Thanks!
Gwowen
David H Nebinger
RE: Service Builder with non-DB data source
24. Januar 2013 21:24
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11046

Eintrittsdatum: 1. September 2006

Neue Beiträge

Are you using oracle jdk 6 for the build? If you open the file in the eclipse visual editor for service builder, does it report an error in the content?
Gwowen Fu
RE: Service Builder with non-DB data source
25. Januar 2013 09:41
Antwort

Gwowen Fu

Rang: Expert

Nachrichten: 315

Eintrittsdatum: 27. Dezember 2010

Neue Beiträge

David H Nebinger:
Are you using oracle jdk 6 for the build? If you open the file in the eclipse visual editor for service builder, does it report an error in the content?


Hi David,

Yes, I am using JDK 1.6. I am using Eclipse Indigo, I opened service.xml and no error is reported in the content.
I clicked on the Overview tab and noticed there is a "Build Services" link, I clicked on that link and was able to generate Java codes.

Thanks, you are the best!
Gwowen
Michele Zanarotti
RE: Service Builder with non-DB data source
8. April 2013 03:31
Antwort

Michele Zanarotti

Rang: Junior Member

Nachrichten: 93

Eintrittsdatum: 20. Februar 2012

Neue Beiträge

Hi. I know this is a very old question.

I'm using this strategy to build web services of my own. But when adding custom methods to xxxServiceImpl , i cannot see them regenerated when calling 'build services' in xxxServiceUtil, so the code is broken. For example :
I added the custom1() method to class xxxServiceImpl. I run 'build service'. The generated xxxServiceSoap class is now calling a method xxxServiceUtil.custom1() , but this method is not present in xxxServiceUtil !!! , despite my addition to the ServiceImpl version. I couldn't find any reason why this is happening.

If I go through each generated file (like xxxSoap) and replace 'Util' with 'Impl', everything works perfectly, also the web service is working with a test client. But rewriting the code that way each time is very annoying.

Am I forgetting to put something in the service xml ? It's only defined as a pure single entity without any column, finder or whatever.

I tried everything, with lf6.1 GA1 and GA2.