Posts

Showing posts with the label jaxb

Building WebService with Custom Serializer using JDeveloper

Image
      JDeveloper 10g comes with UI based web service assembler. It converts simple java class to web service. You can customize web service assembling using Custom Serializer in case Service class accepts pojo class as parameters or return it. This post explains creating web service from simple java class. It is considered that you have gone through previous posts – JAXB by Jdeveloper and XML Document by Jdeveloper . So you have xml schema , xml document and set of java classes generated by JAXB compilation Here is step by step approach 1.    Code a CustomSerializer , it has to implement SOAPElementSerializer and override deserialize and serialize methods. Sample code is as below package jaxb.serializer; import javax.xml.bind.JAXBException; import oracle.webservices.databinding.SOAPElementSerializer; import javax.xml.soap.SOAPFactory; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPElement; import ja...

JAXB with JDeveloper

Image
      Jdeveloper 10g comes with JAXB1.0 tool .  This tool makes XML programming just one click away.This tutorial explains using JABX compilation tool of JDeveloper. In previous post we have seen handling of XML schema and XML document . You can refer the same as prerequisite for this post . Here is the step by step approach 1. Compile xml schema 2. Mention package and Test class 3. This will generate set of java classes under mentioned java package.You will notice one interface and implementation for each complex type or node. ItemType.java and ItemTypeIMpl.java get generated for  complex types ItemType. As we had selected Main class for generation, it creates Main class for testing JAXB compilation.           4. Here is the marshalling and un-marshalling code . [ refer this post for JAXB Coding ] package jaxb.test; import java.io.File; import javax.xml.bind.JAXBContext; import javax....

JAXB By Example

Java Architecture for XML Binding makes developer's life easier .Extended markup language (XML) is standard for exchanging data in between different applications across the network and Java provides a platform for building portable applications . JAXB API provides easier and standard way of accessing XML in java application. It is just two steps process Bind the Schema , binding xml schema to set of Java classes Unsharshaling / marshaling , XML to Java or Java to XML Following are step by step processing of using JAXB 1. Sample department XML Schema, save in the file named dept.xsd. Put in current directory. 2. Generate Java Classes from XML Schema using xjc tool xjc –d src/ dept.xsd output of this command : parsing a schema... compiling a schema... demo\jaxb\Customer.java demo\jaxb\Item.java demo\jaxb\Items.java demo\jaxb\ObjectFactory.java demo\jaxb\Order.java demo\jaxb\package-info.java demo\jaxb\package-info.java As you see the output, it will create j...