Axis Webservice - RegisterTypeMapping

M

Matt

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.
 
A

Arne Vajhøj

Matt said:
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
 
T

thufir

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
 
A

Arne Vajhøj

thufir said:
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 ??

Arne
 
M

Matt

thufir said:
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 ??

Arne

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>.
 
A

Arne Vajhøj

Matt said:
thufir said:
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
 
T

thufir

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 ??

"
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
 
M

Matt

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 ??

"
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

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[]?
 
L

Lew

Matt said:
The WSDL defines a type "ArrayOfObjectA",
why will it not work to register ObjectA[]?

What is the limb when you try it?

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, degenerate, Zionism, racism, fascistm, genocide,
Illuminati, Freemason]

This address of Rabbinovich was published in the U.S. Publication
'Common Sense', and re-published in the September issue of the
Canadian Intelligence Service. Rabbi Rabbinovich speaking to an
assembly in Budapest, Hungary on the 12th January 1952 stated:

"We will openly reveal our identity with the races of Asia or Africa.
I can state with assurance that the last generation of white children
is now being born. Our control commission will, in the interests of
peace and wiping out inter-racial tensions, forbid the Whites to mate
with Whites.

The white women must co-habit with members of the dark races, the
White man with black women. Thus the White race will disappear,
for mixing the dark with the white means the end of the White Man,
and our most dangerous enemy will become only a memory.

We shall embark upon an era of ten thousand years of peace and
plenty, the Pax Judiaca, and OUR RACE will rule undisputed over
the world.

Our superior intelligence will enable us to retain mastery over a
world of dark peoples."

[Read a mind boggling article on degeneracy:
Message-ID: <[email protected]>
]
 
M

Matt

Matt said:
The WSDL defines a type "ArrayOfObjectA",
why will it not work to register ObjectA[]?

What is the error when you try it?

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

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

Matt

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top