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 Phil Wilson <p....@zoo-tech.com> on 2004/06/23 16:47:12 UTC

FW: String[] in complex type was returned as null

Hi all,

Some time after posting my question to the newsgroup (at bottom of mail), I
got a reply from Achim Abeling outlining a possible solution.

I'm actually working on a different project at the moment and so haven't
been able to test whether this is actually the right solution, but since it
might be some time before I get to try it out, I thought it worth posting in
case it could help someone else.

Cheers,

Phil

-----Original Message-----
From: Achim Abeling
Sent: 15 June 2004 15:33
To: p.wilson@zoo-tech.com
Subject: Re: String[] in complex type was returned as null

Hi Phil,

i got the same problem with a String array.

After a lot of debugging in the Axis code I found that the 
BeanDeserializer did not find an appropriate Deserializer for my String 
array. In my case the SOAP element lacked an xsi:type attribute which 
was the cause, I think.

I managed to get my code doing what I want by
- adding a org.apache.axis.description.TypeDesc for my custom bean. I 
got a hint for that by generating code with wsdl2java and inspecting the 
code created for the bean
- registering a TypeMapping for the String array in the call
call.registerTypeMapping(
	String[].class,
	new javax.xml.namespace.QName(
		"http://www.w3.org/2001/XMLSchema",
		"string[]"),
	ArraySerializerFactory.class,
	ArrayDeserializerFactory.class);

Perhaps this helps you, too.

I did not manage to mail this directly to the mailing list because I do 
not have the original mail. I only saw your post at 
http://marc.theaimsgroup.com

If you find my answer useful, perhaps you can mail to the mailing list.

Best regards
Achim Abeling

> Hi all,
> 
> I've tried looking for this in the archive, but haven't had any luck, so
my
> appologies if this has already been answered.
> 
> I have a soap call which returns an object which contains an integer and a
> string array. 
> 
> When I call it the response *looks* fine[3] (via TCPMon), and the integer
> value in the returned object is correct but the string array is null.
There
> aren't any exceptions thrown (I'm using Axis 1.1 and originally thought
this
> could be http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15384 "Error
> deserializing array in custom datatype" but that seems to always throw a
> SAXException, which I'm not getting).
> 
> Anybody have any ideas what might help solve this? I've included the
> WSDD[1], the client code[2] and the server response[3] below.
> 
> Thanks for your time,
> 
> Phil
> 
> [1] The server-config.wsdd:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
> 	<globalConfiguration>
> 		<parameter name="sendMultiRefs" value="true"/>
> 		<parameter name="sendXsiTypes" value="true"/>
> 		<parameter name="sendXMLDeclaration" value="true"/>
> 		<parameter name="axis.sendMinimizedElements" value="true"/>
> 	</globalConfiguration>
> 
> 	<handler name="LocalResponder"
> type="java:org.apache.axis.transport.local.LocalResponder"/>
> 
> 	<handler name="URLMapper"
> type="java:org.apache.axis.handlers.http.URLMapper"/>
> 
> 	<handler name="Authenticate"
> type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
> 
> 	<service name="SomeService" provider="java:RPC">
> 		<parameter name="allowedMethods" value="*"/>
> 		<parameter name="className" 
>         <beanMapping qname="zooNS:MyObject" xmlns:zooNS="urn:SomeService"
> languageSpecificType="java:MyObject"/>
> 	</service>
> 
> 	<transport name="http">
> 		<requestFlow>
> 			<handler type="URLMapper"/>
> 			<handler
> type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
> 		</requestFlow>
> 	</transport>
> 
> 	<transport name="local">
> 		<responseFlow>
> 			<handler type="LocalResponder"/>
> 		</responseFlow>
> 	</transport>
> 
> </deployment>
> 
> [2] The client code:
> 
> MyObject ret = new MyObject();
> 
> Service service = new Service();
> Call call = (Call) service.createCall();
> QName qn = new QName("urn:SomeService", "MyObject");
> call.registerTypeMapping(MyObject.class, qn,
>                          new
> org.apache.axis.encoding.ser.BeanSerializerFactory(MyObject.class, qn),
>                          new
> org.apache.axis.encoding.ser.BeanDeserializerFactory(MyObject.class, qn));
> 
> call.setTargetEndpointAddress(new java.net.URL(m_endPoint));
> call.setOperationName(new QName("SomeService", "getMyObject"));
> 
> call.setReturnClass(MyObject.class);
> 
> Object[] params = new Object[3];
> 
> params[0] = new Integer(intVal1);
> params[1] = new Integer(intVal2);
> params[2] = someString;
> 
> ret = (MyObject) call.invoke(params);
> 
> if (ret.getStringArray()==null) 
> {
>   // always gets into here
>   log.info("Array returned null"); 
> }
> 
> [3] The response from the server:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>  <soapenv:Body>
>   <ns1:getMyObjectResponse
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns1="SomeService">
>    <ns1:getMyObject href="#id0"/>
>   </ns1:getMyObjectResponse>
>   <multiRef id="id0" soapenc:root="0"
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xsi:type="ns2:M" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns2="urn:SomeService">
>    <stringArray xsi:type="soapenc:Array"
soapenc:arrayType="xsd:string[3]">
>     <item>Quiz</item>
>     <item>Badger</item>
>     <item>AnotherName</item>
>    </stringArray>
>    <returnCode xsi:type="xsd:int">32</returnCode>
>   </multiRef>
>  </soapenv:Body>
> </soapenv:Envelope>
> 
> 

-- 
Achim Abeling
Software Developer

SPLENDID Internet GmbH & Co KG
An der Halle 400 1, 24143 Kiel, Germany
Tel. +49 (0) 431 66097-0, Fax: +49 (0) 431 66097-20
Deelbogenkamp 4c, 22297 Hamburg, Germany
Tel. +49 (0) 40 325272-49, Fax +49 (0) 40 325272-50
www.splendid.de