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 Bill Keese <bi...@tech.beacon-it.co.jp> on 2005/01/20 05:00:31 UTC

Arrays: .NET client --> AXIS server

I'm using Axis (server) to run a wrapped/literal service. My .NET client
correctly encodes my

   String[] myArray;

array as

  <myArray>
     <item>one</item>
     <item>two</item>
  </myArray>

However, the AXIS server chokes on this. It gets a nullPointerException
is BeanDeserializer.onStartChild() for the myArray tag.

I've read Eric Chijioke's post entitled "Axis and .NET interoperability
- Arrays", but that seems to concern passing arrays from the AXIS server
to a .NET client, rather than vice-versa. So, my two questions are:

1) When implementing a document/literal service, should you use
BeanSerializer/BeanDeserializer to encode/decode your objects, or should
you use something else, like http://xmlbeans.apache.org/?

2) are there any other steps to do to support this?

Bill

Re: Arrays: .NET client --> AXIS server

Posted by Bill Keese <bi...@tech.beacon-it.co.jp>.
After looking into the code, I found out that deserialization for arrays
works automatically in rpc/encoded mode, but not in document/literal
mode. The workaround is to register a serializer/deserializer in the
WSDD file like this:

<typeMapping
languageSpecificType="java:java.lang.String[]"
qname="soapEncoding:Array"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
encodingStyle=""
/>

where

xmlns:soapEncoding="http://schemas.xmlsoap.org/soap/encoding/".

(Of course, you should substitute String[] with the actual type of your
array.)

Is this a bug? I'd like all Array objects to automatically call
ArraySerializer/ArrayDeserializer.

Note also that there is a default serializer/deserializer registered for
ArrayList (although not for List or Collection). However, in
document/literal mode (where no type information is encoded into the
message), Axis has no way of knowing the type (String, Integer, etc.) so
the conversion fails when processing the first element. Thus your Java
class should contain a simple array like this:

String[] foo;

instead of a list like this:

List foo;

Note that the name of the array is NOT listed in the typeMapping above.

Bill




Bill Keese wrote:

>I'm using Axis (server) to run a wrapped/literal service. My .NET client
>correctly encodes my
>
>   String[] myArray;
>
>array as
>
>  <myArray>
>     <item>one</item>
>     <item>two</item>
>  </myArray>
>
>However, the AXIS server chokes on this. It gets a nullPointerException
>is BeanDeserializer.onStartChild() for the myArray tag.
>
>I've read Eric Chijioke's post entitled "Axis and .NET interoperability
>- Arrays", but that seems to concern passing arrays from the AXIS server
>to a .NET client, rather than vice-versa. So, my two questions are:
>
>1) When implementing a document/literal service, should you use
>BeanSerializer/BeanDeserializer to encode/decode your objects, or should
>you use something else, like http://xmlbeans.apache.org/?
>
>2) are there any other steps to do to support this?
>
>Bill
>
>
>  
>