You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by David Turner <tu...@genome.wi.mit.edu> on 2001/10/25 16:25:23 UTC

Serializers/Deserializers

I've been trying to develop my own serializer & deserializer for some
java classes such as the
java.net.URL class in order to pass URL's to a service method, but the
server sends back a fault:
      Fault Code = SOAP-ENV:Server.Exception:
      Fault String = org/apache/soap/util/xml/Deserializer

I've attempted to write serializers/deserializers for a simple class
also (class contains only Strings) instead of using the BeanSerializer
and I
still get the above exception.

This is a critical issue...

Below is the code:

Deployment Descriptor
--------------------------------------------------------------------------------------------------------------

<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
             id="urn:SimpleURLService">
  <isd:provider type="java"
                scope="Session"
                methods="serviceMethod">
    <isd:java
class="examples.omnitide.SimpleURLService.SimpleURLService"
static="false"/>
  </isd:provider>


<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>

  <isd:mappings>
    <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:xsd="http://www.w3.org/1999/XMLSchema"
qname="xsd:URL"
             javaType="java.net.URL"

xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>

  </isd:mappings>

</isd:service>



Client that calls soap service
--------------------------------------------------------------------------------------------------------------

      // Map the types
       SOAPMappingRegistry smr = new SOAPMappingRegistry();

       URLSerializer ser = new URLSerializer();
       URLDeserializer des = new URLDeserializer();

       smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
QName("urn:SimpleURLService", "URL"),
           URL.class, ser, des);

       // Build the call
       Call call = new Call();
       call.setSOAPMappingRegistry(smr);
       call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
       call.setTargetObjectURI("urn:SimpleURLService");
       call.setMethodName("serviceMethod");

       Vector params = new Vector();
       params.addElement(new Parameter("request", URL.class, url,
null));
       call.setParams(params);



Serializer
--------------------------------------------------------------------------------------------------------------

import java.net.URL;

public class URLSerializer implements Serializer
{

  public void marshall(String inScopeEncStyle, Class javaType, Object
src,
                       Object context, Writer sink, NSStack nsStack,
                       XMLJavaMappingRegistry xjmr, SOAPContext ctx)
                        throws IllegalArgumentException, IOException
  {
      nsStack.pushScope();

      SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
context,
                                          sink, nsStack, xjmr);

      sink.write(StringUtils.lineSeparator);

      URL src2 = (URL) src;

      Parameter param;

      param = new Parameter("URL", String.class, src2.toString(), null);

      xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
                    sink, nsStack, ctx);
      sink.write(StringUtils.lineSeparator);

      sink.write("</" + context + ">");

      nsStack.popScope();
  }
}



Deserializer
--------------------------------------------------------------------------------------------------------------

public class URLDeserializer implements Deserializer
{
  public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
src,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
                          throws IllegalArgumentException
  {
    Element root = (Element)src;
    Element tempEl = DOMUtils.getFirstChildElement(root);

    URL url = null;

    while (tempEl != null)
    {
        Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
RPCConstants.Q_ELEM_PARAMETER,
                                         tempEl, ctx);
        Parameter param = (Parameter)paramBean.value;
        String tagName = tempEl.getTagName();

        if (tagName.equals("URL"))
        {
            try
            {
                url = new URL( (String)param.getValue() );
            }
            catch (Exception e)
            {
                throw new IllegalArgumentException("Problem
instantianting bean: " + e.getMessage());
            }

        }

        tempEl = DOMUtils.getNextSiblingElement(tempEl);
    }


    return new Bean(URL.class, url);
  }
}

Re: Serializers/Deserializers

Posted by Scott Nichol <sn...@computer.org>.
There is class loader info at
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
although some of the info there for 4.0 already seems to be out of date for
4.0.1.

Scott

----- Original Message -----
From: "David Turner" <tu...@genome.wi.mit.edu>
To: <so...@xml.apache.org>
Sent: Thursday, October 25, 2001 10:25 AM
Subject: Serializers/Deserializers


