xml and soap.ppt

30
Introduction to Web Services Diana Beleiu – Application Developer 2 nd of June 2015

Upload: annadumitrache

Post on 17-Sep-2015

230 views

Category:

Documents


5 download

TRANSCRIPT

  • Introduction to Web ServicesDiana Beleiu Application Developer2nd of June 2015

  • AgendaIntroductionWhat are Web Services?Web Service TerminologySOAP Web ServicesXMLXML NamespacesXML SchemaWSDL - Web Service Definition Language

    SOAP Web ServicesJAX-WSCode First or Contract First?JAX-WS handlers typesSOA

  • What are Web Services?A software concept and infrastructure supported by several major computing vendors (notably Microsoft and IBM) for program-to-program communication and application component delivery. The Web services concept treats software as a set of services accessible over ubiquitous networks using Web-based standards and protocols. (Gartner)A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards. (W3C)

  • What are Web Services? (2)Web services are application componentsWeb services communicate using open protocolsWeb services are self-contained and self-describingWeb services can be discovered using UDDIWeb services can be used by other applicationsHTTP and XML is the basis for Web services

  • Company A Web Service ClientWeb Services middleware(internal)Other tiersCompany B Web Service Web Services middleware(internal)Other tiers3. interactCompany C (directory service provider)1. Publish the service description2. FindService descriptions

  • What are Web Services? (3)There are 2 categories of web services: Big web services (SOAP web services) Restful web services (REST web services)SOAP web services:Oldest and quite used today;Uses SOAP protocol over HTTP (or SMTP, JMS, etc);Are described by WSDL file;Can exchange SOAP messages;REST web services: newer and easier than SOAP based web services; uses HTTP as communication protocol; used for exchanging representation of resources; can exchange XML or JSON messages;

  • *Web Service TerminologyMay 14, 2015IBM Confidential

    SOAP(Simple Object Access Protocol)

    WSDL(Web Service Definition Language)

    XML(Extensible Markup Language)

    SEI(Service Endpoint Interface)

    XSD(XML Schema Definition)

    SOA(Service Oriented Architecture)

  • SOAP Web ServicesSOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. it relies on Extensible Markup Language (XML) as its message format, and usually relies on other Application Layer protocols (most notably Remote Procedure Call - RPC and HTTP) for message negotiation and transmission SOAP can form the foundation layer of a web services protocol stack, providing a basic messaging framework upon which web services can be built.

  • XMLXML stands for EXtensible Markup Language.XML was designed to describe data.XML is a software and hardware independent tool for carrying information.

    The advantages of using XML:Easy to understand and readSupported by a large number of platforms Used across open standards that are available todayDevelopers can create their own data definitions and models of representationSimpler to use than binary formats to represent complex data structures

  • XML NamespacesSimilar to Java packages:Are used to avoid name collision;Facilitate grouping of elements;To know which element belongs to which group;Can be used as a version control schemeThe namespace is changed when a new version of the application is releasedSintax of namespace declaration: xmlns:prefix=URIxmlns is reserved keyword;prefix is user defined;URI identifies the namespace;When the prefix is omitted, the declaration define a default namespace

    Bruxelles Frankfurt am Main/html:td>

    Java Developer Network admin

  • XML Schema (XSD)= describes the structure behind an XML(just as classes are for Objects)XML tags,e.g. employee (through XSD )their contentse.g. contains a (through XSD types)and attributes

    John Doe 0720654321 0720123456 1210186410071 1986-10-21 Bucuresti Viorele 4

  • XML Schema

    ...

    John Doe 0720654321 0720123456 1210186410071 1986-10-21 Bucuresti Viorele 4

  • SOAP Web Services (2)*IBM ConfidentialMay 14, 2015The service provider is a computer running server software (Apache, Glassfish etc.) where the web service is deployed

    The service requester is a client that is using the web serviceThe WSDL is an XML file which describes what methods are available for the web service and what parameters you need to includeSOAP is the way the client and the web service communicate UDDI is a platform-independent, XML-based registry by which businesses worldwide can list themselves on the Internet, and a mechanism to register and locate web service applications

  • WSDL - Web Service Definition Language=XML language for describing remote services

    WSDL describes:Remote operations signatureNameparametersreturn type(s)How to access the remote serviceHow to serialize parametersThe protocol to communicate with remote server Address of the remote service

  • JAX-WSThe Java API for XML-based Web services (JSR-224), commonly abbreviated JAX-WS, is the next generation Web services programming model.It replaces the earlier JAX-RPC technology.

    JAX-WS defines a model that uses Java annotations to develop Web service providers and Web service clients

    Java EE 5 platform requires compatible application servers to support JAX-WS 2.0, WebSphere Application Server V7 has already taken the next step and supports JAX-WS 2.1

  • JAX-WS (2)JAX-WS, like all specifications, is divided into 2 partsThe First part consists of an API provided by SUN. This API is accompanied by a JSR. The API consists of a set of interfaces, annotations, xml files and abstract classes (sometimes maybe a few base classes) which are to be used when using that feature. One very important thing about this API that should be noted is that the API in itself is not capable of achieving the intended objective of the specification. The JSR lays down a set of rules and regulations governing the API. The Second part of any specification is the implementation. The implementation follows all the rules laid down by the JSR and uses the API (i.e. provides all implementation for interfaces, and classes that use the annotations to get the desired objective) to provide a base.Multiple reference implementations by different vendors like: Sun (JDK 1.6), Apache (CXF, AXIS 2), IBM (Web sphere), ORACLE (Weblogic App Server), Glassfish (Metro).

  • SOAP I am a Java developer. Do I need to know SOAP?YesUnderstanding it will help you to build better applications;NoYou will mostly use high level API (JAX-WS, JAX-RPC, .NET) to build web services;How SOAP works is hidden from developers;

    Ionescu parola

  • Web Service ImplementationThe simplest way to create a web service consists of the following steps:1. Create an implementation class 2. Annotate the class with @WebService annotation 3. Annotate the methods to be exposed with @WebMethod annotation 4. Publish the web service via Endpoint.publish 5. Get WSDL 6.Test service using Eclipse Web Service Explorer / SoapUI

    7. Deploy JAX-WS web services on Tomcat

    Test with SOAP UI

  • Code First or Contract First?In the Code First approach, development of the service is started from a code. So the developer can write a service without knowing anything about WSDL.

    Contract-first is the generally accepted 'best practice.'When using contract-first, you start with the WSDL contract, and use Java to implement said contract. What is WSDL?

    WSDL stands for Web Services Description Language. A WSDL file is an XML document that describes a Web service.It specifies the location of the service and the operations (or methods) the service exposes.

  • Contract First - WSDL

  • Code First or Contract First? (2)Contract-First vs Code-First Advantages

    Its independent from your programming language It is more descriptive than a generated WSDL fileyoure able to apply more restrictions and rules here that you otherwise needed to implement in some method in your concrete programming languageIf the server and the client part are implemented by different teams, both sides are able to begin implementing quickly

  • JAX-WS handlers typesSOAP Handlers (or, more precisely, protocol handlers, as JAX-WS supports other non-SOAP protocols such as XML over HTTP), which provide the ability to modify the entire SOAP envelope using the DOM-like SAAJ (SOAP with Attachments API for Java).

    LogicalHandlers with provide access to the SOAP body's content (the payload) only. For logical handlers, JAXB or one of the Source options is used to modify the message instead of the protocol-specific SAAJ.Handlers carry a MessageContext - a thread safe mechanism holding request/response data between the handlers of a chain, and between the client or service endpoints and the handlers

  • JAX-WS handlers types (2)

  • Service-Oriented ArchitectureA service-oriented architecture (SOA) is an architectural pattern in computer software design in which application components provide services to other components via a communications protocol, typically over a network.

    The principles of service-orientation are independent of any vendor, product or technology.

  • SOA and Web Services

  • SOA and Web Services (2)

    Strengths Low follow-up costs Very flexible architecture and governance Compliance with standards Supported by all major software housesWeaknesses High startup and infrastructure costs Requires a comprehensive SOA strategyOpportunities Individual systems can be implemented processes and orchestrated easily

    Threats Lack of focus on relevant business

  • Stages of web services developer1. Denial - It's Simple Object Access Protocol, right?2. Over Involvement - OK, I'll read the SOAP, WSDL, WS-I BP, JAX-RPC, SAAJ, JAX-P... specs. next, I'll check the Wiki and finally follow an example showing service and client sides.3. Anger - I can't believe those #$%&*@s made it so difficult!4. Guilt - Everyone is using Web Services, it must be me, I must be missing something.5. Acceptance - It is what it is, Web Services aren't simple or easy.(Mark Hansen Dave Podnar's Five Stages of dealing with web services)

  • Links

    Web Services Description Language (WSDL) 1.1 http://www.w3.org/TR/wsdlSOAP 1.2 specifications http://www.w3.org/TR/soap/JAXB 2.0 specifications http://jcp.org/aboutJava/communityprocess/mrel/jsr222/index.htmlJAX-RPC http://jcp.org/en/jsr/detail?id=101JAX-WS 2.0 http://jcp.org/en/jsr/detail?id=224Web services metadata http://jcp.org/en/jsr/detail?id=181JAX-RS http://jcp.org/en/jsr/detail?id=311

  • Links (2)IBM JAX-WS presentationhttp://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.wasfpws_v6/wasfpws/6.1/JAX-WS/WASv61_WSFP_JAX-WS_Overview/player.htmlJboss JAX-WS User Guide https://docs.jboss.org/author/display/AS71/JAX-WS+User+GuideApache web services projects http://ws.apache.org/ http://cxf.apache.org/A bunch of free SOAP web services on the net http://www.webservicex.net/ws/default.aspxE-bay - documentation for their webservices https://www.x.com/developers/ebay/documentation-tools/E-bay API for product search http://developer.ebay.com/Devzone/finding/Concepts/MakingACall.html

  • Questions?