web services in java - github pages

7
WEB SERVICES IN JAVA 16/09/2020 tdi@cphbus 1

Upload: others

Post on 31-Jul-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WEB SERVICES IN JAVA - GitHub Pages

WEB SERVICES IN JAVA

16/09/2020 tdi@cphbus 1

Page 2: WEB SERVICES IN JAVA - GitHub Pages

Java Technologies for Processing Web Services

16/09/2020 tdi@cphbus 2

Page 3: WEB SERVICES IN JAVA - GitHub Pages

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

Page 4: WEB SERVICES IN JAVA - GitHub Pages

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

Page 5: WEB SERVICES IN JAVA - GitHub Pages

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

Page 6: WEB SERVICES IN JAVA - GitHub Pages

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

Page 7: WEB SERVICES IN JAVA - GitHub Pages

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