web services in java - github pages
TRANSCRIPT
WEB SERVICES IN JAVA
16/09/2020 tdi@cphbus 1
Java Technologies for Processing Web Services
16/09/2020 tdi@cphbus 2
JAX-WS
§ Java API for XML Web Services (JAX-WS) § a technology for building web services and clients that communicate using XML
§ Hides the complexity of SOAP
§ Enables implementation of both§ RPC-oriented web services§ message-oriented web services
§ Provides platform independence§ non-Java clients can use Java service
16/09/2020 tdi@cphbus 3
How Does JAX-WS Work?
§ While creating a client to consume a web service§ creates a local copy of the remote WSDL § maps the URL of the service provider to the local copy
§ this is defined in jax-ws-catalog.xml§ this makes the implementation of the service at the client easier and faster
§ Example of jax-ws-catalog.xml<?xml version="1.0" encoding="UTF-8" standalone="no"?><catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system systemId="http://www.webservicex.net/geoipservice.asmx?WSDL" uri="wsdl/www.webservicex.net/geoipservice.asmx.wsdl"/>
</catalog>
16/09/2020 tdi@cphbus 4
JAXB – Java Architecture for XML Binding
§ Converts Java objects to XML representation and vice-versa
§ Used to transform an user-defined object types and collections into XML as a part of SOAP message
16/09/2020 tdi@cphbus 5
Java vs XML
In Javapublic class MyClass
{int attr1;double attr2;String attr3;
}
In XML<MyClass>
<attr1>value</attr1><attr2>value</attr2><attr3>value</attr3>
</MyClass>
16/09/2020 tdi@cphbus 6
JAXB Annotations
§ Annotations, placed in Java code to instruct JAXB§ not needed for simple transformation§ needed for customisation of default values
§ Examples of annotations§ @XmlRootElement, @XmlType, @XmlElement
16/09/2020 tdi@cphbus 7