Posts

Showing posts from July, 2009

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 javax.xml.soap.Text; import javax.xm

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.xml.bind.JAXBException; import javax.xml.bind.Mar

Schema to XML document by JDeveloper

Image
This tutorial explain creating xml schema from scratch and creating xml document from it as well. Jdeveloper 10g has a very easy visual editor for creating xml schema as well as xml document. It is considered that you have basic knowledge of schema. Here are step by step approach 1.Create new project and them create new XML schema   2.By default, a simple schema header tag  and an example element   3. Here we are going to construct schema for an Order xml document like  Order>>Item_list>>Item . A order will have id,description,shipTo address and list of items. To construct such structure we will have three complex type order_type, item_type and order_list_type. So create order_type complex type by drag and drop Complex Type component and edit properties   4. Now drag and drop sequence component to complex component 5.  now drag and drop element components one by one and edit the properties   6. There will multiple items under an order

Separate Content, behavior and Presentation

Today the most dynamic thing in this world is the Web. These pages are made of no of things which are categories as presentation, behavior or functional and content. It would be very beneficial  to maintain all these artifacts loosely coupled. Here is a simple example of keeping separate presentation and functional logic. In a sign in page , user has to enter login name which server will check for availability. Here is sample code <input type="text" name="loginName" value="Enter Login Name" onblur="checkavailibility"/> This tag invoke “checkavailibility()” function on blur event. To maintain loose coupling we can rewrite same logic in a java script file as window.onload="initPage"; function initPage(){     document.getElementById("loginName").onblur="checkavailibility" } Here initPage function get called on onLoad page event. This function access page element and set onBlur prop