Docsity

Building Cloud-Based Services: A Dream vs. Reality, Study notes of Software Engineering

Partial preview of the text

Download Building Cloud-Based Services: A Dream vs. Reality and more Study notes Software Engineering in PDF only on Docsity!

Last time, we studied how to build a service using SOAP: Services Monday, November 26, 2012 10:54 AM Docsity.com

You create a subroutine in Java. You ask politely that it be presented as a service. The service is written for you. Your service's nature is advertised on the web. Your service becomes discoverable in searches. Clients are automatically written to call the service -- in any language. The dream of service architecture The dream of service architecture Monday, November 26, 2012 11:03 AM Docsity.com

Part I: Code generation strategies. What happens "outside the code"? Part II: Persistence strategies. What has to happen "inside the code"? Details of a cloud-based service Details of a cloud-based service Monday, November 26, 2012 2:23 PM Docsity.com

How can we avoid the tedium of XML/XSchemas in writing web services? What will we give up as a result? Part I: code generation Part I: code generation Monday, November 26, 2012 2:24 PM Docsity.com

Start by defining Plain Old Java Objects (POJOs) that you want to turn into web services, e.g., that read NoSQL data. Generate XML Schemas, service stubs, etc using a service deployment framework , e.g., Apache Axis 2. Don't even learn XML or Schemas! The framework handles all of that! The new world order: bottom-up service development Bottom-up service development Wednesday, March 10, 2010 10:05 AM Docsity.com

Manage "deployment" of a service. Java Code to deploy. Some configuration options. Require only minimal input from you. Result: a running service. Service deployment frameworks Apache Axis (LAMP) Microsoft Visual Studio Services (IIS) Two main ones: Service deployment frameworks Wednesday, March 10, 2010 1:31 PM Docsity.com

The POJO must be "serializable": it must be possible to make a portable copy of the object. The service calls must be methods in the object. Requirements Requirements Monday, November 26, 2012 4:40 PM Docsity.com

Define a simple service as a java class. Tell Axis it should become a service. "Package" the service. "Deploy" the service. Reference: http://wso2.org/library/ Using Axis Using Axis Wednesday, March 10, 2010 10:18 AM Docsity.com

Informing Axis of the service: services.xml locked="false">SimpleService

Pasted from Informing Axis of the service Wednesday, March 10, 2010 10:19 AM Docsity.com

Axis expects service files to be found in a specific directory hierarchy. Packaging the service mkdir temp javac SimpleService.java - d temp/ mkdir temp/META.INF cp services.xml temp/META.INF/ cd temp jar - cvf SimpleService.aar * Creating the hierarchy: Packaging the service Wednesday, March 10, 2010 10:21 AM Docsity.com

conf subdirectory containing axis2.xml empty modules subdirectory (contains jars that your code might need). services directory containing SimpleService.aar Create a "repository" axis2-repo containing sh http-server.sh /path/to/axis2-repo Run the SimpleHTTPserver: Using SimpleHTTPServer Using SimpleHTTPServer Wednesday, March 10, 2010 10:32 AM Docsity.com

Axis2 Services are reflective , i.e., they are self-describing on the web. If one runs the SimpleHTTPserver and browses to http://localhost:8080/services/SimpleService one gets a description of the service and even how to use it. Weird: one has to have the service running before one can build a client to it. Now things get interesting… Now things get interesting… Wednesday, March 10, 2010 10:45 AM Docsity.com

// SimpleServer.echo corresponds to // SimpleServiceStub.EchoResponse // in generated code. package org.apache.axis2; import org.apache.axis2. SimpleServiceStub.EchoResponse ; SimpleServiceStub stub = new SimpleServiceStub(); public static void main(String[] args) throws Exception { public class Client { //Create the request SimpleServiceStub.Echo request^ =^ new^ SimpleServiceStub.Echo(); request.setParam0("Hello world"); //Invoke the service EchoResponse response^ =^ stub.echo(request); System.out.println("Response : " + response.get_return() ); } } Pasted from Querying via generated code Wednesday, March 10, 2010 10:51 AM Docsity.com

XSchemas are generated by the language type system. They do not fully enforce preconditions. Reason: just-in-time compilation. In Axis, it isn't possible to do so. XML is slow to encode/decode. This is a performance issue. So we don't use this for non-public interfaces. What did we give up? What did we give up? Monday, November 26, 2012 2:25 PM Docsity.com