You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Benjamin Sempere <be...@bull.fr> on 2004/06/09 11:24:37 UTC
Getting Mapping between XmlType and JavaType
Hello i ve a little question in glance with Axis
So i ve a wsdl file called "AddressBook.wsdl". With wsdl2java i generate classes associated.
Now in another class i user serializers generated with the Phone.class like this:
//Writer
StringWriter writer = new StringWriter();
//Phone object creation
Phone phone = new Phone();
phone.setAreaCode(74950);
phone.setExchange("exchange");
phone.setNumber("0450566328");
//Getting serializer
Serializer serializer = Phone.getSerializer("", Phone.class, new QName("urn:AddressFetcher2", "phone"));
//Creating a service
Service service = new Service();
//Context
MessageContext msgContext = new MessageContext( service.getEngine() );
SerializationContext ctx = new SerializationContextImpl(writer, msgContext);
//Serialization
serializer.serialize(new QName("", "phone"), null, phone, ctx);
//Writing
System.out.println(" ========== Result: start ==========");
System.out.println(" "+writer);
System.out.println(" ========== Result: end ==========");
writer.close();
And the ouput is:
========== Result: start ==========
<?xml version="1.0" encoding="UTF-8"?>
<phone>
<areaCode xsi:type="xsd:int" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
74950
</areaCode>
<exchange xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
exchange
</exchange>
<number xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
0450566328
</number>
</phone>
========== Result: end ==========
So all is corect, but now i try to obtain mapping between xsd:int to javaType, how can i do this???
It s only a test and later i d have a method that gives me in a string the className for a xmlType:
For example: xsd:String --> java.lang.String
xsd:int --> java.lang.int ...
And the same thing with complexType
Regards SEMPERE Benjamin