You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Barry Kern <bs...@gmail.com> on 2009/10/20 16:31:06 UTC

Array/Collection parameter for web service is coming in null

Hi,
I am using cxf 2.0.9 and JAX WS to write a web service. I have never written
one that takes parameters besides the primitive types and my thought is I am
missing a step. I have coded the web service and written a test in java that
is successful however when clients outside of java are attempting to consume
the service its not working. In an attempt to test this situation I use
soapUI and try to make a valid soap call to the service and the array is
still coming in null.  I tried re writing the service to take a
collection(instead of the array) and I still see the same issue.

The method signature looks like this:


@WebMethod(operationName="getMix")
@WebResult(name="result")
Mix getMix(
@WebParam(name = "length")String length,
@WebParam(name = "bitrate")String bitrate,
@WebParam(name = "audio") Collection<Audio> audio
);


It returns a object of type mix and in the WSDL I see these lines which make
me think the web service understands the mix object

<xs:complexType name="mix">
-
<xs:complexContent>
-
<xs:extension base="abstractEntity">
-
<xs:sequence>
<xs:element minOccurs="0" name="status" type="xs:string"/>
<xs:element minOccurs="0" name="url" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>

There isn't as any information in the WSDL for the type Audio which I am
thinking this is why I am having an issue. Here is what I see for the method
above in the WSDL:

<xs:element name="getMix" type="getMix"/>
-
<xs:complexType name="getMix">
-
<xs:sequence>
<xs:element minOccurs="0" name="length" type="xs:string"/>
<xs:element minOccurs="0" name="bitrate" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="audio"/>
</xs:sequence>
</xs:complexType>
<xs:element name="getMixResponse" type="getMixResponse"/>
-
<xs:complexType name="getMixResponse">
-
<xs:sequence>
<xs:element minOccurs="0" name="result" type="mix"/>
</xs:sequence>
</xs:complexType>

Do I need to do something to the Audio class to have the web service better
understand how to represent this collection (or array)?

Thanks,
Barry

Re: Array/Collection parameter for web service is coming in null

Posted by Barry Kern <bs...@gmail.com>.
Thanks Dan, that worked. The Audio class had no default constructor by
accident. Once in place the WSDL generated more information about the Audio
object and I was able to test the service from java and soapUI without an
issue.
-Barry

On Tue, Oct 20, 2009 at 11:26 AM, Daniel Kulp <dk...@apache.org> wrote:

>
> What does the Audio class look like?
>
> Does it have a default constructor?   Are all properties defined with
> public
> getter and setters?
>
> That all said, I wold definitely encourage you to upgrade to a newer
> version
> of CXF.
>
> Dan
>
> On Tue October 20 2009 10:31:06 am Barry Kern wrote:
> > Hi,
> > I am using cxf 2.0.9 and JAX WS to write a web service. I have never
> >  written one that takes parameters besides the primitive types and my
> >  thought is I am missing a step. I have coded the web service and written
> a
> >  test in java that is successful however when clients outside of java are
> >  attempting to consume the service its not working. In an attempt to test
> >  this situation I use soapUI and try to make a valid soap call to the
> >  service and the array is still coming in null.  I tried re writing the
> >  service to take a
> > collection(instead of the array) and I still see the same issue.
> >
> > The method signature looks like this:
> >
> >
> > @WebMethod(operationName="getMix")
> > @WebResult(name="result")
> > Mix getMix(
> > @WebParam(name = "length")String length,
> > @WebParam(name = "bitrate")String bitrate,
> > @WebParam(name = "audio") Collection<Audio> audio
> > );
> >
> >
> > It returns a object of type mix and in the WSDL I see these lines which
> >  make me think the web service understands the mix object
> >
> > <xs:complexType name="mix">
> > -
> > <xs:complexContent>
> > -
> > <xs:extension base="abstractEntity">
> > -
> > <xs:sequence>
> > <xs:element minOccurs="0" name="status" type="xs:string"/>
> > <xs:element minOccurs="0" name="url" type="xs:string"/>
> > </xs:sequence>
> > </xs:extension>
> > </xs:complexContent>
> >
> > There isn't as any information in the WSDL for the type Audio which I am
> > thinking this is why I am having an issue. Here is what I see for the
> >  method above in the WSDL:
> >
> > <xs:element name="getMix" type="getMix"/>
> > -
> > <xs:complexType name="getMix">
> > -
> > <xs:sequence>
> > <xs:element minOccurs="0" name="length" type="xs:string"/>
> > <xs:element minOccurs="0" name="bitrate" type="xs:string"/>
> > <xs:element maxOccurs="unbounded" minOccurs="0" name="audio"/>
> > </xs:sequence>
> > </xs:complexType>
> > <xs:element name="getMixResponse" type="getMixResponse"/>
> > -
> > <xs:complexType name="getMixResponse">
> > -
> > <xs:sequence>
> > <xs:element minOccurs="0" name="result" type="mix"/>
> > </xs:sequence>
> > </xs:complexType>
> >
> > Do I need to do something to the Audio class to have the web service
> better
> > understand how to represent this collection (or array)?
> >
> > Thanks,
> > Barry
> >
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Array/Collection parameter for web service is coming in null

Posted by Daniel Kulp <dk...@apache.org>.
What does the Audio class look like?

Does it have a default constructor?   Are all properties defined with public 
getter and setters?

That all said, I wold definitely encourage you to upgrade to a newer version 
of CXF.    

Dan

On Tue October 20 2009 10:31:06 am Barry Kern wrote:
> Hi,
> I am using cxf 2.0.9 and JAX WS to write a web service. I have never
>  written one that takes parameters besides the primitive types and my
>  thought is I am missing a step. I have coded the web service and written a
>  test in java that is successful however when clients outside of java are
>  attempting to consume the service its not working. In an attempt to test
>  this situation I use soapUI and try to make a valid soap call to the
>  service and the array is still coming in null.  I tried re writing the
>  service to take a
> collection(instead of the array) and I still see the same issue.
> 
> The method signature looks like this:
> 
> 
> @WebMethod(operationName="getMix")
> @WebResult(name="result")
> Mix getMix(
> @WebParam(name = "length")String length,
> @WebParam(name = "bitrate")String bitrate,
> @WebParam(name = "audio") Collection<Audio> audio
> );
> 
> 
> It returns a object of type mix and in the WSDL I see these lines which
>  make me think the web service understands the mix object
> 
> <xs:complexType name="mix">
> -
> <xs:complexContent>
> -
> <xs:extension base="abstractEntity">
> -
> <xs:sequence>
> <xs:element minOccurs="0" name="status" type="xs:string"/>
> <xs:element minOccurs="0" name="url" type="xs:string"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> 
> There isn't as any information in the WSDL for the type Audio which I am
> thinking this is why I am having an issue. Here is what I see for the
>  method above in the WSDL:
> 
> <xs:element name="getMix" type="getMix"/>
> -
> <xs:complexType name="getMix">
> -
> <xs:sequence>
> <xs:element minOccurs="0" name="length" type="xs:string"/>
> <xs:element minOccurs="0" name="bitrate" type="xs:string"/>
> <xs:element maxOccurs="unbounded" minOccurs="0" name="audio"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="getMixResponse" type="getMixResponse"/>
> -
> <xs:complexType name="getMixResponse">
> -
> <xs:sequence>
> <xs:element minOccurs="0" name="result" type="mix"/>
> </xs:sequence>
> </xs:complexType>
> 
> Do I need to do something to the Audio class to have the web service better
> understand how to represent this collection (or array)?
> 
> Thanks,
> Barry
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog