Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Axis Webservice - RegisterTypeMapping

0 views
Skip to first unread message

Matt

unread,
Jul 25, 2008, 2:43:18 PM7/25/08
to
Hello,

I am trying to access a webservice via Axis and having problems with
registering my type mappings.

I have two different Lists that I need mapped: List<ObjectA> and
List<ObjectB>. However, I can only register one type mapping for
List.class. It only picks up the last one registered.

<code>
call.registerTypeMapping(java.util.List.class, objectAqname, new
ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));

call.registerTypeMapping(java.util.List.class, objectBqname, new
ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
</code>

I am stumped and would appreciate any and all help. Please let me know
if you need more info.
Thanks.

Arne Vajhøj

unread,
Jul 26, 2008, 10:09:30 PM7/26/08
to
Matt wrote:
> I am trying to access a webservice via Axis and having problems with
> registering my type mappings.
>
> I have two different Lists that I need mapped: List<ObjectA> and
> List<ObjectB>. However, I can only register one type mapping for
> List.class. It only picks up the last one registered.
>
> <code>
> call.registerTypeMapping(java.util.List.class, objectAqname, new
> ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
>
> call.registerTypeMapping(java.util.List.class, objectBqname, new
> ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
> </code>

I think this is how it has to be considering type erasure.

If you return ObjectA[] and ObjectB[] then I think you can
do it.

Arne

thufir

unread,
Jul 27, 2008, 12:18:24 AM7/27/08
to
On Sat, 26 Jul 2008 22:09:30 -0400, Arne Vajhøj wrote:

>> I have two different Lists that I need mapped: List<ObjectA> and
>> List<ObjectB>. However, I can only register one type mapping for
>> List.class. It only picks up the last one registered.
>>
>> <code>
>> call.registerTypeMapping(java.util.List.class, objectAqname, new
>> ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
>>
>> call.registerTypeMapping(java.util.List.class, objectBqname, new
>> ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
>> </code>
>
> I think this is how it has to be considering type erasure.
>
> If you return ObjectA[] and ObjectB[] then I think you can do it.
>
> Arne


Would wildcards help?


-Thufir

Arne Vajhøj

unread,
Jul 27, 2008, 10:02:34 AM7/27/08
to
> Would wildcards help?

Wildcards ??

Arne

Matt

unread,
Jul 27, 2008, 5:30:02 PM7/27/08
to

I dont know what you mean by wildcards either. And I cannot return
ObjectA[] or ObjectB[]. I am actually returning a different object,
ObjectC, which has two properties, List<ObjectA> and List<ObjectB>.

Arne Vajhøj

unread,
Jul 27, 2008, 6:05:54 PM7/27/08
to
Matt wrote:
> On Jul 27, 10:02 am, Arne Vajhøj <a...@vajhoej.dk> wrote:
>> thufir wrote:
>>> On Sat, 26 Jul 2008 22:09:30 -0400, Arne Vajhøj wrote:
>>>>> I have two different Lists that I need mapped: List<ObjectA> and
>>>>> List<ObjectB>. However, I can only register one type mapping for
>>>>> List.class. It only picks up the last one registered.
>>>>> <code>
>>>>> call.registerTypeMapping(java.util.List.class, objectAqname, new
>>>>> ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
>>>>> call.registerTypeMapping(java.util.List.class, objectBqname, new
>>>>> ArraySerializerFactory(), new ArrayDeserializerFactory(hostqname));
>>>>> </code>
>>>> I think this is how it has to be considering type erasure.
>>>> If you return ObjectA[] and ObjectB[] then I think you can do it.
>>> Would wildcards help?
>> Wildcards ??
>
> I dont know what you mean by wildcards either. And I cannot return
> ObjectA[] or ObjectB[]. I am actually returning a different object,
> ObjectC, which has two properties, List<ObjectA> and List<ObjectB>.

Make an ObjectCExternal that contains ObjectA[] and ObjectB[].

Arne

thufir

unread,
Jul 28, 2008, 12:43:46 AM7/28/08
to

"
public void drawAll(List<? extends Shape> shapes) { ... }
There is a small but very important difference here: we have replaced
the type
List<Shape> with List<? extends Shape>. Now drawAll() will accept lists of
any subclass of Shape, so we can now call it on a List<Circle> if we
want."


Generics in the Java Programming Language
Gilad Bracha
July 5, 2004

page 6

Instead of List<ObjectA> how about List<? extends ParentOfAB>. Or not?

-Thufir

Matt

unread,
Jul 28, 2008, 10:15:57 AM7/28/08
to

Hmmmmm, That is something I will consider.

But why do I have to register the List class anyway? The WSDL defines
a type "ArrayOfObjectA", why will it not work to register ObjectA[]?

Lew

unread,
Jul 28, 2008, 8:22:15 PM7/28/08
to
Matt wrote:
> The WSDL defines a type "ArrayOfObjectA",
> why will it not work to register ObjectA[]?

What is the error when you try it?

--
Lew

Matt

unread,
Jul 29, 2008, 8:32:42 AM7/29/08
to

I get a NullPointerException when it tries to deserialize
ArrayOfObjectA as ObjectA[].

I can get past this point by registering ArrayOfObjectA with
List.class...

Matt

unread,
Jul 29, 2008, 8:51:49 AM7/29/08
to
Here is my simplified WSDL...

<xsd:complexType name="ArrayOfMainObject">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="TraceRoute"
nillable="true" type="ns1:MainObject"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="MainObject">
<xsd:sequence>
<xsd:element minOccurs="0" name="id" nillable="true"
type="xsd:string"/>
<xsd:element minOccurs="0" name="objectA" nillable="true"
type="ns1:ArrayOfObjectA"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfObjectA">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Hops"
nillable="true" type="ns1:ObjectA"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ObjectA">
<xsd:sequence>
<xsd:element minOccurs="0" name="id" nillable="true"
type="xsd:string"/>
<xsd:element minOccurs="0" name="objectB" nillable="true"
type="ns1:ArrayOfObjectB"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfObjectB">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Host"
nillable="true" type="ns1:ObjectB"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ObjectB">
<xsd:sequence>
<xsd:element minOccurs="0" name="hostId" nillable="true"
type="xsd:string"/>
<xsd:element minOccurs="0" name="field1" nillable="true"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

0 new messages