> I've been trying to develop my own serializer & deserializer for some
> java classes such as the
> java.net.URL class in order to pass URL's to a service method, but the
> server sends back a fault:
>       Fault Code = SOAP-ENV:Server.Exception:
>       Fault String = org/apache/soap/util/xml/Deserializer
>
> I've attempted to write serializers/deserializers for a simple class
> also (class contains only Strings) instead of using the BeanSerializer
> and I
> still get the above exception.
>
> This is a critical issue...
>
> Below is the code:
>
> Deployment Descriptor
> --------------------------------------------------------------------------
------------------------------------
>
> <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
>              id="urn:SimpleURLService">
>   <isd:provider type="java"
>                 scope="Session"
>                 methods="serviceMethod">
>     <isd:java
> class="examples.omnitide.SimpleURLService.SimpleURLService"
> static="false"/>
>   </isd:provider>
>
>
>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
r>
>
>   <isd:mappings>
>     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> qname="xsd:URL"
>              javaType="java.net.URL"
>
> xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
>
>   </isd:mappings>
>
> </isd:service>
>
>
>
> Client that calls soap service
> --------------------------------------------------------------------------
------------------------------------
>
>       // Map the types
>        SOAPMappingRegistry smr = new SOAPMappingRegistry();
>
>        URLSerializer ser = new URLSerializer();
>        URLDeserializer des = new URLDeserializer();
>
>        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> QName("urn:SimpleURLService", "URL"),
>            URL.class, ser, des);
>
>        // Build the call
>        Call call = new Call();
>        call.setSOAPMappingRegistry(smr);
>        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>        call.setTargetObjectURI("urn:SimpleURLService");
>        call.setMethodName("serviceMethod");
>
>        Vector params = new Vector();
>        params.addElement(new Parameter("request", URL.class, url,
> null));
>        call.setParams(params);
>
>
>
> Serializer
> --------------------------------------------------------------------------
------------------------------------
>
> import java.net.URL;
>
> public class URLSerializer implements Serializer
> {
>
>   public void marshall(String inScopeEncStyle, Class javaType, Object
> src,
>                        Object context, Writer sink, NSStack nsStack,
>                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>                         throws IllegalArgumentException, IOException
>   {
>       nsStack.pushScope();
>
>       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> context,
>                                           sink, nsStack, xjmr);
>
>       sink.write(StringUtils.lineSeparator);
>
>       URL src2 = (URL) src;
>
>       Parameter param;
>
>       param = new Parameter("URL", String.class, src2.toString(), null);
>
>       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
>                     sink, nsStack, ctx);
>       sink.write(StringUtils.lineSeparator);
>
>       sink.write("</" + context + ">");
>
>       nsStack.popScope();
>   }
> }
>
>
>
> Deserializer
> --------------------------------------------------------------------------
------------------------------------
>
> public class URLDeserializer implements Deserializer
> {
>   public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
> src,
>                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>                           throws IllegalArgumentException
>   {
>     Element root = (Element)src;
>     Element tempEl = DOMUtils.getFirstChildElement(root);
>
>     URL url = null;
>
>     while (tempEl != null)
>     {
>         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> RPCConstants.Q_ELEM_PARAMETER,
>                                          tempEl, ctx);
>         Parameter param = (Parameter)paramBean.value;
>         String tagName = tempEl.getTagName();
>
>         if (tagName.equals("URL"))
>         {
>             try
>             {
>                 url = new URL( (String)param.getValue() );
>             }
>             catch (Exception e)
>             {
>                 throw new IllegalArgumentException("Problem
> instantianting bean: " + e.getMessage());
>             }
>
>         }
>
>         tempEl = DOMUtils.getNextSiblingElement(tempEl);
>     }
>
>
>     return new Bean(URL.class, url);
>   }
> }


Re: Serializers/Deserializers

Posted by Scott Nichol <sn...@computer.org>.
Good to hear you conquered the problem.  I just downloaded 4.0.1 the other
day and was interested to see the things that changed, such as the libs
already in the path ready for servlets to use, and the "standards" for where
to put shared code.  It's nice to not toy with the startup scripts at all.

Scott

----- Original Message -----
From: "David Turner" <tu...@genome.wi.mit.edu>
To: <so...@xml.apache.org>
Sent: Friday, October 26, 2001 9:25 AM
Subject: Re: Serializers/Deserializers


