Lecture 7 Examples for Web Service 苏伟

Slides:



Advertisements
Similar presentations
Siebel Web Services Siebel Web Services March, From
Advertisements

31242/32549 Advanced Internet Programming Advanced Java Programming
Francisco Gonzalez Mario Rincon.  Apache CXF is an open source services framework.  CXF helps you build and develop services using frontend programming.
Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
Web Services with Apache CXF
JNDI Java Naming Directory Interface JNDI is an API specified in Java that provides naming and directory functionality to applications written in Java.
Webservices using JAXB and JAX-WS Lalit Bhatt SpiderLogic
Scale Up Access to your 4GL Application using Web Services
6/2/2015Page 1 SOA Development and Deployment B. Ramamurthy.
Integrating SOA and the Application Development Framework Shaun O’Brien Principal Product Manager – Oracle JDeveloper / ADF.
6/11/2015Page 1 Web Services-based Distributed System B. Ramamurthy.
 2007 Pearson Education, Inc. All rights reserved JAX-WS Web Services, Web 2.0 and Mash-Ups.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
1 HyCon Framework Overview Frank Allan Hansen and Bent Guldbjerg Christensen ! Run this presentation in presentation mode to watch animations.
Slide 1 EE557: Server-Side Development Lecturer: David Molloy Room: XG19 Mondays 10am-1pm Notes:
Ravi Palejiya Ruofan Xu.  Consumer often spends lot of time on searching for best deals of products on different websites.  SOAShopper provides a solution.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Apache Chemistry face-to-face meeting April 2010.
1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
C Copyright © 2009, Oracle. All rights reserved. Appendix C: Service-Oriented Architectures.
Developing Web Services with the Eclipse Web Tools Platform Boris Minkin.
Design of Distributed Software 2.7 Web Services 1.Introduction : Service Oriented Architectures 2.Technology building blocks 3.Java Web Services.
Developing Web Services Oracle SOA Suite 11g (JDeveloper)
Entity Java Beans Jorg Janke Open Source ERP & CRM.
COP 4991 Component Based Software Development Lecture #4 Java Web Services Onyeka Ezenwoye.
1 HRS2422 Web Services JAX-WS and SOAP Introduction  Web service – A software component stored on one computer that can be accessed via method.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Web servisu izstrāde JAX-WS. Ievads JAX-WS = Java API for XML Web Services JAX-WS ir fundamentāla Web servisu izstrādes tehnoloģija Java EE 5 un Java.
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
Message Driven Beans & Web Services INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
SCA Bindings Simon Holdsworth Piotr Przybylski. Agenda n SCA Bindings Overview l Bindings TC Charter n Bindings l Web Services Binding l JMS Binding l.
© 2007 IBM Corporation SOA on your terms and our expertise Software WebSphere Process Server and Portal Integration Overview.
Web Services (SOAP) part 1 Eriq Muhammad Adams J |
XML and Web Services (II/2546)
INT-9: Implementing ESB Processes with OpenEdge ® and Sonic ™ David Cleary Principal Software Engineer.
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
WEB 服务初级编程 祝伟华 网络新型服务技术中心. 内容 分布式计算 互联网分布式计算标准 定义 发布 使用 其它特性.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
ODS – Introduction to Web Services and BPEL Vakgroep Informatietechnologie Web Services & BPEL Design of Distributed Software.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
.NET Mobile Application Development XML Web Services.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
1 Web services for DIP LDIWG meeting C.H.Sicard 7 Jan 2003.
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
The Java API for XML-Based Web Services. A Web Service example in Java SOAP-awareServlet (e.g. Apache Axis2) SOAP-awareServlet Any class processing the.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
© 2009 IBM Corporation 1 JAX-WS 2.1 Support For WS-Addressing In WebSphere Application Server V 7 18 March 2010.
CONNECT, Non EJB Programming Model.. CONNECT Architecture with EJB Current code base is using EJB services implemented by using the JAX-WS. Only session.
Labs: Create, deploy and test a simple web service
J2EE Lecture 10: EJB 3.0 Overview
Developing Web Services with the Eclipse Web Tools Platform
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Ravi Palejiya Ruofan Xu
Writing simple Java Web Services using Eclipse
Web Services-JAX-RPC JAX-RPC enables a Web Service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model.
Lecture 7 Examples for Web Service
Web-Services-based Systems Architecture, Design and Implementation
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Introduction to Web Services
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Distributed System using Web Services
Distributed System using Web Services
Presentation transcript:

