Retorno de um @webMethod

1 resposta
F

Caros amigos,

Sou iniciante com webServices em Java e estou com algumas dificuldades. Só consigo retornar valores de tipos primitivos nos métodos do web service. Não consigo retornar objetos.

Como retornar um objeto na chamada de um método?
quando tento executar:

@WebMethod

public CollectionCurso getCursos(){

CollectionCurso oCurso = new CollectionCurso();

return oCurso;

}

e realizo o teste do web service através da opção “Test Web Service” do NetBeans ele dispara uma exceção:

java.lang.reflect.InvocationTargetException

Se puderem me ajudar dando alguma direção eu agradeço.

1 Resposta

F

Encontrei a resposta da minha pergunta. A quem interessar possa segue os tipos de dados suportados suportados.

Standard Java Types
All standard Java types as specified in section 5.1 of the JAX-RPC spec (JSR-101) are supported. These types include some core Java classes that can easily convert to Strings (section 5.1.3), primitives, exceptions and arrays of types already deemed suitable.

JavaBeans
Java Value types (section 5.4 of JAX-RPC) are supported. These are standard JavaBeans with the requirements that (1) they have a default no argument constructor, (2) implement java.io.Serializable, but (3) do not implement java.rmi.Remote.

Collections and Arrays
Collections are minimally supported: typed arrays are far superior. Support for JDK 5 typed Collections using Java Generics is being considered for the future. In the meantime use a typed array.

XmlBeans
XmlBeans are supported as web service types.

Attachments
DataHandler types provide attachment support in Apache Axis. If activation.jar and mailapi.jar are available, then developers can use java.awt.Image, javax.mail.internet.MimeMultipart as well as any classes extending javax.activation.DataHandler to transmit raw data as web service attachments. See the Petstore Dashboard Sample for instructions on acquiring these JARs. If these types are used directly as return values or parameters, then the client must be an Axis client.

Other Types
If you wish to use types not declared here, you can explicitly register your own serialization mechanism by adding code to register TypeMappings for custom type classes in a static block of those classes. See the Axis documentation for more information: XML <-> Java Data Mapping in Axis (see the section labeled “When Beans Are Not Enough - Custom Serialization”).

Criado 6 de setembro de 2006
Ultima resposta 7 de set. de 2006
Respostas 1
Participantes 1