1 / 45

Web Services and Application Development Frameworks Supplemental Lecture **NOT ASSESSIBLE**

Web Services and Application Development Frameworks Supplemental Lecture **NOT ASSESSIBLE**. Web Services. Web Services are used primarily as a means for businesses to communicate with each other and with clients.

nhu
Download Presentation

Web Services and Application Development Frameworks Supplemental Lecture **NOT ASSESSIBLE**

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Services and Application Development FrameworksSupplemental Lecture**NOT ASSESSIBLE** ICT337 Week13 Supplemental: Web Services

  2. Web Services • Web Services are used primarily as a means for businesses to communicate with each other and with clients. • They allow organisations to transfer data without knowing the details of the IT systems behind the firewall. • Web services do not provide the user with a GUI, rather they share business logic, data and processes through a programmatic interface across a network. ICT337 Week13 Supplemental: Web Services

  3. Web Services • Web services allow different applications from different sources to communicate with each other without custom coding, and because all communication is in XML, Web services are not tied to any one operating system or programming language. • For example, Java can talk to Perl, Windows applications can talk with UNIX applications. ICT337 Week13 Supplemental: Web Services

  4. Web Services • Web Servicesis our current generation of technologies to allow application-to-application (program-to-program) communication by using XML. • It covers how to: • define modular, self-describing applications • publish the applications so they are available • locate these available applications from anywhere • invoke these applications remotely • All these using open Internet standards like XML, HTTP and SMTP. ICT337 Week13 Supplemental: Web Services

  5. Web Services • Please note the difference between this technical use of the word “Web Services” and the non-technical use of “web services”, which refers to any program available through an HTML form over the web. ICT337 Week13 Supplemental: Web Services

  6. Distributed Object Technologies • There have been past efforts to provide program-level object exchange: • OMG’s CORBA/IIOP (www.corba.org/) • Microsoft’s DCOM (www.microsoft.com/com/tech/dcom.asp) • Java RMI (java.sun.com/rmi) • But all of these technologies suffer from: • Complex set-up and object invocation. • Platform and language dependence. • Lack of universal acceptance. • Lack of extensibility to different problem areas. ICT337 Week13 Supplemental: Web Services

  7. What is missing today? • What is missing today is a consistent way to allow a service (program, application) communication with another: • There is no consistent framework for describing how a service can be invoked. eg. how do I use a particular PHP application? • There is no consistent framework for listing available services, and how clients can discover them. eg. how do I find out what other PHP applications are available? • Location of services on the web and how to use them have to be manually determined, and then manually invoked - they can’t be done by programs automatically. ICT337 Week13 Supplemental: Web Services

  8. Developing Web Services • Various companies and organisations have taken strong initiatives to gain and maintain the loyalty of software developers as we move towards Web Services. • The two biggest initiatives: • SUN and the Java approach • Microsoft’s .NET ICT337 Week13 Supplemental: Web Services

  9. Microsoft .NET • .NET is a model targeted at migrating Microsoft’s focus from desktop-based software towards Internet-based software. • Uses XML as the basis for data exchange. ICT337 Week13 Supplemental: Web Services

  10. Components of .NET • Different parts of the .NET initiative: • Tools for software developers • Visual Studio .NET • the .NET Framework (consisting of a runtime engine CLR, languages ASP.NET and C#, XML classes, etc) • .NET Enterprise Servers • where all the data will reside and be served from • e.g.. BizTalk 2000, Commerce Server 2000, SQL Server 2000, etc. • .NET operating systems. • Building Block Services. • Collections of complete services for integrating into other software. • e.g.. Passport .NET for user authentication ICT337 Week13 Supplemental: Web Services

  11. Sun’s ONE • Sun Microsystems's future vision of web services is based on its Open Net Environment (ONE) initiative. • Heavy promotion of developments in Java technologies • Especially in its J2EE (Java 2 Enterprise Edition) ICT337 Week13 Supplemental: Web Services

  12. Platform Independence • These are the two biggest initiatives in the industry today to lock Internet service and application developers into one environment. • Microsoft claims programming language independence with .NET (ONE uses Java), while Sun claims operating system independence with ONE (.NET requires Microsoft OS and servers to operate). ICT337 Week13 Supplemental: Web Services

  13. Advantages claimed by .NET • Cross-language development. • Power and Integration of Visual Studio.Net as a development tool. • Simpler programming model - easier to pick up. • Interweaved with the operating system - makes use of the powerful facilities available. ICT337 Week13 Supplemental: Web Services

  14. Advantages claimed by Java • Proven technology in the enterprise environment. • Systems portable to other operating systems. • More advanced and powerful programming model. • Standards developed by an industry instead of one vendor. ICT337 Week13 Supplemental: Web Services

  15. Other Frameworks • Other organisations also push their own versions of development frameworks, although not as extensive or as fanatically, as Java or .NET. • eg. • IBM’s WebSphere • http://www-3.ibm.com/software/info1/websphere/index.jsp?tab=highlights • BEA’s WebLogic • http://www.bea.com/products/weblogic/platform/index.shtml • Apache XML Project • http://xml.apache.org/ ICT337 Week13 Supplemental: Web Services

  16. Web Service Example Source: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconwebservicesinfrastructure.asp ICT337 Week13 Supplemental: Web Services

  17. Components of Web Services • In Web Services, we • describe a service using the Web Services Description Language (WSDL). • define a way to publish and discover information about Web services using Universal Description, Discovery and Integration (UDDI), and • invoke the service using Simple Object Access Protocol (SOAP). • We will look at WSDL and SOAP. ICT337 Week13 Supplemental: Web Services

  18. WSDL WSDL1.1 Document Structure • A WSDL document describes • What the service can do • Where it resides • How to invoke it • WSDL are like IDL but lot more flexible and extensible • Defines binding for SOAP1.1, HTTP GET/POST and MIME • WSDL descriptions can be made available from an UDDI registry WSDL Document [Types] {Messages} {Port Types} {Bindings} {Services} ICT337 Week13 Supplemental: Web Services

  19. WSDL • WSDL can be generated dynamically by web service frameworks, or from scratch. • Creating a WSDL from scratch allows for a great deal of flexibility and makes it easier for consumers of web services to create clients when not using proxy-generated classes. • WSDL has the ability to specify a specific ordering of element, cardinality and optionality, etc. ICT337 Week13 Supplemental: Web Services

  20. XML based protocol for exchange of information Encoding rules for datatype instances Convention for representing RPC invocations Designed for loosely-coupled distributed computing No remote references Used with XML Schema Transport independent SOAP with Attachments allow arbitrary data to be packaged. SOAP SOAP1.1 Message Structure SOAP Envelope Header Entries [Header Element] Body Element [Fault Element] ICT337 Week13 Supplemental: Web Services

  21. Methods of Implementing in Java • Many text books on Web Services tend to present far too much theory and few examples that can help you to create your own Web Services. • No service, regardless of its percieved benefits can be considered useful unless there are applications, tools, and reference materials that make development easier • Look for very recent text books. Most of the older ones are heavy on theory and use packages that are out of date. Many of the examples wont work unless you can track down an older version of the tool. ICT337 Week13 Supplemental: Web Services

  22. Methods of Implementing in Java • There are Applications/Tools that can make creating and running your own web services in Java very easy. The most notable include. • Java Web Services Developer Pack • AXIS • Electric Glue ICT337 Week13 Supplemental: Web Services

  23. AXIS • Axis is essentially a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, gateways, etc. • The current version of Axis is written in Java. • Supports 3 modes of services- • RPC – default – Object based. AXIS hides all the complicated implementation from you. • Document/Wrapped – uses plain XML. • Message based – XML contained in java XML objects. • a simple stand-alone server. • a server which plugs into servlet engines such as Tomcat, • extensive support for the Web Service Description Language (WSDL), • emitter tooling that generates Java classes from WSDL. • some sample programs, and • a tool for monitoring TCP/IP packets. • A tool for monitoring raw SOAP messages. ICT337 Week13 Supplemental: Web Services

  24. AXIS - Installation • Make sure that you have • J2SE SDK 1.3 or 1.4: We will use 1.4 • A Servlet Container: We will use Tomcat • Download the AXIS package from http://xml.apache.org/axis • Unzip it and look at the dir. tree. Note that Axis runs as a Servlet. • Deploy Axis. • Copy webapps\axis tree to webapps directory of Tomcat. • Alternatively, modify server.xml of Tomcat. • Run Tomcat. • Test the installation with the test JSP. Load http://localhost/axis/happy.jsp. This script will tell you if anything else is required. Direcotry Structure: axis webapps lib docs samples axis WEB-INF lib classes web.xml …… ICT337 Week13 Supplemental: Web Services

  25. AXIS - Setup • The above will generally install AXIS for use by Tomcat. • If you compile/run anything from the command line, you will need to make the AXIS jars (axis/lib directory) visible so the java compiler and interpreter can find them. • You can do this by: - • creating a simple batch file that adds each of these jars to the classpath. Then run this each time you run from the command line. • Adding each AXIS jar to the CLASSPATH environment variable in windows. If you do it this way java can find the jars without having to do anything supplemental. • Create a new environment variable in windows and then include the environment variable when you compile of run java files. • If you are using JBuilder or similar, specify the jars as required libraries. ICT337 Week13 Supplemental: Web Services

  26. Creating web services in AXIS • Two mechanisms. • Java Web Service (JWS) – easiest. • Custom deployment. ICT337 Week13 Supplemental: Web Services

  27. Creating web services in AXIS - JWS • JWS • Simple way to create basic web services • Step 1: Create a java class with the services you want to deploy. • Step 2: Save the file with a .jws extension. • Step 3: move to webapps/axis directory on Tomcat. That’s it. public class echo { public String echoBack(String word) { return "You said "+word; } } ICT337 Week13 Supplemental: Web Services

  28. Creating web services in AXIS - JWS • AXIS takes care of everything for you. • If you want to view the wsdl just append ?wsdl to the end of the url. • As axis creates a wsdl, the web service can be invoked by any client on any platform using any language (as long as it has any SOAP API). ICT337 Week13 Supplemental: Web Services

  29. AXIS – JWS Clients – Manual Client • You can create a client in one of two ways in AXIS. • Create a client from scratch. • Dynamically create stubs and skeletons using wdsl2java. • Code can be embedded into other applications, servlets, JSPs, etc. • Clients that use AXIS are generally object based. However AXIS does support pure XML exchange. ICT337 Week13 Supplemental: Web Services

  30. AXIS – JWS Clients – Option 1 import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class echoClient { public static void main(String [] args) throws Exception { String endpoint = "http://localhost/axis/echo.jws"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName("echoBack"); String ret = (String) call.invoke( new Object [] { "Your mother" }); System.out.println("Got result : " + ret); } } ICT337 Week13 Supplemental: Web Services

  31. AXIS – JWS Clients – Option 1 ICT337 Week13 Supplemental: Web Services

  32. AXIS – JWS Clients – Option 2 • In the second option we use wsdl2java to generate some skeletons and stubs and the write a small client. • Issue the command: -java org.apache.axis.wsdl.WSDL2Java http://localhost/axis/echo.jws?wsdl • This will create a package with some java skeletons in it. In our case it created- • localhost\axis\echo_jws\Echo.java • localhost\axis\echo_jws\EchoService.java • localhost\axis\echo_jws\EchoServiceLocator.java • localhost\axis\echo_jws\EchoSoapBindingStub.java • EchoSoapBindingStub is the one we are concerned with. It provides an object with a number of constructors and an echoBack method that we can use like a normal java object. ICT337 Week13 Supplemental: Web Services

  33. AXIS – JWS Clients – Option 2 import localhost.axis.echo_jws.*; import java.net.URL; import org.apache.axis.client.Service; public class echoClient2 { public static void main(String [] args) throws Exception { EchoSoapBindingStub ser=new EchoSoapBindingStub(new URL("http://localhost/axis/echo.jws"),new Service()); String ret = ser.echoBack("my mother"); System.out.println("Got result : " + ret); } } ICT337 Week13 Supplemental: Web Services

  34. AXIS – JWS Clients – Option 2 ICT337 Week13 Supplemental: Web Services

  35. Creating web services in AXIS – Custom Deployment using Web Service Deployment Descriptor (WSDD) • JWS is easy and fast but with the following limitations- • you need to expose the source. • the amount of configuration you can do as to how the service gets accessed is pretty limited. • you can't specify custom type mappings, or control which Handlers get invoked when people are using your service. • Using WSDD we can run configurable services with advanced options. ICT337 Week13 Supplemental: Web Services

  36. AXIS - WSDD • Implementing a web service using WSDD only requires a few additional steps. • Compile the java class, rather than just giving it a .jws extension. • Create a WSDD file which tells AXIS how to deploy the class. • Run the adminClient to send the service to the AXIS server for deployment. ICT337 Week13 Supplemental: Web Services

  37. AXIS – WSDD – deploying a service • To deploy echo.java as a service • Compile echo.java. • Move echo.class to webapps\axis\WEB-INF\classes. • Create a WSDD file <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="echo" provider="java:RPC"> <parameter name="className" value="echo"/> <parameter name="allowedMethods" value="*"/> </service> </deployment> ICT337 Week13 Supplemental: Web Services

  38. AXIS – WSDD – deploying a service • Use the adminClient to deploy the service. The –p80 at the end is used to specify the port (needed if not running on port 8080). ICT337 Week13 Supplemental: Web Services

  39. AXIS – WSDD – deploying a service • Test the service is up and running by loading in a browser. Note the addition of “services” in the url. ICT337 Week13 Supplemental: Web Services

  40. AXIS – WSDD – deploying a service • The clients created earlier will still work after we modify the url. ICT337 Week13 Supplemental: Web Services

  41. AXIS – WSDD – undeploying a service • If we need to remove a web service then we need to undeploy it. • Create an undeploy wsdd file<undeployment xmlns="http://xml.apache.org/axis/wsdd/"> <service name="echo"/></undeployment> • Run the adminClient to undeploy the service ICT337 Week13 Supplemental: Web Services

  42. AXIS – WSDD • The process of deploying/undeploying is relatively simple. • Unless we need to configure the service differently, you can copy the wsdd files and change a couple of values which represent the name of your class/service. ICT337 Week13 Supplemental: Web Services

  43. AXIS - SoapMonitor • Axis provides an applet that monitors raw soap requests/responses. • Can be used for debugging. • Can also be used to determine the XML needed to support a particular WSDL. WSDL files that are generated dynamically can be a bit hard to read. If you need the XML, you can use wsdl2java, run the client and then you will have the necessary XML. ICT337 Week13 Supplemental: Web Services

  44. AXIS – Conclusion • AXIS provides an easier mechanism to deploy and consume services. • Similar tools exist in other packages. AXIS is open source. • AXIS can connect to other web services in other platforms, and can process requests made from clients on other platforms. • A good choice when starting off in web services. You can use the object-based implementations while you are learning XML/XSLT, etc. • If you are not undertaking serious development in web services, you wont have to learn XML at all. ICT337 Week13 Supplemental: Web Services

  45. References • ICT211 Week 9 Lecture Notes. • AXIS installation and user guides. • Web Services and the Semantic Web • http://www.w3.org/2002/ws/ • http://www.w3.org/2001/sw/ • Microsoft’s .NET • http://msdn.microsoft.com/net/default.asp • Java • http://java.sun.com ICT337 Week13 Supplemental: Web Services

More Related