Lecture 7 Examples for Web Service 苏伟

Part I JAX-WS

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Quick Overview of JAX-WS 2.1  Simpler way to develop/deploy Web services – Plain Old Java Object (POJO) can be easily exposed as a Web service – No deployment descriptor is needed - use Annotation instead – Layered programming model  Part of Java SE 6 and Java EE 5 platforms  Integrated data binding via JAXB 2.1  Protocol and transport independence

SOA & Web Service Lan Zhou University JAX-WS Core specification for a newly redesigned API stack for Web services – Includes JAX-WS V2.1, JAXB V2.1, SAAJ V1.3 and StAX V1.0

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Two ways to create a Web Service  Starting from a WSDL file (top-down approach) –Generate classes using wsimport WS interface WS implementation skeleton class –Add business logic to the WS implementation class –Build, deploy, and test  Starting from a POJO (bottom-up approach) –Annotate POJO –Build and deploy –WSDL file generated automatically

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Server-Side Programming Model:(Starting from POJO) 1.Write a POJO implementing the service annotation to it 3.Optionally, inject a WebServiceContext 4.Deploy the application 5.Point your clients at the WSDL e.g.

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Example 1: Servlet-Based public class Calculator { public int add(int a, int b) { return a+b; } annotation –All public methods become web service operations  WSDL/Schema generated automatically –Default values are used

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Example 2: public class Calculator WebServiceContext context; public int add(int a, int b) { return a+b; }  It’s a regular EJB 3.0 component, so it can use any EJB features –Transactions, security, interceptors...

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Customizing through targetNamespace=” public class CreditRating public Score Customer c) { //... implementation code... }

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Java SE Client-Side Programming 1.Point a tool (NetBeans or wsimport) at the WSDL for the service wsimport 2.Generate annotated classes and interfaces 3.Call new on the service class 4.Get a proxy using a get Port method 5.Invoke any remote operations

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Example: Java SE-Based Client CalculatorService svc = new CalculatorService(); Calculator proxy = svc.getCalculatorPort(); int answer = proxy.add(35, 7);  No need to use factories  The code is fully portable  XML is completely hidden from programmer

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Java EE Client-Side Programming 1.Point a tool (NetBeans or wsimport) at the WSDL for the service wsimport 2.Generate annotated classes and interfaces 3.Inject of the appropriate type No JNDI needed 4.Invoke any remote operations

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Example: Java EE-Based public class MyBean { // Resource Calculator proxy; public int mymethod() { return proxy.add(35, 7); }

SOA & Web Service Lan Zhou University Bottom-up development tooling IBM Rational Application Developer V7.5 provides wizards to create complete Web service applications from: – JavaBeans – Stateless session EJBs – JPA entities – SQL statements The wizards can: – Generate source code for services – Generate source code for service clients (including Web pages) – Generate WSDL – Assemble, deploy, install, start and test the service – Assemble, deploy, install, start and test service clients

SOA & Web Service Lan Zhou University Creating a Web service from JavaBeans Configure and start a server Create or import a bean into the source folder of a Java project or dynamic Web project Switch to the Java EE perspective Select the bean in the Enterprise Explorer Invoke the Web services wizard by choosing either: Web Services > Create Web Services from context menu File > New > Other > Web Services > Web Service from the workbench menu

SOA & Web Service Lan Zhou University Testing with the Web Services Explorer

SOA & Web Service Lan Zhou University Useful URLs – Displays the namespace of the service and a greeting – Mostly used to verify service is running – Retrieves the dynamically generated WSDL for the service servicename_schema1.xsd – Retrieves the XML schema for the WSDL Examples: – – –

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Annotations Used in JAX-WS  JSR 181: Web Services Metadata for the Java Platform  JSR 222: Java Architecture for XML Binding (JAXB)  JSR 224: Java API for XML Web Services (JAX-WS)  JSR 250: Common Annotations for the Java Platform

SOA & Web Service Lan Zhou University 教育部 -IBM  Marks a Java class as implementing a Web Service, or a Java interface as defining a Web Service interface.  Attributes –endpointInterface –name the value of wsdl:portType –portName the value of wsdl:portName –serviceName the value of wsdl:service –targetNamespace –wsdlLocation

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 properties

SOA & Web Service Lan Zhou University 教育部 -IBM  Customizes a method that is exposed as a Web Service operation  Attributes –operationName Specifies the name of the wsdl:operation that for this method. The default value is the name of the Java method. –action Defines the value (a URI) of the SOAPAction header in HTTP. This gives the receiving servlet a hint as to the intent of the message. –exclude If true, indicates that the method should be excluded from the Web service. The default value is false.

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 properties

SOA & Web Service Lan Zhou University 教育部 -IBM  Customizes the mapping of an individual parameter to a Web Service message part and XML element.  Attributes >header >mode >name >partName >targetNamespace

SOA & Web Service Lan Zhou University 教育部 -IBM  Customizes the mapping of the return value to a WSDL part and XML element.  Attributes >header >name >partName >targetNamespace

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 = " use=SOAPBinding.Use.LITERAL) public interface AddNumbersIF public int number2) throws AddNumbersException; }

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Protocol and Transport Independence  Typical application code is protocol-agnostic  Default binding in use is SOAP 1.1/HTTP  Server can specify a different binding,  Client must use binding specified in WSDL  Bindings are extensible, expect to see more of them >e.g. SOAP/Java Message Service(JMS) or XML/SMTP

SOA & Web Service Lan Zhou University 教育部 -IBM DING) public class AddNumbersImpl { // More code

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Handler Types  JAX-WS 2.0 defines a Handler interface, with subinterfaces LogicalHandler and SOAPHandler. >The Handler interface contains >handleMessage(C context) >handleFault(C context) >C extends MessageContext >A property in the MessageContext object is used to determine if the message is inbound or outbound  SOAPHandler objects have access to the full soap message including headers  Logical handlers are independent of protocol and have access to the payload of the message

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Logical Handler public class MyLogicalHandler implements LogicalHandler { public boolean handleMessage(LogicalMessageContext messageContext) { LogicalMessage msg = messageContext.getMessage(); return true; } // other methods }

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 SOAP Handler public class MySOAPHandler implements SOAPHandler { public boolean handleMessage(SOAPMessageContext messageContext) { SOAPMessage msg = messageContext.getMessage(); return true; } // other methods }

Part II 手机短信发布平台 Web Service 开发实例

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 利用 WebService 实现异构系统方法的调用

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 基于 JAX-WS 的 WebService 开发 package com.cwq.ws; public class SayHello{ public string SayHello(String name){ Return "Hello"+name; }

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 发布手机短信 web service 服务 Windows/system32/FT_ET99_API.dll JET99A120.dll %JDK%/JRE/lib/ext/RxTxComm.jar %tomcat%/bin/FT_ET99_API.dll JET99A120.dll RxTxParallel.dll rxtxSerial.dll Szhtogsm.jar RxTxComm.jar Eclipse: Szhtogsm.jar RxTxComm.jar

SOA & Web Service Lan Zhou University 教育部 -IBM 专业综合改革项目 Dotnet web service 客户端  代码如下: –Localhost.MsgService svr=new eshop.localhost.MsgService(); –svr.send(tel," 您在 eshop 的密码已找回,新密码是 "+newPassword);  运行结果如下:

SOA & Web Service Lan Zhou University Thank you !