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 Lisurc <li...@gmail.com> on 2006/02/09 11:37:49 UTC

Ouput primitive array

Hello,
Writing to the list to maybe get some clues/help on an issue.

I am currently trying to develop a set of web services using Axis / Tomcat 4
as part of a larger web application (another servlet). Everything went quite
fine until I faced a problem when I wanted one of the parameters of a method
to be a primitive int array as an ouput parameter.

I can't manage to explain my config (wsdd) file or java source files I want
such an out parameter.

For example, let's say I have a public method WS_MakeSomething in a java
class named Service defined like the following :

public class Service {
public int WS_MakeSomething(int a, int[] array)  {
...
}
}

I'd like this method to return an int value and consider the array parameter
as an output parameter in which I could put some data according to the
behaviour of the method. I could not find any Holder class for such a type.

I put the matching compilated class in my webapps / WEB-INF servlet
directory (I pass over the web.xml config file for this) and edit my
server-config.wsdd config file to define my service (I just put the
interesting part, at least I hope it is interesting). :

<service name="Service" provider="java:RPC">
  <parameter name="allowedMethods" value="*"/>
  <parameter name="scope" value="request"/>
  <parameter name="className" value="Service"/>
    <operation name="WS_MakeSomething">
      <parameter name="a" mode="IN"/>
      <parameter name="array" mode="OUT"/>
    </operation>
</service>

And after restarting Tomcat, when I try to access the automatically
generated WSDL with http://myserver:8081/Service?wsdl , I get the nice
following error :

"Illegal argument passed to ParameterDesc.setJavaType.  The java type [I
does not match the mode out"

>From what I understand Axis is not really happy to read my wsdd file where
it's asked to set a primitive array as an output parameter.

I think I know how to create a Bean and wrap this array in something like
MyIntArrayHolder but I just consider this a bit complicated just to get an
output int array.

So, I am wrong wanting my int[] to be an output and do I need to write my
Bean Holder, or is there something else I missed ?

Thanks in advance if any answers.

-- Lisurc

Re: Ouput primitive array

Posted by Anne Thomas Manes <at...@gmail.com>.
yes.

On 2/9/06, Lisurc <li...@gmail.com> wrote:
>
> It's ok about windmills, they are probably not that far considering some
> headaches I got about this stuff (web services definition, not bread and
> flour)
>
> Nevertheless, even if I'll probably have to play with structured messages
> instead of several out values, I would have liked to know wether there is a
> way or not to handle that out int[] matter (not as a direct return value).
>
> Just to check if I correctly understood, you'd advise me to change the
> above method in something like the following :
>
> public class Service {
> public MadeSomethingResponse WS_MakeSomething(MadeSomethingRequest arg)  {
>
> ...
> }
> }
> With MadeSomethingResponse and MadeSomethingRequest being bean objects to
> be included in my WSDL ?
>
> -- Lisurc
>

Re: Ouput primitive array

Posted by Lisurc <li...@gmail.com>.
It's ok about windmills, they are probably not that far considering some
headaches I got about this stuff (web services definition, not bread and
flour)

Nevertheless, even if I'll probably have to play with structured messages
instead of several out values, I would have liked to know wether there is a
way or not to handle that out int[] matter (not as a direct return value).

Just to check if I correctly understood, you'd advise me to change the above
method in something like the following :

public class Service {
public MadeSomethingResponse WS_MakeSomething(MadeSomethingRequest arg)  {
...
}
}
With MadeSomethingResponse and MadeSomethingRequest being bean objects to be
included in my WSDL ?

-- Lisurc

Re: Ouput primitive array

Posted by Anne Thomas Manes <at...@gmail.com>.
Perhaps I'm fighting windmills here, but ...

You really should start thinking of SOAP in terms of message in and message
out, not in terms of Java IN, OUT, and INOUT parameters. If you want to
return an array of ints, then you should compose that array as part of your
return value.

Anne

On 2/9/06, Lisurc <li...@gmail.com> wrote:
>
> Hello,
> Writing to the list to maybe get some clues/help on an issue.
>
> I am currently trying to develop a set of web services using Axis / Tomcat
> 4 as part of a larger web application (another servlet). Everything went
> quite fine until I faced a problem when I wanted one of the parameters of a
> method to be a primitive int array as an ouput parameter.
>
> I can't manage to explain my config (wsdd) file or java source files I
> want such an out parameter.
>
> For example, let's say I have a public method WS_MakeSomething in a java
> class named Service defined like the following :
>
> public class Service {
> public int WS_MakeSomething(int a, int[] array)  {
> ...
> }
> }
>
> I'd like this method to return an int value and consider the array
> parameter as an output parameter in which I could put some data according to
> the behaviour of the method. I could not find any Holder class for such a
> type.
>
> I put the matching compilated class in my webapps / WEB-INF servlet
> directory (I pass over the web.xml config file for this) and edit my
> server-config.wsdd config file to define my service (I just put the
> interesting part, at least I hope it is interesting). :
>
> <service name="Service" provider="java:RPC">
>   <parameter name="allowedMethods" value="*"/>
>   <parameter name="scope" value="request"/>
>   <parameter name="className" value="Service"/>
>     <operation name="WS_MakeSomething">
>       <parameter name="a" mode="IN"/>
>       <parameter name="array" mode="OUT"/>
>     </operation>
> </service>
>
> And after restarting Tomcat, when I try to access the automatically
> generated WSDL with http://myserver:8081/Service?wsdl , I get the nice
> following error :
>
> "Illegal argument passed to ParameterDesc.setJavaType.  The java type [I
> does not match the mode out"
>
> From what I understand Axis is not really happy to read my wsdd file where
> it's asked to set a primitive array as an output parameter.
>
> I think I know how to create a Bean and wrap this array in something like
> MyIntArrayHolder but I just consider this a bit complicated just to get an
> output int array.
>
> So, I am wrong wanting my int[] to be an output and do I need to write my
> Bean Holder, or is there something else I missed ?
>
> Thanks in advance if any answers.
>
> -- Lisurc
>