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 Yura Tkachenko <yu...@gmail.com> on 2007/01/19 17:09:58 UTC

Re: Axis 1.2 .NET wrapped array interoperability

Hi,
It's well-known issue you need to have something like that:
1) wsdl part:
<complexType name="exampleType">
 <sequence>
  <element maxOccurs="unbound" minOccurs="0" name="f1stArr"
type="ns:DataType1"
</sequence>
2) Java side:
public DataType1[] getF1stArr() {
...
}
public void setF1stArr(DataType1[] d) {
 .....
}
public DataType1 getF1stArr(int i) {
 return arr[i];
}
public void setF1stArr(int i, DataType1 dt) {
 arr[i] = dt;
}

Last two methods is requires for .NET interroperobility. If you haven't them
in the you bean than you will have your wsdl in that way:

<complexType name="ReturnType">

    <sequence>

      <element name="myArray" nillable="true" type="impl:ArrayOfMyArrayType
"/>

   </sequence>

</complexType>

 <complexType name="ArrayOfMyArrayType">

    <sequence>

      <element maxOccurs="unbounded" minOccurs="0" name="item"
type="impl:ArrayType"/>

    </sequence>

</complexType>
Just add these two methods and correct your wsdl and be happy with .NET :-)

2007/1/19, Chris Harris <ch...@thunderhead.com>:
>
>  Hi all,
>
>
>
> We currently have a java application that provides a number of axis web
> services that are rpc/encoded and have be recently experiencing problems
> with integrating into web services client tools such as Biztalk. The cause
> of our problem was around the encoding of arrays. In order to be WS-I
> compliant we now expose wrapped/literal web services.
>
>
>
> This has worked perfectly when the client application is using Axis but
> there is an interoperability problem when the client is a .net application.
> The problem only occurs when you returning an object that has an array of
> other objects. I hope the following environment explanation helps you
> understand the problem:
>
>
>
> Axis generated the following XML schema of the return object (I have only
> included the return object definition).
>
>
>
>
>
> <complexType name="ReturnType">
>
>     <sequence>
>
>       <element name="myArray" nillable="true"
> type="impl:ArrayOfMyArrayType "/>
>
>    </sequence>
>
> </complexType>
>
>
>
> <complexType name="ArrayOfMyArrayType">
>
>     <sequence>
>
>       <element maxOccurs="unbounded" minOccurs="0" name="item"
> type="impl:ArrayType"/>
>
>     </sequence>
>
> </complexType>
>
>
>
> <complexType name=" ArrayType ">
>
>     <sequence>
>
>       <element name="value" type="xsd:int"/>
>
>    </sequence>
>
> </complexType>
>
>
>
>
>
> The response message generated by axis looks like:
>
>
>
> <soapenv:Body>
>
>          <myMethodResponse xmlns="http://test ">
>
>             <myMethodReturn>
>
>                <myArray>
>
>                   <myArray>
>
>                      <channelId>2</channelId>
>
>                  </myArray>
>
>              </myArray>
>
>           </myMethodReturn>
>
>       </myMethodResponse>
>
> </soapenv:Body>
>
>
>
>
>
> The problem is that there are nested myArray element when the xml schema
> within the WSDL defines that there should be an item element. For some
> reason an axis client will accept this odd nesting of elements but a .net
> client always reports that the array is empty.
>
>
>
> Does anyone know of a way of making the response message look like:
>
>
>
> <soapenv:Body>
>
>          <myMethodResponse xmlns="http://test ">
>
>             <myMethodReturn>
>
>                <myArray>
>
>                   <item>
>
>                      <channelId>2</channelId>
>
>                  </item>
>
>              </myArray>
>
>           </myMethodReturn>
>
>       </myMethodResponse>
>
> </soapenv:Body>
>
>
>
> Many Thanks,
>
>
>
> Chris
>
>
>
>
>
>
>
>
>
>
>
>
>



-- 
Thanks,
Yura.

RE: Axis 1.2 .NET wrapped array interoperability

Posted by Chris Harris <ch...@thunderhead.com>.
Hi,

 

Thanks for the tip but I can not change the interface to the web
service.

 

