• 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: WebObjects: No serializer found for class Student in registry...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WebObjects: No serializer found for class Student in registry...


  • Subject: Re: WebObjects: No serializer found for class Student in registry...
  • From: Francis Labrie <email@hidden>
  • Date: Mon, 12 Apr 2004 11:51:32 -0400

Hi,


Ismael Nass-Duce wrote:
[...]
Is there a WebObjects tutorial that shows how to create a simple
serializer/deserializer that one can use to pass
custom objects to a web service?

The easiest way to create Web Services Java serializer / deserializer is to use Axis' BeanSerializer and BeanDeserializer. But you can use these serialization classes only if your class is simple, with a setter and a getter for each attribute.


So, to add serialization factories for the following simple Student class below:


public class Student implements java.io.Serializable { private String _firsName; // [Other attributes...]

	public String getFirstName() {
		return(_firstName);
	}

	public void setFirstName(String firstName) {
		_firstName = firstName;
	}

	// [Other setters and getters...]
}


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 like this:



BeanDeserializerFactory deserializer; BeanSerializerFactory serializer; QName qName;

qName = new QName("http://mynamespacebase/webservices/soap/";, "Student");
serializer = new BeanSerializerFactory(Student.class, qName);
deserializer = new BeanDeserializerFactory(Student.class, qName);


// For publishing
WOWebServiceRegistrar.registerFactoriesForClassWithQName(
	serializer, deserializer, Student.class, qName);

// For accessing
WOWebServiceClient client = new WOWebServiceClient(webServiceURL);
client.registerFactoriesForClassWithQName(
	serializer, deserializer, Student.class, qName);


The Web_Services.pdf document says the following under "Serialization
and Deserialization of Objects":

"Complex classes require a custom serialization and deserialization
strategy.  WebObjects provides serializers and deserializers for [most
of its classes]. If you  have special classes that required a special
serializer and deserializer, you have to  create them.

Creating serializer and deserializer classes is a simple process, but
requires knowledge of SAX (Simple API for XML). To learn how to process
SAX callbacks in your serializers and deserializers, see Java & XML
(OReilly)."


I tried the O'Reilly book, but found myself getting no where.


You should check SAX and the Axis documentation to understand how XML serialization works in order to create factories for more complex objects requiring special org.apache.axis.description.TypeDesc schemas. Essentially, you'll then need to build serialization and a deserialization classes:


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.


  • Prev by Date: Re: Moving projects between machines
  • Next by Date: Re: Allows Concurrent Request Documentation
  • Previous by thread: Re: Moving projects between machines
  • Next by thread: Re: What class generates the sql? (Greg Hulands)
  • Index(es):
    • Date
    • Thread