> Hi Scott,
> Thanks for getting back to me.
> I did manage to figure out why it wasn't working -- I changed tomcats
classpath
> to point to my stuff and it didn't like this.  I jar'ed things up and
placed it
> in WEB/INF/lib of soap and it worked fine.  Going the classpath route, the
> service class was found but any supporting classes were having the problem
of
> not be found.
> I'll have to read up on tomcats classloader.
> Thanks again.
>
> Scott Nichol wrote:
>
> > From where is the URLSerializer loaded?  Is it a class in
WEB-INF/classes,
> > in a jar in WEB-INF/lib or somewhere in the servlet container classpath?
If
> > it is the last of these, I would recommend you try one of the other two.
> > This is a *guess*, but I still have not got a full grip on the different
> > class loading schemes used within the container.
> >
> > Scott
> >
> > ----- Original Message -----
> > From: "David Turner" <tu...@genome.wi.mit.edu>
> > To: <so...@xml.apache.org>
> > Sent: Thursday, October 25, 2001 10:25 AM
> > Subject: Serializers/Deserializers
> >
> > > I've been trying to develop my own serializer & deserializer for some
> > > java classes such as the
> > > java.net.URL class in order to pass URL's to a service method, but the
> > > server sends back a fault:
> > >       Fault Code = SOAP-ENV:Server.Exception:
> > >       Fault String = org/apache/soap/util/xml/Deserializer
> > >
> > > I've attempted to write serializers/deserializers for a simple class
> > > also (class contains only Strings) instead of using the BeanSerializer
> > > and I
> > > still get the above exception.
> > >
> > > This is a critical issue...
> > >
> > > Below is the code:
> > >
> > > Deployment Descriptor
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > > <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
> > >              id="urn:SimpleURLService">
> > >   <isd:provider type="java"
> > >                 scope="Session"
> > >                 methods="serviceMethod">
> > >     <isd:java
> > > class="examples.omnitide.SimpleURLService.SimpleURLService"
> > > static="false"/>
> > >   </isd:provider>
> > >
> > >
> > >
> >
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
> > r>
> > >
> > >   <isd:mappings>
> > >     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > >              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> > > qname="xsd:URL"
> > >              javaType="java.net.URL"
> > >
> > >
xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
> > >
> > >   </isd:mappings>
> > >
> > > </isd:service>
> > >
> > >
> > >
> > > Client that calls soap service
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > >       // Map the types
> > >        SOAPMappingRegistry smr = new SOAPMappingRegistry();
> > >
> > >        URLSerializer ser = new URLSerializer();
> > >        URLDeserializer des = new URLDeserializer();
> > >
> > >        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> > > QName("urn:SimpleURLService", "URL"),
> > >            URL.class, ser, des);
> > >
> > >        // Build the call
> > >        Call call = new Call();
> > >        call.setSOAPMappingRegistry(smr);
> > >        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> > >        call.setTargetObjectURI("urn:SimpleURLService");
> > >        call.setMethodName("serviceMethod");
> > >
> > >        Vector params = new Vector();
> > >        params.addElement(new Parameter("request", URL.class, url,
> > > null));
> > >        call.setParams(params);
> > >
> > >
> > >
> > > Serializer
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > > import java.net.URL;
> > >
> > > public class URLSerializer implements Serializer
> > > {
> > >
> > >   public void marshall(String inScopeEncStyle, Class javaType, Object
> > > src,
> > >                        Object context, Writer sink, NSStack nsStack,
> > >                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> > >                         throws IllegalArgumentException, IOException
> > >   {
> > >       nsStack.pushScope();
> > >
> > >       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> > > context,
> > >                                           sink, nsStack, xjmr);
> > >
> > >       sink.write(StringUtils.lineSeparator);
> > >
> > >       URL src2 = (URL) src;
> > >
> > >       Parameter param;
> > >
> > >       param = new Parameter("URL", String.class, src2.toString(),
null);
> > >
> > >       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
> > >                     sink, nsStack, ctx);
> > >       sink.write(StringUtils.lineSeparator);
> > >
> > >       sink.write("</" + context + ">");
> > >
> > >       nsStack.popScope();
> > >   }
> > > }
> > >
> > >
> > >
> > > Deserializer
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > > public class URLDeserializer implements Deserializer
> > > {
> > >   public Bean unmarshall(String inScopeEncStyle, QName elementType,
Node
> > > src,
> > >                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> > >                           throws IllegalArgumentException
> > >   {
> > >     Element root = (Element)src;
> > >     Element tempEl = DOMUtils.getFirstChildElement(root);
> > >
> > >     URL url = null;
> > >
> > >     while (tempEl != null)
> > >     {
> > >         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> > > RPCConstants.Q_ELEM_PARAMETER,
> > >                                          tempEl, ctx);
> > >         Parameter param = (Parameter)paramBean.value;
> > >         String tagName = tempEl.getTagName();
> > >
> > >         if (tagName.equals("URL"))
> > >         {
> > >             try
> > >             {
> > >                 url = new URL( (String)param.getValue() );
> > >             }
> > >             catch (Exception e)
> > >             {
> > >                 throw new IllegalArgumentException("Problem
> > > instantianting bean: " + e.getMessage());
> > >             }
> > >
> > >         }
> > >
> > >         tempEl = DOMUtils.getNextSiblingElement(tempEl);
> > >     }
> > >
> > >
> > >     return new Bean(URL.class, url);
> > >   }
> > > }
>
> --
> David Turner <tu...@genome.wi.mit.edu>
> Senior Software Engineer
> Whitehead Institute/MIT Center for Genome Research
> One Kendall Square, Bldg. 300
> Cambridge, MA 02139-1561 USA
> phone 617-252-1573 / fax 617-252-1902
>
>


Re: Serializers/Deserializers

Posted by Scott Nichol <sn...@computer.org>.
Good to hear you conquered the problem.  I just downloaded 4.0.1 the other
day and was interested to see the things that changed, such as the libs
already in the path ready for servlets to use, and the "standards" for where
to put shared code.  It's nice to not toy with the startup scripts at all.

Scott

----- Original Message -----
From: "David Turner" <tu...@genome.wi.mit.edu>
To: <so...@xml.apache.org>
Sent: Friday, October 26, 2001 9:25 AM
Subject: Re: Serializers/Deserializers


> Hi Scott,
> Thanks for getting back to me.
> I did manage to figure out why it wasn't working -- I changed tomcats
classpath
> to point to my stuff and it didn't like this.  I jar'ed things up and
placed it
> in WEB/INF/lib of soap and it worked fine.  Going the classpath route, the
> service class was found but any supporting classes were having the problem
of
> not be found.
> I'll have to read up on tomcats classloader.
> Thanks again.
>
> Scott Nichol wrote:
>
> > From where is the URLSerializer loaded?  Is it a class in
WEB-INF/classes,
> > in a jar in WEB-INF/lib or somewhere in the servlet container classpath?
If
> > it is the last of these, I would recommend you try one of the other two.
> > This is a *guess*, but I still have not got a full grip on the different
> > class loading schemes used within the container.
> >
> > Scott
> >
> > ----- Original Message -----
> > From: "David Turner" <tu...@genome.wi.mit.edu>
> > To: <so...@xml.apache.org>
> > Sent: Thursday, October 25, 2001 10:25 AM
> > Subject: Serializers/Deserializers
> >
> > > I've been trying to develop my own serializer & deserializer for some
> > > java classes such as the
> > > java.net.URL class in order to pass URL's to a service method, but the
> > > server sends back a fault:
> > >       Fault Code = SOAP-ENV:Server.Exception:
> > >       Fault String = org/apache/soap/util/xml/Deserializer
> > >
> > > I've attempted to write serializers/deserializers for a simple class
> > > also (class contains only Strings) instead of using the BeanSerializer
> > > and I
> > > still get the above exception.
> > >
> > > This is a critical issue...
> > >
> > > Below is the code:
> > >
> > > Deployment Descriptor
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > > <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
> > >              id="urn:SimpleURLService">
> > >   <isd:provider type="java"
> > >                 scope="Session"
> > >                 methods="serviceMethod">
> > >     <isd:java
> > > class="examples.omnitide.SimpleURLService.SimpleURLService"
> > > static="false"/>
> > >   </isd:provider>
> > >
> > >
> > >
> >
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
> > r>
> > >
> > >   <isd:mappings>
> > >     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > >              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> > > qname="xsd:URL"
> > >              javaType="java.net.URL"
> > >
> > >
xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
> > >
> > >   </isd:mappings>
> > >
> > > </isd:service>
> > >
> > >
> > >
> > > Client that calls soap service
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > >       // Map the types
> > >        SOAPMappingRegistry smr = new SOAPMappingRegistry();
> > >
> > >        URLSerializer ser = new URLSerializer();
> > >        URLDeserializer des = new URLDeserializer();
> > >
> > >        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> > > QName("urn:SimpleURLService", "URL"),
> > >            URL.class, ser, des);
> > >
> > >        // Build the call
> > >        Call call = new Call();
> > >        call.setSOAPMappingRegistry(smr);
> > >        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> > >        call.setTargetObjectURI("urn:SimpleURLService");
> > >        call.setMethodName("serviceMethod");
> > >
> > >        Vector params = new Vector();
> > >        params.addElement(new Parameter("request", URL.class, url,
> > > null));
> > >        call.setParams(params);
> > >
> > >
> > >
> > > Serializer
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > > import java.net.URL;
> > >
> > > public class URLSerializer implements Serializer
> > > {
> > >
> > >   public void marshall(String inScopeEncStyle, Class javaType, Object
> > > src,
> > >                        Object context, Writer sink, NSStack nsStack,
> > >                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> > >                         throws IllegalArgumentException, IOException
> > >   {
> > >       nsStack.pushScope();
> > >
> > >       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> > > context,
> > >                                           sink, nsStack, xjmr);
> > >
> > >       sink.write(StringUtils.lineSeparator);
> > >
> > >       URL src2 = (URL) src;
> > >
> > >       Parameter param;
> > >
> > >       param = new Parameter("URL", String.class, src2.toString(),
null);
> > >
> > >       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
> > >                     sink, nsStack, ctx);
> > >       sink.write(StringUtils.lineSeparator);
> > >
> > >       sink.write("</" + context + ">");
> > >
> > >       nsStack.popScope();
> > >   }
> > > }
> > >
> > >
> > >
> > > Deserializer
> >
> --------------------------------------------------------------------------
> > ------------------------------------
> > >
> > > public class URLDeserializer implements Deserializer
> > > {
> > >   public Bean unmarshall(String inScopeEncStyle, QName elementType,
Node
> > > src,
> > >                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> > >                           throws IllegalArgumentException
> > >   {
> > >     Element root = (Element)src;
> > >     Element tempEl = DOMUtils.getFirstChildElement(root);
> > >
> > >     URL url = null;
> > >
> > >     while (tempEl != null)
> > >     {
> > >         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> > > RPCConstants.Q_ELEM_PARAMETER,
> > >                                          tempEl, ctx);
> > >         Parameter param = (Parameter)paramBean.value;
> > >         String tagName = tempEl.getTagName();
> > >
> > >         if (tagName.equals("URL"))
> > >         {
> > >             try
> > >             {
> > >                 url = new URL( (String)param.getValue() );
> > >             }
> > >             catch (Exception e)
> > >             {
> > >                 throw new IllegalArgumentException("Problem
> > > instantianting bean: " + e.getMessage());
> > >             }
> > >
> > >         }
> > >
> > >         tempEl = DOMUtils.getNextSiblingElement(tempEl);
> > >     }
> > >
> > >
> > >     return new Bean(URL.class, url);
> > >   }
> > > }
>
> --
> David Turner <tu...@genome.wi.mit.edu>
> Senior Software Engineer
> Whitehead Institute/MIT Center for Genome Research
> One Kendall Square, Bldg. 300
> Cambridge, MA 02139-1561 USA
> phone 617-252-1573 / fax 617-252-1902
>
>


Re: Serializers/Deserializers

Posted by David Turner <tu...@genome.wi.mit.edu>.
Hi Scott,
Thanks for getting back to me.
I did manage to figure out why it wasn't working -- I changed tomcats classpath
to point to my stuff and it didn't like this.  I jar'ed things up and placed it
in WEB/INF/lib of soap and it worked fine.  Going the classpath route, the
service class was found but any supporting classes were having the problem of
not be found.
I'll have to read up on tomcats classloader.
Thanks again.

Scott Nichol wrote:

> From where is the URLSerializer loaded?  Is it a class in WEB-INF/classes,
> in a jar in WEB-INF/lib or somewhere in the servlet container classpath?  If
> it is the last of these, I would recommend you try one of the other two.
> This is a *guess*, but I still have not got a full grip on the different
> class loading schemes used within the container.
>
> Scott
>
> ----- Original Message -----
> From: "David Turner" <tu...@genome.wi.mit.edu>
> To: <so...@xml.apache.org>
> Sent: Thursday, October 25, 2001 10:25 AM
> Subject: Serializers/Deserializers
>
> > I've been trying to develop my own serializer & deserializer for some
> > java classes such as the
> > java.net.URL class in order to pass URL's to a service method, but the
> > server sends back a fault:
> >       Fault Code = SOAP-ENV:Server.Exception:
> >       Fault String = org/apache/soap/util/xml/Deserializer
> >
> > I've attempted to write serializers/deserializers for a simple class
> > also (class contains only Strings) instead of using the BeanSerializer
> > and I
> > still get the above exception.
> >
> > This is a critical issue...
> >
> > Below is the code:
> >
> > Deployment Descriptor
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> > <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
> >              id="urn:SimpleURLService">
> >   <isd:provider type="java"
> >                 scope="Session"
> >                 methods="serviceMethod">
> >     <isd:java
> > class="examples.omnitide.SimpleURLService.SimpleURLService"
> > static="false"/>
> >   </isd:provider>
> >
> >
> >
> <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
> r>
> >
> >   <isd:mappings>
> >     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> > qname="xsd:URL"
> >              javaType="java.net.URL"
> >
> > xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
> >
> >   </isd:mappings>
> >
> > </isd:service>
> >
> >
> >
> > Client that calls soap service
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> >       // Map the types
> >        SOAPMappingRegistry smr = new SOAPMappingRegistry();
> >
> >        URLSerializer ser = new URLSerializer();
> >        URLDeserializer des = new URLDeserializer();
> >
> >        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> > QName("urn:SimpleURLService", "URL"),
> >            URL.class, ser, des);
> >
> >        // Build the call
> >        Call call = new Call();
> >        call.setSOAPMappingRegistry(smr);
> >        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> >        call.setTargetObjectURI("urn:SimpleURLService");
> >        call.setMethodName("serviceMethod");
> >
> >        Vector params = new Vector();
> >        params.addElement(new Parameter("request", URL.class, url,
> > null));
> >        call.setParams(params);
> >
> >
> >
> > Serializer
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> > import java.net.URL;
> >
> > public class URLSerializer implements Serializer
> > {
> >
> >   public void marshall(String inScopeEncStyle, Class javaType, Object
> > src,
> >                        Object context, Writer sink, NSStack nsStack,
> >                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> >                         throws IllegalArgumentException, IOException
> >   {
> >       nsStack.pushScope();
> >
> >       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> > context,
> >                                           sink, nsStack, xjmr);
> >
> >       sink.write(StringUtils.lineSeparator);
> >
> >       URL src2 = (URL) src;
> >
> >       Parameter param;
> >
> >       param = new Parameter("URL", String.class, src2.toString(), null);
> >
> >       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
> >                     sink, nsStack, ctx);
> >       sink.write(StringUtils.lineSeparator);
> >
> >       sink.write("</" + context + ">");
> >
> >       nsStack.popScope();
> >   }
> > }
> >
> >
> >
> > Deserializer
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> > public class URLDeserializer implements Deserializer
> > {
> >   public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
> > src,
> >                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> >                           throws IllegalArgumentException
> >   {
> >     Element root = (Element)src;
> >     Element tempEl = DOMUtils.getFirstChildElement(root);
> >
> >     URL url = null;
> >
> >     while (tempEl != null)
> >     {
> >         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> > RPCConstants.Q_ELEM_PARAMETER,
> >                                          tempEl, ctx);
> >         Parameter param = (Parameter)paramBean.value;
> >         String tagName = tempEl.getTagName();
> >
> >         if (tagName.equals("URL"))
> >         {
> >             try
> >             {
> >                 url = new URL( (String)param.getValue() );
> >             }
> >             catch (Exception e)
> >             {
> >                 throw new IllegalArgumentException("Problem
> > instantianting bean: " + e.getMessage());
> >             }
> >
> >         }
> >
> >         tempEl = DOMUtils.getNextSiblingElement(tempEl);
> >     }
> >
> >
> >     return new Bean(URL.class, url);
> >   }
> > }

--
David Turner <tu...@genome.wi.mit.edu>
Senior Software Engineer
Whitehead Institute/MIT Center for Genome Research
One Kendall Square, Bldg. 300
Cambridge, MA 02139-1561 USA
phone 617-252-1573 / fax 617-252-1902



Re: Serializers/Deserializers

Posted by David Turner <tu...@genome.wi.mit.edu>.
Hi Scott,
Thanks for getting back to me.
I did manage to figure out why it wasn't working -- I changed tomcats classpath
to point to my stuff and it didn't like this.  I jar'ed things up and placed it
in WEB/INF/lib of soap and it worked fine.  Going the classpath route, the
service class was found but any supporting classes were having the problem of
not be found.
I'll have to read up on tomcats classloader.
Thanks again.

Scott Nichol wrote:

> From where is the URLSerializer loaded?  Is it a class in WEB-INF/classes,
> in a jar in WEB-INF/lib or somewhere in the servlet container classpath?  If
> it is the last of these, I would recommend you try one of the other two.
> This is a *guess*, but I still have not got a full grip on the different
> class loading schemes used within the container.
>
> Scott
>
> ----- Original Message -----
> From: "David Turner" <tu...@genome.wi.mit.edu>
> To: <so...@xml.apache.org>
> Sent: Thursday, October 25, 2001 10:25 AM
> Subject: Serializers/Deserializers
>
> > I've been trying to develop my own serializer & deserializer for some
> > java classes such as the
> > java.net.URL class in order to pass URL's to a service method, but the
> > server sends back a fault:
> >       Fault Code = SOAP-ENV:Server.Exception:
> >       Fault String = org/apache/soap/util/xml/Deserializer
> >
> > I've attempted to write serializers/deserializers for a simple class
> > also (class contains only Strings) instead of using the BeanSerializer
> > and I
> > still get the above exception.
> >
> > This is a critical issue...
> >
> > Below is the code:
> >
> > Deployment Descriptor
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> > <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
> >              id="urn:SimpleURLService">
> >   <isd:provider type="java"
> >                 scope="Session"
> >                 methods="serviceMethod">
> >     <isd:java
> > class="examples.omnitide.SimpleURLService.SimpleURLService"
> > static="false"/>
> >   </isd:provider>
> >
> >
> >
> <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
> r>
> >
> >   <isd:mappings>
> >     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> > qname="xsd:URL"
> >              javaType="java.net.URL"
> >
> > xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
> >
> >   </isd:mappings>
> >
> > </isd:service>
> >
> >
> >
> > Client that calls soap service
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> >       // Map the types
> >        SOAPMappingRegistry smr = new SOAPMappingRegistry();
> >
> >        URLSerializer ser = new URLSerializer();
> >        URLDeserializer des = new URLDeserializer();
> >
> >        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> > QName("urn:SimpleURLService", "URL"),
> >            URL.class, ser, des);
> >
> >        // Build the call
> >        Call call = new Call();
> >        call.setSOAPMappingRegistry(smr);
> >        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> >        call.setTargetObjectURI("urn:SimpleURLService");
> >        call.setMethodName("serviceMethod");
> >
> >        Vector params = new Vector();
> >        params.addElement(new Parameter("request", URL.class, url,
> > null));
> >        call.setParams(params);
> >
> >
> >
> > Serializer
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> > import java.net.URL;
> >
> > public class URLSerializer implements Serializer
> > {
> >
> >   public void marshall(String inScopeEncStyle, Class javaType, Object
> > src,
> >                        Object context, Writer sink, NSStack nsStack,
> >                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> >                         throws IllegalArgumentException, IOException
> >   {
> >       nsStack.pushScope();
> >
> >       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> > context,
> >                                           sink, nsStack, xjmr);
> >
> >       sink.write(StringUtils.lineSeparator);
> >
> >       URL src2 = (URL) src;
> >
> >       Parameter param;
> >
> >       param = new Parameter("URL", String.class, src2.toString(), null);
> >
> >       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
> >                     sink, nsStack, ctx);
> >       sink.write(StringUtils.lineSeparator);
> >
> >       sink.write("</" + context + ">");
> >
> >       nsStack.popScope();
> >   }
> > }
> >
> >
> >
> > Deserializer
> > --------------------------------------------------------------------------
> ------------------------------------
> >
> > public class URLDeserializer implements Deserializer
> > {
> >   public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
> > src,
> >                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
> >                           throws IllegalArgumentException
> >   {
> >     Element root = (Element)src;
> >     Element tempEl = DOMUtils.getFirstChildElement(root);
> >
> >     URL url = null;
> >
> >     while (tempEl != null)
> >     {
> >         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> > RPCConstants.Q_ELEM_PARAMETER,
> >                                          tempEl, ctx);
> >         Parameter param = (Parameter)paramBean.value;
> >         String tagName = tempEl.getTagName();
> >
> >         if (tagName.equals("URL"))
> >         {
> >             try
> >             {
> >                 url = new URL( (String)param.getValue() );
> >             }
> >             catch (Exception e)
> >             {
> >                 throw new IllegalArgumentException("Problem
> > instantianting bean: " + e.getMessage());
> >             }
> >
> >         }
> >
> >         tempEl = DOMUtils.getNextSiblingElement(tempEl);
> >     }
> >
> >
> >     return new Bean(URL.class, url);
> >   }
> > }

