users@jax-rpc.java.net

RE: Returning a Collection (List (LinkedList)) of java beans

From: Tim Lucia <timlucia_at_yahoo.com>
Date: Tue, 30 Mar 2004 13:47:36 -0500

Actually, it works only for the static stub. In the staticstub example,
I no longer get the "no deserializer" exception. In the dynamic proxy
example, I do. I added "-f:searchschema" to the ant targets
generate-interface and generate-stubs:

  <target name="generate-interface"
      description="Runs wscompile to generate the service endpoint
                   interface">
    <antcall target="run-wscompile">
      <param name="param1" value="-import -d ${build} -nd ${build}
      -f:norpcstructures -f:searchschema -classpath ${build}
${config.wsdl.file}"/>
    </antcall>
  </target>

  <target name="generate-stubs"
      description="Runs wscompile to generate the client stub classes">
    <antcall target="run-wscompile">
      <param name="param1" value="-gen:client -f:searchschema -d
${build}
      -classpath ${build} ${config.wsdl.file}"/>
    </antcall>
  </target>

These are the only two targets I saw being invoked. Did I miss one?

Tim


> -----Original Message-----
> From: Tim Lucia [mailto:timlucia_at_yahoo.com]
> Sent: Tuesday, March 30, 2004 1:36 PM
> To: users_at_jax-rpc.dev.java.net
> Subject: RE: Returning a Collection (List (LinkedList)) of java beans
>
>
> That does the trick, thanks! I'm a bit concerned that this
> was so difficult for me to figure out. Admittedly, I am a
> newbie to jax-rpc, but a more complete, complex example would
> have solved this problem for me while I still had hair ;-)
>
> Tim
>
>
> > -----Original Message-----
> > From: Doug Kohlert [mailto:Doug.Kohlert_at_Sun.COM]
> > Sent: Tuesday, March 30, 2004 1:21 PM
> > To: users_at_jax-rpc.dev.java.net
> > Subject: Re: Returning a Collection (List (LinkedList)) of
> java beans
> >
> >
> > Tim,
> > When generating your client from the WSDL did you use the
> > -f:searchschema flag?
> >
> > Tim Lucia wrote:
> >
> > >Hi,
> > >
> > >I've read all about how JAX-RPC (as supplied with JWSDP 1.3)
> > supports
> > >Collection classes, including List and LinkedList. I have
> > been trying
> > >(for several days) to return a LinkedList of beans from one of my
> > >functions. I can return a LinkedList of String objects without
> > >problem, but returing a list of my object always gives me a
> > >deserialization error.
> > >
> > >For simplicity, I have reproduced this using the tutorial
> > >'jaxrpc-hello' example, in both the static stub and dynamic proxy
> > >clients. I've extended this example to have a
> > "sayHelloList()" return
> > >a List of String objects (works) and a list of Foo objects
> (does not
> > >work.) I am using the ant build process in the tutorial otherwise
> > >untouched (except for including compilation units for
> > >Foo.java/Foo.class where necessary.) I also tried returning
> > an array
> > >of String (works) and an array of Foo (does not work).
> > >
> > >It has to be that I am missing some configuration
> something-or-other
> > >that tells the client that the List contains "Foo" objects,
> > while it is
> > >smart enough to figure out String on its own. I tried
> adding (to my
> > >config-interface.xml) <typeMappingRegistry><additionalTypes><class
> > >name="hello.Foo"/><class
> >
> >name="java.util.LinkedList"/></additionalTypes></typeMappingRegistry>
> > >which did not seem to help. I even made Foo implement
> Serializable
> > >which didn't change anything either.
> > >
> > >BTW, A single Foo getFoo() object DOES return Foo correctly.
> > >
> > >Thanks in advance for any input.
> > >Tim Lucia
> > >
> > >
> > >-----Foo.java-----
> > >/* A really simple Java Bean */
> > >package hello;
> > >public class Foo
> > >{
> > > private int intVal;
> > > private String stringVal = null;
> > >
> > > public void setStringVal(String val) { stringVal = val; }
> > > public String getStringVal() { return stringVal; }
> > > public void setIntVal(int val) { intVal = val; }
> > > public int getIntVal() { return intVal; }
> > > public String toString() { return intVal + ":" + stringVal; } }
> > >
> > >-----HelloIF.java-----
> > >package helloservice;
> > >
> > >import java.rmi.Remote;
> > >import java.rmi.RemoteException;
> > >
> > >public interface HelloIF extends Remote {
> > > public String sayHello(String s) throws RemoteException;
> > > public java.util.List sayHelloList(String s) throws
> > RemoteException;
> > > public java.util.List getFooList() throws RemoteException; }
> > >
> > >-----HelloImpl.java-----
> > >package helloservice;
> > >import hello.Foo;
> > >public class HelloImpl implements HelloIF {
> > >
> > > public String message = "Hello ";
> > >
> > > public String sayHello(String s) {
> > > return message + s;
> > > }
> > >
> > > public java.util.List sayHelloList(String s) {
> > > java.util.List list = new java.util.LinkedList();
> > > list.add(message);
> > > list.add(s);
> > > return list;
> > > }
> > >
> > > public java.util.List getFooList() {
> > > java.util.List list = new java.util.LinkedList();
> > > Foo
> > > foo = new Foo(); foo.setIntVal(1); foo.setStringVal("Tim");
> > >list.add(foo);
> > > foo = new Foo(); foo.setIntVal(1); foo.setStringVal("Tim");
> > >list.add(foo);
> > > foo = new Foo(); foo.setIntVal(1); foo.setStringVal("Tim");
> > >list.add(foo);
> > > foo = new Foo(); foo.setIntVal(1); foo.setStringVal("Tim");
> > >list.add(foo);
> > > return list;
> > > }
> > >}
> > >
> > >-----WSDL-----
> > ><?xml version="1.0" encoding="UTF-8"?>
> > ><definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
> > >xmlns:tns="urn:Foo"
> > xmlns:ns2="http://java.sun.com/jax-rpc-ri/internal"
> > >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > >xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > >name="MyHelloService" targetNamespace="urn:Foo">
> > > <types>
> > > <schema xmlns="http://www.w3.org/2001/XMLSchema"
> > >xmlns:tns="http://java.sun.com/jax-rpc-ri/internal"
> > >xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
> > >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > >targetNamespace="http://java.sun.com/jax-rpc-ri/internal">
> > > <import
> namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
> > > <import namespace="urn:Foo"/>
> > > <complexType name="list">
> > > <complexContent>
> > > <extension base="tns:collection">
> > > <sequence/></extension></complexContent></complexType>
> > > <complexType name="collection">
> > > <complexContent>
> > > <restriction base="soap11-enc:Array">
> > > <attribute ref="soap11-enc:arrayType"
> > >wsdl:arrayType="anyType[]"/></restriction></complexContent></
> > complexTyp
> > >e
> > >
> > >
> > > <complexType name="linkedList">
> > > <complexContent>
> > > <extension base="tns:list">
> > >
> > ><sequence/></extension></complexContent></complexType></schema>
> > > <schema xmlns="http://www.w3.org/2001/XMLSchema"
> > >xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
> > >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > targetNamespace="urn:Foo">
> > > <import
> namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
> > > <import namespace="http://java.sun.com/jax-rpc-ri/internal"/>
> > > <complexType name="Foo">
> > > <sequence>
> > > <element name="intVal" type="int"/>
> > > <element name="stringVal"
> > >type="string"/></sequence></complexType></schema></types>
> > > <message name="HelloIF_getFooList"/>
> > > <message name="HelloIF_getFooListResponse">
> > > <part name="result" type="ns2:list"/></message>
> > > <message name="HelloIF_sayHello">
> > > <part name="String_1" type="xsd:string"/></message>
> > > <message name="HelloIF_sayHelloResponse">
> > > <part name="result" type="xsd:string"/></message>
> > > <message name="HelloIF_sayHelloList">
> > > <part name="String_1" type="xsd:string"/></message>
> > > <message name="HelloIF_sayHelloListResponse">
> > > <part name="result" type="ns2:list"/></message>
> > > <portType name="HelloIF">
> > > <operation name="getFooList" parameterOrder="">
> > > <input message="tns:HelloIF_getFooList"/>
> > > <output
> message="tns:HelloIF_getFooListResponse"/></operation>
> > > <operation name="sayHello" parameterOrder="String_1">
> > > <input message="tns:HelloIF_sayHello"/>
> > > <output message="tns:HelloIF_sayHelloResponse"/></operation>
> > > <operation name="sayHelloList" parameterOrder="String_1">
> > > <input message="tns:HelloIF_sayHelloList"/>
> > > <output
> > >message="tns:HelloIF_sayHelloListResponse"/></operation></portType>
> > > <binding name="HelloIFBinding" type="tns:HelloIF">
> > > <operation name="getFooList">
> > > <input>
> > > <soap:body
> > >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="encoded"
> > >namespace="urn:Foo"/></input>
> > > <output>
> > > <soap:body
> > >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="encoded"
> > >namespace="urn:Foo"/></output>
> > > <soap:operation soapAction=""/></operation>
> > > <operation name="sayHello">
> > > <input>
> > > <soap:body
> > >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="encoded"
> > >namespace="urn:Foo"/></input>
> > > <output>
> > > <soap:body
> > >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="encoded"
> > >namespace="urn:Foo"/></output>
> > > <soap:operation soapAction=""/></operation>
> > > <operation name="sayHelloList">
> > > <input>
> > > <soap:body
> > >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="encoded"
> > >namespace="urn:Foo"/></input>
> > > <output>
> > > <soap:body
> > >encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="encoded"
> > >namespace="urn:Foo"/></output>
> > > <soap:operation soapAction=""/></operation>
> > > <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> > >style="rpc"/></binding>
> > > <service name="MyHelloService">
> > > <port name="HelloIFPort" binding="tns:HelloIFBinding">
> > > <soap:address xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > >location="http://127.0.0.1:8080/hello-jaxrpc/hello"/></port><
> > /service><
> > >/
> > >definitions>
> > >
> > >-----Ant run output-----
> > >
> > >E:\jwsdp-1.3\jwstutorial13\examples\jaxrpc\staticstub>\jwsdp-
> > 1.3\apache
> > >-
> > >ant\bin\ant run
> > >Buildfile: build.xml
> > >
> > >run-client:
> > > [java] Endpoint address =
> > http://localhost:8080/hello-jaxrpc/hello
> > > [java] Hello Duke!
> > > [java] 2
> > > [java] [0]=Hello
> > > [java] [1]=Tim!
> > > [java] java.rmi.RemoteException: Runtime exception; nested
> > >exception is:
> > > [java] deserialization error: deserialization error: no
> > >deserializer is registered for (null, {urn:Foo}Foo)
> > > [java] at
> > >com.sun.xml.rpc.client.StreamingSender._handleRuntimeExceptio
> > nInSend(St
> > >r
> > >eamingSender.java:248)
> > > [java] at
> > >com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.
> > java:230)
> > > [java] at
> > >staticstub.HelloIF_Stub.getFooList(HelloIF_Stub.java:67)
> > > [java] at staticstub.HelloClient.main(Unknown Source)
> > > [java] Caused by: deserialization error:
> > deserialization error: no
> > >deserializer is registered for (null, {urn:Foo}Foo)
> > > [java] at
> > >com.sun.xml.rpc.encoding.SOAPDeserializationContext.deseriali
> > zeMultiRefO
> > >bjects(SOAPDeserializationContext.java:82
> > >)
> > > [java] at
> > >com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.
> > java:163)
> > > [java] ... 2 more
> > >
> > >run:
> > >
> > >
> > >
> >
> >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> > >For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
> > >
> > >
> > >
> > >
> >
> > --
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Doug Kohlert
> >
> > Sun Microsystems, Inc.
> > 503-345-9806
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > NOTICE: This email message is for the sole use of the intended
> > recipient(s) and may contain confidential and privileged
> > information. Any unauthorized review, use, disclosure or
> > distribution is prohibited. If you are not the intended
> > recipient, please contact the sender by reply email and
> > destroy all copies of the original message.
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> > For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net