geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jarek Gawor" <jga...@gmail.com>
Subject Re: Returning String[] from WebService method
Date Fri, 04 Apr 2008 00:05:34 GMT
Fred,

Ok, I can reproduce this problem with Axis2 but not with CXF. Axis2
just serializes (and deserializes) the data completely wrong. Looks
like a bug in Axis2. There are two options:

1) Switch to CXF, or

2) Use jaxws-tools wsimport to generate the right classes from the
wsdl and use the generated PortType class to implement your service
and client. That's the option I would recommend.

Jarek

On Fri, Mar 28, 2008 at 6:00 PM,  <frowe@nc.rr.com> wrote:
> I'm having a problem returning a String array from a method of a webservice.  In order
to provide a simple way to recreate the problem, I modified the 2.1 webservices sample ( http://cwiki.apache.org/GMOxDOC21/developing-a-simple-calculator-web-service.html
) such that the add() method returns a String[] instead of an int.  The mods were simple,
I changed the "return" element of the addResponse in the wsdl of the sample
>  from:
>         <xsd:element name="return" type="xsd:int"/>
>  to:
>         <xsd:element name="return" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
>  and the CalculatorService.java (and the corresponding interface it implements) from:
>     public int add(int value1, int value2) {
>  ...
>       return value1 + value2;
>  to:
>     public String[] add(int value1, int value2) {
>  ...
>       return new String[]{"Value 1", String.valueOf(value1), "Value 2", String.valueOf(value2),
String.valueOf(value1 + value2)};
>
>  and then changed the result.jsp to expect a String[] and iterate over the contents printing
out each element,  If I add 3 + 4, I expected the result.jsp to display:
>
>  Value 1
>  3
>  Value 2
>  4
>  7
>
>  but I get instead:
>  Value
>  1
>  3
>  Value
>  2
>  4
>  7
>
>  It seems that in the process of converting the response into a Java String[], the whitespace
of the individual strings is acting as a delimiter.  Thus instead of getting an array of 5
strings, I get an array of 7 strings instead.  What have I misconfigured?
>
>  Fred
>

Mime
View raw message