--
David Turner <tu...@genome.wi.mit.edu>
Senior Software Engineer
Whitehead Institute/MIT Center for Genome Research
One Kendall Square, Bldg. 300
Cambridge, MA 02139-1561 USA
phone 617-252-1573 / fax 617-252-1902



Re: Serializers/Deserializers

Posted by Scott Nichol <sn...@computer.org>.
>From where is the URLSerializer loaded?  Is it a class in WEB-INF/classes,
in a jar in WEB-INF/lib or somewhere in the servlet container classpath?  If
it is the last of these, I would recommend you try one of the other two.
This is a *guess*, but I still have not got a full grip on the different
class loading schemes used within the container.

Scott

----- Original Message -----
From: "David Turner" <tu...@genome.wi.mit.edu>
To: <so...@xml.apache.org>
Sent: Thursday, October 25, 2001 10:25 AM
Subject: Serializers/Deserializers


> I've been trying to develop my own serializer & deserializer for some
> java classes such as the
> java.net.URL class in order to pass URL's to a service method, but the
> server sends back a fault:
>       Fault Code = SOAP-ENV:Server.Exception:
>       Fault String = org/apache/soap/util/xml/Deserializer
>
> I've attempted to write serializers/deserializers for a simple class
> also (class contains only Strings) instead of using the BeanSerializer
> and I
> still get the above exception.
>
> This is a critical issue...
>
> Below is the code:
>
> Deployment Descriptor
> --------------------------------------------------------------------------
------------------------------------
>
> <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
>              id="urn:SimpleURLService">
>   <isd:provider type="java"
>                 scope="Session"
>                 methods="serviceMethod">
>     <isd:java
> class="examples.omnitide.SimpleURLService.SimpleURLService"
> static="false"/>
>   </isd:provider>
>
>
>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
r>
>
>   <isd:mappings>
>     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> qname="xsd:URL"
>              javaType="java.net.URL"
>
> xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
>
>   </isd:mappings>
>
> </isd:service>
>
>
>
> Client that calls soap service
> --------------------------------------------------------------------------
------------------------------------
>
>       // Map the types
>        SOAPMappingRegistry smr = new SOAPMappingRegistry();
>
>        URLSerializer ser = new URLSerializer();
>        URLDeserializer des = new URLDeserializer();
>
>        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> QName("urn:SimpleURLService", "URL"),
>            URL.class, ser, des);
>
>        // Build the call
>        Call call = new Call();
>        call.setSOAPMappingRegistry(smr);
>        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>        call.setTargetObjectURI("urn:SimpleURLService");
>        call.setMethodName("serviceMethod");
>
>        Vector params = new Vector();
>        params.addElement(new Parameter("request", URL.class, url,
> null));
>        call.setParams(params);
>
>
>
> Serializer
> --------------------------------------------------------------------------
------------------------------------
>
> import java.net.URL;
>
> public class URLSerializer implements Serializer
> {
>
>   public void marshall(String inScopeEncStyle, Class javaType, Object
> src,
>                        Object context, Writer sink, NSStack nsStack,
>                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>                         throws IllegalArgumentException, IOException
>   {
>       nsStack.pushScope();
>
>       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> context,
>                                           sink, nsStack, xjmr);
>
>       sink.write(StringUtils.lineSeparator);
>
>       URL src2 = (URL) src;
>
>       Parameter param;
>
>       param = new Parameter("URL", String.class, src2.toString(), null);
>
>       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
>                     sink, nsStack, ctx);
>       sink.write(StringUtils.lineSeparator);
>
>       sink.write("</" + context + ">");
>
>       nsStack.popScope();
>   }
> }
>
>
>
> Deserializer
> --------------------------------------------------------------------------
------------------------------------
>
> public class URLDeserializer implements Deserializer
> {
>   public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
> src,
>                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>                           throws IllegalArgumentException
>   {
>     Element root = (Element)src;
>     Element tempEl = DOMUtils.getFirstChildElement(root);
>
>     URL url = null;
>
>     while (tempEl != null)
>     {
>         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> RPCConstants.Q_ELEM_PARAMETER,
>                                          tempEl, ctx);
>         Parameter param = (Parameter)paramBean.value;
>         String tagName = tempEl.getTagName();
>
>         if (tagName.equals("URL"))
>         {
>             try
>             {
>                 url = new URL( (String)param.getValue() );
>             }
>             catch (Exception e)
>             {
>                 throw new IllegalArgumentException("Problem
> instantianting bean: " + e.getMessage());
>             }
>
>         }
>
>         tempEl = DOMUtils.getNextSiblingElement(tempEl);
>     }
>
>
>     return new Bean(URL.class, url);
>   }
> }


