Deal of the Day

Home » Main » Manning Forums » 2006 » EJB3 in Action

Thread: Web Service Return Complex Type

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Pages: 1 - Last Post: Jan 2, 2009 3:43 PM by: reza_rahman
AntonioJSG

Posts: 16
From: Guatemala
Registered: 8/18/08
Web Service Return Complex Type
Posted: Dec 22, 2008 8:19 PM
  Click to reply to this thread Reply

Dear Authors,

I have succeed declaring web services with int or String return type, as the example written in your book.

But now I want to return an array of complex type. Below is a simplified example (for the sake of the readers).

*********************************************************************
@WebService()
@Stateless()
public class SyncMovProductoDet {

@WebMethod(operationName = "getAll")
public ProductoDetalle[] getAllProdDet(wsSecurityToken securityToken) {
return productoDetalle;
}
******************************************************************

The ProductoDetalle Class if very simple

*****************************************************************
public class ProductoDetalle {

public Integer codigoProducto;
public String tipoMaterial;
public Integer codigoPapel;


public ProductoDetalle() {
}

public ProductoDetalle(Integer codigoProducto) {
this.codigoProducto = codigoProducto;
}
getter/setter methods ...
}
*******************************************************************************************

When I deploy the web service in GlassFish V2R2, I get the following error.

Exception occured in the wsgen process javax.xml.ws.WebServiceException: Unable to create JAXBContext at com.sun.enterprise.webservice.WsUtil.runWsGen

What I am missing to declare in the Web Service ??

It would be very useful if you include this kind of example in your next version of the book.

Kind regards

Antonio

AntonioJSG

Posts: 16
From: Guatemala
Registered: 8/18/08
Re: Web Service Return Complex Type
Posted: Dec 22, 2008 10:30 PM   in response to: AntonioJSG in response to: AntonioJSG
  Click to reply to this thread Reply

I feel really silly, because it was my fault.

The problem is that the custom class has public access for the properties and also it has getter/setter methods.

I discover because you can use Netbeans to generate the WSDL files for the Webservice to inspect them. Doing so it returned the detailed error.

If you want to use it, write your Web Service, then go to "Web Services" node, select your Web Service, right click it and select "Generate and Copy WSDL".

reza_rahman


Posts: 456
From: Philadelphia ,PA
Registered: 11/30/05
Re: Web Service Return Complex Type
Posted: Jan 2, 2009 3:43 PM   in response to: AntonioJSG in response to: AntonioJSG
  Click to reply to this thread Reply

Antonio,

Glad it got resolved and no problem.

Best regards,
Reza

P.S.: Sorry for the late reply, I have been on vacation the past few weeks.

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor