• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Webservices and Entities
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Webservices and Entities


  • Subject: Re: Webservices and Entities
  • From: Francis Labrie <email@hidden>
  • Date: Tue, 13 Apr 2004 09:45:12 -0400

Hi,


Greg Hulands wrote:
I am adding an administration web service to my application that
returns custom EOEnterpriseObjects, for example Client. Webobjects
packs the entity object into dictionary. Currently I am fetching the
objects via

        public NSArray clients() {
[...]

What I ultimately would like to do is to create an xml document with
maybe the following structure.

<Client>
<firstName>Greg</firstName>
<lastName>Hulands</lastName>
<email>email@hidden</email>
</Client>

Is there a way to intercept the web service request response loop via a
delegate or some other method that will transform the entity dictionary
into a well formed xml document?


Well, WebObjects Web Services support already serialize EOEnterpriseObject into XML form (see classes in com.webobjects.webservices.support.xml package). But the serialization will not respect the schema you wrote above.

But you can define your own serializer and deserializer with factories using SAX and Axis. You'll have to register serializations factories to com.webobjects.appserver.WOWebServiceRegistrar if you are about to publish this class through Web Services, and / or to com.webobjects.webservices.client.WOWebServiceClient instance if you are about to access a Web Service publishing such Student objects. In both case, you'll have to call the registerFactoriesForClassWithQName(SerializerFactory, DeserializerFactory, Class, QName) method.


any help or pointers to information/documentation is greatly
appreciated.


To define custom serialization classes and factories, I suggest you to check Axis (http://ws.apache.org/axis/, remind that WebObjects unfortunately uses Axis 1.0) and SAX documentation. As I wrote previously, you'll have to create factories for more complex objects requiring special org.apache.axis.description.TypeDesc schemas. Essentially, you'll need to build serialization class to transform your object into a XML representation, and a deserialization class if you also need to transform the XML representation back to a Java object:


public class MyClassSerializer implements org.apache.axis.encoding.Serializer {...}

public class MyClassDeserializer extends
	org.apache.axis.encoding.DeserializerImpl implements
		org.apache.axis.encoding.Deserializer {...}


Finally, you'll need simple a serialization factory class for both. Usually, I define them as serializer / deserializer inner class:



public class MyClassSerializerFactory extends org.apache.axis.encoding.ser.BaseSerializerFactory { private MyClassSerializerFactory() { super(MyClassSerializer.class); } }

public class MyClassDeserializerFactory
	extends org.apache.axis.encoding.ser.BaseDeserializerFactory {
	private MyClassDeserializerFactory() {
		super(MyClassDeserializer.class);
	}
}


Kind regards,

--
Francis Labrie
Saint-Bruno-de-Montarville, Quebec, Canada
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Webservices and Entities (From: Greg Hulands <email@hidden>)

  • Prev by Date: RE: What class generates the sql?
  • Next by Date: set SQL server as Argument
  • Previous by thread: Webservices and Entities
  • Next by thread: set SQL server as Argument
  • Index(es):
    • Date
    • Thread