axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arthur van Dorp" <>
Subject Re: Re: Reusing the axis serializers [Axis 1.4]
Date Tue, 18 Jul 2006 06:35:48 GMT
Hi Martin

> > I'm using Axis 1.4 and java classes generated with WSDL2Java for
> > offering a webservice. The service adds a bit of generated data and is then
> > supposed to store it as a file again in XML. As all the serializers are already
> > there thanks to Axis I'd like to use them. Every generated class has a
> > getSerializer(java.lang.String mechType, java.lang.Class _javaType,
> > javax.xml.namespace.QName _xmlType) function and there's a SerializerFactory. I've
> > looked at the Axis documentation and the source but couldn't figure out how to
> > use getSerializer correctly. Any pointers to documentations or a small
> > example would be very welcome.
> Starting with the locator class example located at
> ./samples/addr/AddressBookServiceLocator.class
> will allow you to obtain a service object which will allow you to gain
> access to the properties you desire
> I found the wsdl11 tutorial most instructive via /src/
> [...]

A thousand thanks for your answer. With your answer, digging through the axis source code
and trial and error I've managed to get nice XML from my class instances. I've attached the
my work which somewhat resembles java code below in case anyone else has a similar problem.

Two problems remain:
* The outermost XML element is now of type xsd:anyType. I've got to have a look at this.
* The need for knowing the service endpoint is ugly.

Thanks again,


MyQueryDocType queryDoc = new MyQueryDocType();

MyQueryParams queryParams = new MyServiceParams();
// Fill queryParams with something sensible.

OutputStream Out = whereverYouGetYourStreamFrom.getOutputStream();

// Get a nice XML representation

MyService_ServiceLocator service
	= new MyService_ServiceLocator();

MyServicePortType MyService
	= new MyServiceImpl(); // Your service implementation

javax.xml.rpc.encoding.TypeMappingRegistry reg
	= service.getTypeMappingRegistry();
TypeMapping tm = (TypeMapping) reg.getTypeMapping("");

javax.xml.namespace.QName queryDocQName
	= tm.getTypeQName(MyQueryDocType.class);
javax.xml.namespace.QName queryDocXMLType
	= tm.getXMLType(MyQueryDocType.class,
	false); // TODO: Check boolean value.
Serializer serializer
	= EPCISQueryDocumentType.getSerializer("mechType??",
	queryDocXMLType); // TODO: What is mechType?

OutputStreamWriter oWriter = new OutputStreamWriter(Out);
SerializationContext serContext
	= new SerializationContext(oWriter);

queryDoc = MyService.myQuery(queryParams);

	new NullAttributes(),



Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message