Service builder generates *Soap.java files, but none for JSON.

thumbnail
Gerald Rubin, modified 14 Years ago. Junior Member Posts: 59 Join Date: 10/23/11 Recent Posts
Should it? Obviously, all my entities have remote-access="true". I even tried setting the implied attribute json-enabled="true".

I've added JSON servlet definitions to web.xml.

I just cannot get scanning for JSON api methods to happen when I deploy.

Any help would be greatly appreciated.
thumbnail
Prakash Khanchandani, modified 14 Years ago. Expert Posts: 329 Join Date: 2/10/11 Recent Posts
For me it generates the *JSONSerializer.java files when service is built.
version: Liferay 6.0

Can you share your web.xml and service.xml files.
gatla1 chinna, modified 14 Years ago. New Member Post: 1 Join Date: 4/4/11 Recent Posts
Hi Gerald Rubin
i have the same problem, did you find the solution , if can you please help me in that.
Thanks
thumbnail
Gerald Rubin, modified 14 Years ago. Junior Member Posts: 59 Join Date: 10/23/11 Recent Posts
gatla1 chinna:
Hi Gerald Rubin
i have the same problem, did you find the solution , if can you please help me in that.
Thanks

Let me tell you what I've done now.

My service.xml creates about 30 entities, but I really want custom methods exposed for JSON queries. So, I created a Database-portlet and put the service.xml into it. All entiies are marked local only, not remote. I build, deploy, handle the tables, etc. normally. I move the Database-portlet-service.jar to \tomcat\lib\ext. All other portlet project have this jar in their build classpath. This portlet is NEVER meant to be added to a web page.

Neither is this one: JSON_wrapper-portlet. It has a service.xml which Liferay generated with the sample Foo class--marked as remote. I did a build service.

Then I opened ...FooServiceImpl.java and added all the JSON methods I wrote and want to expose there. You have complete access to the real database jar and any custom classes you need. All your work goes into this Impl. My methods return either database entities or Object[] (if I'm returning an array of entities--database or my own). I have not been able to JSON serialize a complex custom class.

After adding methods to FooServiceImpl.java I build the service again; clean; compile; and deploy. That service.jar stays right in the webapp.

If I browse to http://localhost:8080/json_wrapper-portlet/api/jsonws, I see all my custom methods. I can test them right there. (In Internet Explorer the JSON response wants to download, but the other browsers just display it.)

I'm in Liferay 6.1. If you're in 6.0.x, I think you have tunnel-web someplace in the URL, but I did everything under 6.1.

It works fine. I hope this help.

Jerry