You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Fabrício <fa...@de9.ime.eb.br> on 2005/08/27 21:33:33 UTC

Getting a complex type from web services

Hello all,

I created a web service that uses a bean. My intention is that the web
service returns an instance of this bean. When I saw the WSDL I noticed that
a complex type was created to represents the bean that I want to return. All
ok until here.

After that I created a client to call the web service. But I'm always
receiving the error:

javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end
of file.

The same client calling web services that return simple types works fine.

Any ideas?

Thanks in advance,

Fabrício.


Re: Getting a complex type from web services

Posted by Rogério Luz <ro...@gmail.com>.
Hi Fabricio,
I have a similar Web Service that returns (and passes as parameter) a bean 
(and/or an array of beans).
Remember that when using complex type you need to serialize and deserialize 
the bean!.

I'll put my code here and if you have any doubt feel free to ask me.


********
QName qnYourBean = new QName("urn:YourService", "YourBean");
call.registerTypeMapping(YourBean.class, qnYourBean , 
new org.apache.axis.encoding.ser.BeanSerializerFactory(YourBean.class, 
qnYourBean ), 
new org.apache.axis.encoding.ser.BeanDeserializerFactory(YourBean.class, 
qnYourBean ));
call.setTargetEndpointAddress( new java.net.URL(options.getURL()) ); 
call.setOperationName( new QName("YourServiceProcessor", "yourMethod") 
);//the method call... 
call.addParameter( "arg1", org.apache.axis.encoding.XMLType.XSD_LONG, 
ParameterMode.IN );//yourMethod's parameter... in this case, a Long...
YourBean yb= (YourBean) call.invoke( new Object[] {new Long(args[0])});// 
calling your method (passing a long parameter) and expecting the return of 
YourBean.

*******

I hope this helps,


Um abraço,

Rogério Santos Luz



On 8/27/05, Fabrício <fa...@de9.ime.eb.br> wrote:
> 
> Hello all,
> 
> I created a web service that uses a bean. My intention is that the web
> service returns an instance of this bean. When I saw the WSDL I noticed 
> that
> a complex type was created to represents the bean that I want to return. 
> All
> ok until here.
> 
> After that I created a client to call the web service. But I'm always
> receiving the error:
> 
> javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end
> of file.
> 
> The same client calling web services that return simple types works fine.
> 
> Any ideas?
> 
> Thanks in advance,
> 
> Fabrício.
> 
> 


-- 
[]´s

Rogério Luz