Posts

Showing posts with the label Web Services

Java Architecture for XML Binding (JAXB) - Important tags

JAXB is a standard for mapping POJOS to XML. It mainly does 2 tasks: Binding the Java data types to equivalent XSD types. By annotating Java class with JAXB annotations, Java objects can be converted   to XML documents(Marshalling) and XML docs can be converted back to java objects(Unmarshalling). Below are some of the useful tags which can be handy in many scenarios.. @XmlRootElement(name = "Catologue") -  Maps the class to a Root element of the generated XML   <?xml version="1.0" encoding="UTF-8"?> <Catalogue> </Catalogue> @XmlType(name = "CatalogueDataType") - Binds/Maps the class to a Schema type <xs:complexType name="CatalogueDataType">     <xs:sequence>     .......     </xs:sequence>   </xs:complexType> @XmlType(propOrder = {"name", "products"}) - Order in which the properties of a class appear in XML <Catalogue> <name></n...

Web Services - One stop shop

Image
Technologies required for creating Web services: XSD, JAXB, WSDL, JAX-WS annotations WSDL - Web Service Descriptor Language. Using WSDL, you can register your web service on a server.  We can write WSDL manually or use annotations to convert a JAVA file into a WSDL file. 2nd option is the easiest and the preferred way . Here, I am demonstrating how @Webservice annotation converts java interfaces and classed to a WSDL is given below On server, we write interfaces and Impls for every service. When we deploy the service with @Webservice annotation. The service gets registered with the    Impl  name. WSDL components: WSDL has the below components 1. Service 2. Port 3. Binding 4. PortType 5. Operation 6. Messages 7. Types So, A WSDL roughly looks like this.. <Definitions>   <Type/>or XSD import   <Messages/> <PortType> <Operation/> </PortType> <Binding/> <Service> ...