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/RunClient.java
> http://esw.w3.org/topic/SparqlProtocolWsdl11Examples
> [...]
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,
Arthur
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();
service.setMyServiceEndpointAddress(
"http://localhost:8080/WhereEverYourServiceLives");
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,
queryDocQName,
false); // TODO: Check boolean value.
Serializer serializer
= EPCISQueryDocumentType.getSerializer("mechType??",
MyQueryDocType.class,
queryDocXMLType); // TODO: What is mechType?
OutputStreamWriter oWriter = new OutputStreamWriter(Out);
SerializationContext serContext
= new SerializationContext(oWriter);
queryDoc = MyService.myQuery(queryParams);
serializer.serialize(queryDocXMLType,
new NullAttributes(),
queryDoc,
serContext
);
oWriter.flush();
oWriter.close();
Out.flush();
Out.close();
--
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]