[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    RE: Help on how to Make XMLBeans work with AXIS(cont.)
From:       "Campana Jr., Salvatore J" <sal.campana () hp ! com>
Date:       2004-08-19 15:10:54
Message-ID: 1D9F67DCEDDF86478FA146AC147904570603F7C5 () tayexc17 ! americas ! cpqcorp ! net
[Download RAW message or body]

As for enumerations (or Arrays) I suspect that Axis's base
(de)serializers would just call to the other registered (de)serializer
(i.e. XmlBeanDeserilizer) for each encountered object/element....So it
may just work...I'd try it....

-Sal 

-----Original Message-----
From: Campana Jr., Salvatore J 
Sent: Thursday, August 19, 2004 10:59 AM
To: xmlbeans-dev@xml.apache.org
Subject: RE: Help on how to Make XMLBeans work with AXIS(cont.) 

Here's how I would approach it:


Implement a Factory for each:

i.e.
XmlBeanDeserializerFactory extends BaseDeserializerFactory
XmlBeanSerializerFactory extends BaseSerializerFactory

Both should have a constructor which points to the (de)serialization
class:

i.e.
public XmlBeanDeserializerFactory ( Class javaType, QName xmlType ) {
        super( XmlBeanSerializer.class, xmlType, javaType ); }

Then implement the (de)serializers:

Serializer Impl: 

public class XmlBeanSerializer implements Serializer ...

//implement this operation
public void serialize(
            QName name,
            Attributes attributes,
            Object value,
            SerializationContext context )
            throws IOException
    {
        context.startElement( name, attributes );

        try
        {
            //note "value" is an XmlBean
            context.writeString(value.toString());
        }
        catch ( MarshalException me )
        {
           ...
        finally
        {
            context.endElement();
        }
    }

Deserializer: 

public class XmlBeanDeserializer extends DeserializerImpl ...

//override this operation
public void onEndElement(
            String namespace,
            String localName,
            DeserializationContext context )
            throws SAXException
    {
        try
        {
            MessageElement msgElem = context.getCurElement();
            //note "value" is defined in super class..this is what you'd
set the xmlbean to
            value = XmlObject.Factory.parse(msgElem.toString());
        }
        catch ( MarshalException me )
        {
           ...

So the last part of the puzzle is to register your types in the
server-config.wsdd file and point them to your (de)serializers...


<typeMapping
         xmlns:ns="http://foo.com"
         qname="ns:Foo"
         type="java:com.my.xmlbean.generated.interface.Foo"
         serializer="com.my.XmlBeanSerializationFactory"
         deserializer="com.my.XmlBeanDeserializationFactory"
         encodingStyle=""
       />


This will tell Axis that when it sees the element "ns:Foo" it should
hand it off to the factory for (de)serialization.  It also tells Axis
that when it sees the class com.my.xmlbean.generated.interface.Foo come
for serialization it should call the correct factory...

Hope that helps...


-Sal

_____  

Sal Campana
Web Services Management Operation
HP Openview Division
856.638.6284
sal_campana@hp.com




-----Original Message-----
From: Yu Long [mailto:yulong32601@yahoo.com]
Sent: Thursday, August 19, 2004 9:59 AM
To: xmlbeans-dev@xml.apache.org
Subject: Help on how to Make XMLBeans work with AXIS(cont.) 

Can any one help here? Thanks a lot. --longyu


--- Yu Long <yulong32601@yahoo.com> wrote:

> Hi,
>   I am looking into the castor's de/serializer to see how to write my 
> own custom de/serializer for XMLBean Object.
>   Here is some of my thoughts. In my case, I may need three 
> de/seralizers.
> 
> 1) a general one similar to CastorSerializer.java and 
> CastorDeserializer.java
> 
> 2) one for Enumeration type similar to CastorEnumTypeSerializer.java 
> and CastorEnumTypeDeserializer.java
> 
> 3) one may be needed for the following type:
> 
>  <xs:simpleType name="percentageType">
>     <xs:restriction base="xs:string">
>       <xs:pattern value="[1]?[0-9]?[0-9]">
>         <xs:annotation>
>           <xs:documentation>
>                    percentage (0-100) (default 0)
>               </xs:documentation>
>         </xs:annotation>
>       </xs:pattern>
>     </xs:restriction>
>   </xs:simpleType>
> 
>  
> But it seems I need some documents on how XMLBeans is designed and 
> implemented,especially related to writing the three de/serializer. The

> User Guide Documents on apache website is only for using purpose.
> It doesn't help much.
> 
> Thanks,
> longyu
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-dev-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org Apache
XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org Apache
XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic