Axis Webservice - RegisterTypeMapping

Discussion in 'Java' started by Matt, Jul 25, 2008.

  1. Matt

    Matt Guest

    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.
     
    Matt, Jul 25, 2008
    #1
    1. Advertising

  2. Matt

    Arne Vajhøj Guest

    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
     
    Arne Vajhøj, Jul 27, 2008
    #2
    1. Advertising

  3. Matt

    thufir Guest

    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
     
    thufir, Jul 27, 2008
    #3
  4. 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 ??

    Arne
     
    Arne Vajhøj, Jul 27, 2008
    #4
  5. Matt

    Matt Guest

    On Jul 27, 10:02 am, Arne Vajhøj <> 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 ??
    >
    > 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>.
     
    Matt, Jul 27, 2008
    #5
  6. Matt

    Arne Vajhøj Guest

    Matt wrote:
    > On Jul 27, 10:02 am, Arne Vajhøj <> 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
     
    Arne Vajhøj, Jul 27, 2008
    #6
  7. Matt

    thufir Guest

    On Sun, 27 Jul 2008 10:02:34 -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 ??


    "
    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
     
    thufir, Jul 28, 2008
    #7
  8. Matt

    Matt Guest

    On Jul 28, 12:43 am, thufir <> wrote:
    > On Sun, 27 Jul 2008 10:02:34 -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 ??

    >
    > "
    > 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[]?
     
    Matt, Jul 28, 2008
    #8
  9. Matt

    Lew Guest

    Matt wrote:
    > 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: <>
    ]
     
    Lew, Jul 29, 2008
    #9
  10. Matt

    Matt Guest

    On Jul 28, 8:22 pm, Lew <com.lewscanon@lew> wrote:
    > 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


    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, Jul 29, 2008
    #10
  11. Matt

    Matt Guest

    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>
     
    Matt, Jul 29, 2008
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joey Vendetta
    Replies:
    0
    Views:
    3,459
    Joey Vendetta
    Apr 1, 2004
  2. Stefan
    Replies:
    0
    Views:
    742
    Stefan
    May 6, 2004
  3. Replies:
    0
    Views:
    945
  4. hocho888
    Replies:
    1
    Views:
    657
  5. Cyril
    Replies:
    2
    Views:
    4,515
    Cyril
    Jun 1, 2006
Loading...

Share This Page