As a workaround I have put together a custom ArraySerializerFactory
which extends the existing ArraySerializerFactory but overrides the
following method:

 

    protected Serializer getGeneralPurpose(String mechanismType)

    {

         QName newComponentQName = new
QName(xmlType.getNamespaceURI(),"item"); //FIX AXIS so that the
componentQName it is item

 

          return new ArraySerializer(javaType, xmlType, componentType,
newComponentQName);

    }

 

 

This does mean that my componentQName will always be "item" but I
believe this is always going to be true.  Is anyone aware of any issues
with this approach?

 

Thanks,

 

Chris.

 

________________________________

From: Yura Tkachenko [mailto:yura.tkachenko@gmail.com] 
Sent: 19 January 2007 16:10
To: axis-user@ws.apache.org
Subject: Re: Axis 1.2 .NET wrapped array interoperability

 

Hi,
It's well-known issue you need to have something like that:
1) wsdl part:
<complexType name="exampleType">
 <sequence>
  <element maxOccurs="unbound" minOccurs="0" name="f1stArr"
type="ns:DataType1" 
</sequence>
2) Java side:
public DataType1[] getF1stArr() {
...
}
public void setF1stArr(DataType1[] d) {
 .....
}
public DataType1 getF1stArr(int i) {
 return arr[i];
}
public void setF1stArr(int i, DataType1 dt) { 
 arr[i] = dt;
}

Last two methods is requires for .NET interroperobility. If you haven't
them in the you bean than you will have your wsdl in that way:

<complexType name="ReturnType">

    <sequence>

      <element name="myArray" nillable="true"
type="impl:ArrayOfMyArrayType "/>

   </sequence>

</complexType>

 <complexType name="ArrayOfMyArrayType">

    <sequence>

      <element maxOccurs="unbounded" minOccurs="0" name="item"
type="impl:ArrayType"/>

    </sequence>

</complexType>  

Just add these two methods and correct your wsdl and be happy with .NET
:-)

2007/1/19, Chris Harris < charris@thunderhead.com>:

Hi all,

 

We currently have a java application that provides a number of axis web
services that are rpc/encoded and have be recently experiencing problems
with integrating into web services client tools such as Biztalk. The
cause of our problem was around the encoding of arrays. In order to be
WS-I compliant we now expose wrapped/literal web services.  

 

This has worked perfectly when the client application is using Axis but
there is an interoperability problem when the client is a .net
application. The problem only occurs when you returning an object that
has an array of other objects. I hope the following environment
explanation helps you understand the problem: 

 

Axis generated the following XML schema of the return object (I have
only included the return object definition).

 

 

<complexType name="ReturnType">

    <sequence>

      <element name="myArray" nillable="true"
type="impl:ArrayOfMyArrayType "/>

   </sequence>

</complexType>

 

<complexType name="ArrayOfMyArrayType">

    <sequence>

      <element maxOccurs="unbounded" minOccurs="0" name="item"
type="impl:ArrayType"/>

    </sequence>

</complexType>  

 

<complexType name=" ArrayType ">

    <sequence>

      <element name="value" type="xsd:int"/>

   </sequence>

</complexType>

 

 

The response message generated by axis looks like:

 

<soapenv:Body>

         <myMethodResponse xmlns="http://test ">

            <myMethodReturn>

               <myArray>

                  <myArray>

                     <channelId>2</channelId>

                 </myArray>

             </myArray>

          </myMethodReturn>

      </myMethodResponse>

</soapenv:Body>

 

 

The problem is that there are nested myArray element when the xml schema
within the WSDL defines that there should be an item element. For some
reason an axis client will accept this odd nesting of elements but a
.net client always reports that the array is empty. 

 

Does anyone know of a way of making the response message look like:

 

<soapenv:Body>

         <myMethodResponse xmlns="http://test ">

            <myMethodReturn>

               <myArray>

                  <item>

                     <channelId>2</channelId>

                 </item>

             </myArray>

          </myMethodReturn>

      </myMethodResponse>

</soapenv:Body>

 

Many Thanks,

 

Chris

 

 

 

 

 

 




-- 
Thanks,
Yura.