Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Alex Belt
Using arrays with ServiceBuilder
9 de enero de 2013 11:22
Respuesta

Alex Belt

Ranking: Junior Member

Mensajes: 49

Fecha de incorporación: 9 de octubre de 2012

Mensajes recientes

Hi Everyone,

I have a new question, one I haven't been able to locate an answer to anywhere. I'm writing a new web service, and I want to build it out using ServiceBuilder. It's not going to have a database table behind it, so I'm not worried about SQL at all. The last piece of information used in the service is an Object[] array. The one thing I can't find how to represent in a service.xml file is an array. I know you can specify a Finder object that will give you a collection, but the array is being provided by the caller, not a database lookup. How do I represent an array in service.xml so that it generates the classes correctly?

Thanks,
Alex
David H Nebinger
RE: Using arrays with ServiceBuilder
10 de enero de 2013 6:14
Respuesta

David H Nebinger

Ranking: Liferay Legend

Mensajes: 7252

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

Alex Belt:
Hi Everyone,

I have a new question, one I haven't been able to locate an answer to anywhere. I'm writing a new web service, and I want to build it out using ServiceBuilder. It's not going to have a database table behind it, so I'm not worried about SQL at all. The last piece of information used in the service is an Object[] array. The one thing I can't find how to represent in a service.xml file is an array. I know you can specify a Finder object that will give you a collection, but the array is being provided by the caller, not a database lookup. How do I represent an array in service.xml so that it generates the classes correctly?

Thanks,
Alex


Arrays are unsupported. Use a collection instead.
Alex Belt
RE: Using arrays with ServiceBuilder
10 de enero de 2013 9:21
Respuesta

Alex Belt

Ranking: Junior Member

Mensajes: 49

Fecha de incorporación: 9 de octubre de 2012

Mensajes recientes

Thanks for letting me know. This does complicate some things for me.

That being the case, I may need to expose a portlet as a web service, as I might need to access some of the invoking user data that would have been carried as part of the array. I haven't found any documentation on exposing a portlet as a web service, only methods using the ServiceBuilder starting from the service.xml.

How do I expose a portlet's methods as SOAP based services?

Thanks,
Alex
Hitoshi Ozawa
RE: Using arrays with ServiceBuilder
11 de enero de 2013 4:31
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7954

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

Not too sure about what you're trying to do but how about creating a method in impl instead of service.xml file.
David H Nebinger
RE: Using arrays with ServiceBuilder
11 de enero de 2013 5:31
Respuesta

David H Nebinger

Ranking: Liferay Legend

Mensajes: 7252

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

Alex Belt:
How do I expose a portlet's methods as SOAP based services?


The same way you'd do it for a servlet; either a lot of manual coding or the use of some framework to help. You still have the web.xml stuff to add, you still have to ensure you've got all of your beans wired together, ...

A couple of things you can't do:

1. assume there is only one portlet instance in runtime; you'll actually have a number of instances, so you can't just keep a static link to some instance and expect it will be good though the lifetime of the servlet.

2. share data via sessions, a servlet session and a portlet session are two different things, and they do not share anything between them.

Hitoshi's right, though, it's easy to do this in SB. In addition to your XxxLocalServiceImpl class, you define an XxxServiceImpl class (and set the remote-service attribute to "true" on the entity). Here you can return an array, the method will just invoke your method that returns the collection and marshals it to an array. And if it's a standard method generated by SB, SB will help out by generating a lot of the code for you (if not all of it); in either case, it is a SOAP-based service.

Check out the Liferay remote services as to how to do this...
Alex Belt
RE: Using arrays with ServiceBuilder
11 de enero de 2013 6:48
Respuesta

Alex Belt

Ranking: Junior Member

Mensajes: 49

Fecha de incorporación: 9 de octubre de 2012

Mensajes recientes

Thanks. I've figured out how to add methods to the Impl class, and tried that already. What I haven't been able to figure out is how to access the web service user's information, since it contains data that will be needed by the service. Since it's a secure web service and the user's credentials are part of the url used to invoke the web service, I want to just get the user's info from the url. Unfortunately, there doesn't appear to be a simple way to do that, since the web service doesn't appear to be handed a session reference of any sort from which to get the url or reference the authenticated user data. Unless I've overlooked something, which is possible.

The way I see it, that leaves me with a couple of alternatives: change the web service standard to include a user reference, which for many reasons is unlikely, or find another way to get the url, such as using a portlet or servlet as the service instead. I don't like either idea, but I'm not seeing a lot of alternatives. I'm open to suggestions.

Thanks,
Alex