Re: Serializers/Deserializers

Posted by Scott Nichol <sn...@computer.org>.
There is class loader info at
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
although some of the info there for 4.0 already seems to be out of date for
4.0.1.

Scott

----- Original Message -----
From: "David Turner" <tu...@genome.wi.mit.edu>
To: <so...@xml.apache.org>
Sent: Thursday, October 25, 2001 10:25 AM
Subject: Serializers/Deserializers


> I've been trying to develop my own serializer & deserializer for some
> java classes such as the
> java.net.URL class in order to pass URL's to a service method, but the
> server sends back a fault:
>       Fault Code = SOAP-ENV:Server.Exception:
>       Fault String = org/apache/soap/util/xml/Deserializer
>
> I've attempted to write serializers/deserializers for a simple class
> also (class contains only Strings) instead of using the BeanSerializer
> and I
> still get the above exception.
>
> This is a critical issue...
>
> Below is the code:
>
> Deployment Descriptor
> --------------------------------------------------------------------------
------------------------------------
>
> <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
>              id="urn:SimpleURLService">
>   <isd:provider type="java"
>                 scope="Session"
>                 methods="serviceMethod">
>     <isd:java
> class="examples.omnitide.SimpleURLService.SimpleURLService"
> static="false"/>
>   </isd:provider>
>
>
>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
r>
>
>   <isd:mappings>
>     <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>              xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> qname="xsd:URL"
>              javaType="java.net.URL"
>
> xml2JavaClassName="examples.omnitide.SimpleURLService.URLDeserializer"/>
>
>   </isd:mappings>
>
> </isd:service>
>
>
>
> Client that calls soap service
> --------------------------------------------------------------------------
------------------------------------
>
>       // Map the types
>        SOAPMappingRegistry smr = new SOAPMappingRegistry();
>
>        URLSerializer ser = new URLSerializer();
>        URLDeserializer des = new URLDeserializer();
>
>        smr.mapTypes(Constants.NS_URI_SOAP_ENC, new
> QName("urn:SimpleURLService", "URL"),
>            URL.class, ser, des);
>
>        // Build the call
>        Call call = new Call();
>        call.setSOAPMappingRegistry(smr);
>        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>        call.setTargetObjectURI("urn:SimpleURLService");
>        call.setMethodName("serviceMethod");
>
>        Vector params = new Vector();
>        params.addElement(new Parameter("request", URL.class, url,
> null));
>        call.setParams(params);
>
>
>
> Serializer
> --------------------------------------------------------------------------
------------------------------------
>
> import java.net.URL;
>
> public class URLSerializer implements Serializer
> {
>
>   public void marshall(String inScopeEncStyle, Class javaType, Object
> src,
>                        Object context, Writer sink, NSStack nsStack,
>                        XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>                         throws IllegalArgumentException, IOException
>   {
>       nsStack.pushScope();
>
>       SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType,
> context,
>                                           sink, nsStack, xjmr);
>
>       sink.write(StringUtils.lineSeparator);
>
>       URL src2 = (URL) src;
>
>       Parameter param;
>
>       param = new Parameter("URL", String.class, src2.toString(), null);
>
>       xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
>                     sink, nsStack, ctx);
>       sink.write(StringUtils.lineSeparator);
>
>       sink.write("</" + context + ">");
>
>       nsStack.popScope();
>   }
> }
>
>
>
> Deserializer
> --------------------------------------------------------------------------
------------------------------------
>
> public class URLDeserializer implements Deserializer
> {
>   public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
> src,
>                          XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>                           throws IllegalArgumentException
>   {
>     Element root = (Element)src;
>     Element tempEl = DOMUtils.getFirstChildElement(root);
>
>     URL url = null;
>
>     while (tempEl != null)
>     {
>         Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
> RPCConstants.Q_ELEM_PARAMETER,
>                                          tempEl, ctx);
>         Parameter param = (Parameter)paramBean.value;
>         String tagName = tempEl.getTagName();
>
>         if (tagName.equals("URL"))
>         {
>             try
>             {
>                 url = new URL( (String)param.getValue() );
>             }
>             catch (Exception e)
>             {
>                 throw new IllegalArgumentException("Problem
> instantianting bean: " + e.getMessage());
>             }
>
>         }
>
>         tempEl = DOMUtils.getNextSiblingElement(tempEl);
>     }
>
>
>     return new Bean(URL.class, url);
>   }
> }