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 vincent <vi...@thelis.fr> on 2006/04/21 14:16:35 UTC

Problem with Array in parameter

Hi,
I have a problem with array in the parameter of my webservice. For the response, there are no problem I try to receive it, but I cannot send it. 
The WSDL is:
<complexType name="TestArray">
<sequence>
<element name="first" nillable="true" type="soapenc:short"/>
<element name="second" nillable="true" type="soapenc:short"/>
</sequence>
</complexType>
<complexType name="ArrayOfTestArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="impl:TestArray[]"/>
</restriction>
</complexContent>
</complexType>
..............
.............
<wsdl:message name="TestRequest">
<wsdl:part name="in0" type="impl:ArrayOfTestArray"/>
</wsdl:message>
.................
..................
<wsdl:operation name="Test" parameterOrder="in0 in1 in2 in3 in4 in5">
<wsdl:input message="impl:TestRequest" name="TestRequest"/>
<wsdl:output message="impl:TestResponse" name="TestResponse"/>
</wsdl:operation>


I use Java to call the webservice, if I put null in parameter there are no problem, but if I put an array there are error. My source is:

............................
 TypeMappingRegistry tmr = service.getTypeMappingRegistry();

  QName xmlType = new QName("urn:test", "TestArray");

//   get a TypeMapping (default for axis is SOAP encoding TypeMapping)
  TypeMapping tm = tmr.getDefaultTypeMapping();


  tm.register(ResponseCpgContext.class, 
              xmlType,
              new BeanSerializerFactory(TestArray.class, xmlType),
              new BeanDeserializerFactory(TestArray.class, xmlType));

  xmlType = new QName("urn:test", "ArrayOfTestArray");
    tm.register(TestArray[].class, 
               xmlType,
               new ArraySerializerFactory(TestArray.class, xmlType),
               new ArrayDeserializerFactory( xmlType)); 

TestArray[] toto = new TestArray[1];
myProxy.Test(toto);   
...................................

I have an axis fault with this code. Maybe is my serialization which is bad. 
Thanks. 



 

Re: Problem with Array in parameter

Posted by robert lazarski <ro...@gmail.com>.
For us to be to help, you need to show the entire wsdl, and the relevant
java code on both the server side and client side.

Looks like you are using SOAP Encoded arrays. I recommend considering a doc
/ lit style instead.

HTH,
Robert
http://www.braziloutsource.com

On 4/21/06, vincent <vi...@thelis.fr> wrote:
>
> Hi,
> I have a problem with array in the parameter of my webservice. For the
> response, there are no problem I try to receive it, but I cannot send it.
> The WSDL is:
> <
> complexType name="TestArray">
> <sequence>
> <element name="first" nillable="true" type="soapenc:short"/>
> <element name="second" nillable="true" type="soapenc:short"/>
> </sequence>
> </complexType>
> <complexType name="ArrayOfTestArray">
> <complexContent>
> <restriction base="soapenc:Array">
> <attribute ref="soapenc:arrayType" wsdl:arrayType="impl:TestArray[]"/>
> </restriction>
> </complexContent>
> </complexType> ..............
> .............
> <wsdl:message name="TestRequest">
> <wsdl:part name="in0" type="impl:ArrayOfTestArray"/>
> </wsdl:message> .................
> ..................
> <wsdl:operation name="Test" parameterOrder="in0 in1 in2 in3 in4 in5">
> <wsdl:input message="impl:TestRequest" name="TestRequest"/>
> <wsdl:output message="impl:TestResponse" name="TestResponse"/>
> </wsdl:operation>
>
> I use Java to call the webservice, if I put null in parameter there are no
> problem, but if I put an array there are error. My source is:
>
> ............................
>  TypeMappingRegistry tmr = service.getTypeMappingRegistry();
>
>   QName xmlType = new QName("urn:test", "TestArray");
>
> //   get a TypeMapping (default for axis is SOAP encoding TypeMapping)
>   TypeMapping tm = tmr.getDefaultTypeMapping();
>
>
>   tm.register(ResponseCpgContext.class,
>               xmlType,
>               new BeanSerializerFactory(TestArray.class, xmlType),
>               new BeanDeserializerFactory(TestArray.class, xmlType));
>
>   xmlType = new QName("urn:test", "ArrayOfTestArray");
>     tm.register(TestArray[].class,
>                xmlType,
>                new ArraySerializerFactory(TestArray.class, xmlType),
>                new ArrayDeserializerFactory( xmlType));
>
> TestArray[] toto = new TestArray[1];
> myProxy.Test(toto);
> ...................................
>
> I have an axis fault with this code. Maybe is my serialization which is
> bad.
> Thanks.
>
>
>
>