axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "srini.maran" <thiruma...@yahoo.com>
Subject Re: XML Unmarshalling/ Data Binding
Date Mon, 19 Oct 2009 13:42:07 GMT

Here is the sample code to convert XM to object using ADB binding

Refering IBM article Library example - Input Object getBook

First convert XML schema to Object using wsdl2java - ADB binding

String xmlStr = "<GetBook>  <isbn>123456</isbn> </GetBook>"

if you get an unexpected sub element, please specify
xmlns='http://ws.sosnoski.com/library/wsdl' in GetBook element.  ADB
requires xmlns in the element.

Instatiate the main element obejct (Eg. refering IBM article Library
example)

XMLStreamReader reader = XMLInputFactory.newInstance()
		.createXMLStreamReader(new ByteArrayInputStream(xmlStr.getBytes()));
System.out.println("Getting Object");
GetBook gb = GetBook .Factory.parse(reader);

// to verify that the xml coverted to object succesfully or not, print the
XML from coverted object
System.out.println("Retrive XML from Object "
           + gb.getOMElement(gb.MY_QNAME,
		OMAbstractFactory.getOMFactory())
			.toStringWithConsume());

GetBook1 gb1 = new GetBook1();
gb1.setGetBook(gb);

System.out.println("Retrive XML from Object "
           + gb1.getOMElement(gb1.MY_QNAME,
		OMAbstractFactory.getOMFactory())
			.toStringWithConsume());



jcaristi wrote:
> 
> There are three Axis2 options for this, which are clearly explained in
> this article:
> 
> http://www.ibm.com/developerworks/webservices/library/ws-java3/
> 
> Note that you would probably want to use these in place of JAXB, not in
> addition to it.  If you want to use JAXB, you should probably stick with a
> pure JAX-WS solution and skip the Axis data binding.
> 
> 
> kushal12 wrote:
>> 
>> Hi,
>> 
>> Can somebody tell me if, there is a way by which you can convert the
>> incoming XML to a java object using Axis ??
>> 
>> I am trying to call a webservice and the client for which has been
>> written in Axis.
>> 
>> Now Client in turn gets the input data to be passsed to the service in
>> the form of XML. 
>> 
>> If I use Jaxb to unmarshal the incoming data, Jaxb generates its own set
>> of java classes for the xml, which are different in names, as those
>> generated by axis, as a part of wsdl2java tool.
>> 
>> Is there any way by which I can driectly copy the java object returned by
>> JAXB into the one generated by Axis ?
>> 
>> Have tried beanutils, but it expects all the property names in the source
>> and destination object to be same ?
>> 
>> Regards
>> Kushal
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/XML-Unmarshalling--Data-Binding-tp22580923p25958601.html
Sent from the Axis - User mailing list archive at Nabble.com.


Mime
View raw message