1 / 48

EGL and Services (SOA)

EGL and Services (SOA). Unit. Topics:. EGL and Services Overview Creating and Consuming Local Services Setting up for Web Services Creating and consuming an EGL Web Service Consuming a 3 rd Party Web Service.

axelle
Télécharger la présentation

EGL and Services (SOA)

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. EGL and Services (SOA) Unit Topics: • EGL and Services Overview • Creating and Consuming Local Services • Setting up for Web Services • Creating and consuming an EGL Web Service • Consuming a 3rd Party Web Service

  2. Services are the driving business system design paradigm of the day.Services – implemented in EGL provide a cross platform language for business oriented developmentServices and SOA are based on the concept of “Service Oriented Design” The Promise of Services and SOA (Service Oriented Architecture) At development time… • Focus on the business logic • Implement SOA design elements: services and interfaces • Leverage existing business developers for new SOA development • Ignore deployment targets/technology while coding/testing Leverage external web services… • EGL Interfaces • Represent external web services • Are created via import from WSDL • Allow the EGL developer to stay within the context of the EGL programming model EGL SOA for WAS, CICS, System i Consume external services Deploy EGL services… To any platform • Java to WAS/Tomcat/etc. • COBOL to CICS, iSeries As… • A Web service (uses SOAP) • A private service (uses CICS ECI, J2C, or TCP) • Other SOA runtimes when they reach critical mass W S D L External Web Service EGL Service EGL Interface EGL Records EGL Service WSDL Deploy Services as Web Services External Applications

  3. Service Oriented Design – Concepts • Service Orientated Designis a software design paradigm that encourages the creation of functionally discrete (modular) business logic, composed of standardized software components (logic routines and subroutines with standard interfaces) • Services are software components that: • Are logically separated, along the lines of a “business service” – such as: • Rent a car – which is further de-composed into: • Reserve a vehicle – consisting of lower-level services such as: • Confirm a location • Confirm the customer information • Get payment information • Confirm customer and payment information • Create the reservation … • Services are formally declared with a standard network interface that allows them to be invoked by other services that only know the interface. • Also, services: • May be created at various levels of business/technical granularity (i.e. low-level vs. high-level) • Can be assembled/combined (“choreographed”) to create higher-level business functionality • Can be deployed to any platform – independently – and called from any platform through their network interface

  4. Network Interface (and More Services Concepts) • “A Service is a network interface to programs that live on a particular machine implemented in such a manner that any other program (or many programs) running on any other machine, written in any language, and running on any OS can call it.”Bob Cancilla, IBM. • Additionally: • Services are an abstract design pattern - they are not the same as Web Services. In fact, a service can be implemented using a number of different technologies, including: • RPC (Remote Program Call) - which you implement with an EGL: • Local Service …or… • Library call …or… • Program • DCOM (Distributed Component Object Model) • REST (Representational State Transfer) • CORBA (Common Object Request Broker) • Web Services – which you implement with an EGL Service part • The “network interface” for a Web Service is formally termed a WSDL • Web Services Description Language

  5. Creating and Consuming Services – WSDL Files and EGL Interfaces • WSDL is an XML document used to describe and locate Web Services. • A WSDL: • Specifies the run-time location as a URL • Specifies operations and data in the Web Service • Is written in XML using the SOAP transport protocol • But you don’t want to: • Learn XML or SOAP or… • Create the WSDL files manually  • You want to code EGL business logic – exactly as you’ve done all along in this course  • So in fact, the RBD tooling will generate all of the “plumbing” for you – when you create or consume Web Services: • When you create an EGL service, the tooling generates WSDL files, so you will not need to learn XML (and other low-level languages, terms and concepts) • When you consume a service, RBD generates EGL Interfaces from existing WSDL files for you – automatically

  6. EGL and Services Overview Topic Sub-Topics: • EGL and Services Overview • Creating and Consuming Local Services • Setting up for Web Services • Creating and consuming an EGL Web Service • Consuming a 3rd Party Web Service

  7. A Simple EGL Service • A service (Local or Web) is coded from the same basic EGL programming model you’ve used all along: • package statement • import statement(s) • service <UniqueName> {optional properties} • Global data (area) • Functions – including a returns(type) on the signature

  8. EGL Services – Steps for Creating and Consuming Local Services  Here are the high-level steps to create a Local Service. • To create a local Service using EGL • Code the service • Generate the service • (if not available) – Create a new services descriptor file • Add the service as a local service • Generate the descriptor file • (if not done) Point to the services descriptor file, from the build-file • To consume a local service from an EGL client 1. Code a variable of <serviceName> type in the client logic • Add a Bindservice property with the appropriate bindkey (not shown, and optional if service binding name is the same as the service part name) serviceVar service1 {@Bindservice{}}; 2. Code the call to the ServiceVar.function(…) – passing parameters retCode int = serviceVar.nyTest(zipIn);

  9.  EGL Local Services – Code the Service – 1 of 2 A “Local Service” is an EGL Service that runs basically like a remote procedure call (RPC). However it IS a Service (EGL Service part) and can be generated into a Web Service with a WSDL without having to recode a single line. You’ve already created a service (in an earlier section of the course) – so let’s go add another Function to it • From \EGLSource\services\ - open service1 in the content area. • Add the following new function: Function name:nyTest Function parms:(zipIn char(5)) returns(int) Function logic: Suggestion: Use Content Assist to create the function logic

  10.  EGL Local Services – Code the Service – 2 of 2 • Still from within edit on service1 – add this custStateSearch function: Follow these steps to create this new service: • Type the new function name and parms (use content assist for the tooling to automatically create the import statement for the Customer array) • Inside the function, code: get customer; • Right-click and using SQL Statement > Add, create an explicit SQL statement • Add the where clause shown above • Right-click and do a SQL Statement > Validate • Save – Ctrl/S • Generate – Ctrl/G

  11.  EGL Services – Create a Descriptor File and Add a Local Service • Recall from one of the labs earlier in this course that you needed to add a new Services Descriptor file. You should already have done this – and its name is: EGLWeb.egldd • You should already have added your service1 part as a LOCAL service. • A Service Client Binding is basically a description of how your client applications (JSFHandlers, Programs, Library functions, Service Functions, etc.) call a Service. • It names the Service • Describes the calling protocol • Etc.  You should not have anything to do here – as long as you finished the Service Workshop earlier in the course. If you didn’t see the ***Notes section of this slide.

  12.  EGL Services – Add the Service Descriptor to the Build-File • Recall from the previous workshop, that you must add a reference to your Service Descriptor file into your Project’s Build File From Project Explorer:  OpenbatchBuildOptions.eglbldin the Content Area  If not already set, from the ellipsis for thedeploymentDescriptorentry, browse-to andselectEGLWeb.egldd • Save (press Ctrl/S) your changes and close the Build File • Generate your Project • You should now be ready to call the Service

  13.  EGL Services – Consume the Local Service To consume a local service 1. Code a variable of <serviceName> type in the client logic 2a. Add a Bindservice property with the appropriate bindkey (see notes) 2. Code the call to the ServiceVar.function – passing parameters From Project Explorer, create a new EGL program in the \programs\ folder: • Name: localServiceTest • Add the following code (comments optional) to the main() function • As you did in previous workshops, add a breakpoint next to an operational EGL instruction inside the function • Press Ctrl/S (save) and Ctrl/G (generate)

  14.  EGL Services – Debug Your Local Services • From Project Explorer, right-click over localServiceTest.egl and select Debug EGL Program - Note that the Debugger allows you to step into the Service calls

  15. Topic Summary • Now that you have completed this topic, you should be able to: • Create a Local Service and its functions • Create a Services Descriptor file • Add the Local Service to the Descriptor file’s client bindings • Consume the Local Service • Declare a variable of type service • Call a service function • Debug a Local Service • Step through the code

  16. EGL Services – Conceptual View  To do a Web Service as opposed to a Local Service, you may want to architect a separate project for your Web Services. You can think of this as a “service” project – and you can think of calls to the web services as coming from “client” projects Service Project • Web Service • EGL Code • Generated Java • Deployment Descriptor • WSDL Client Project • Client process • Service Variable • Call to the Web service • Deployment Descriptor • WSDL (copy) • EGL Interface Common EAR File Note – in our example we will use the same project, but as a best practice, you might consider a separate Service Project

  17. EGL Services – Steps for Creating and Consuming Web Services  Here are the steps we’ll take together, to create a new EGL Web project (from scratch) and use it as our Web Service project. • Start Tomcat – or WebSphere (see ***Notes) • Customize your project’s Build File • Create and generate a Web Service • Code the service • Generate the service • Generate the WSDL for your Service • Test the WSDL Using Web Services Explorer • Consume the Web Service • (If using a 3rd Party WSDL) Import or copy the WSDL to your Client/Project • Add a WSDL entry in the services descriptor file for all Web Services • Generate the services descriptor file • In the client process - code a variable of <serviceName> type • Add a Bindservice property with the appropriate bindkey • Code the call to the ServiceVar.function – passing parameters 1. (From the Servers Tab) Start Tomcat (or WebSphere)

  18.  2. Customize Your Project’s Build-File • Next – you need to select the serverType you will be publishing the Web Server to • Open EGLWeb.eglbld • Un-check Show only specified options • Scroll down to find the serverType option • Use the combo-box to select the serverType for your project • WEBSPHERE • TOMCAT • From Project Explorer: • Generate your Project  Select the serverType

  19.  3. Create a new EGL Web Service • Create a new EGL package in your EGLServiceProject under \EGLSource\ named: services • Create a new Service, in the \services\ package named: ZipService See ***Notes  Check: Create as web service

  20.  3. Create a new EGL Web Service – continued • Create a new function in ZipService named: caTestbk You can either try typing the above function in (using Content Assist), or you can copy/paste in the code – found in the Notes section. Save the Web service  Press Ctrl/S to save and validate the Service

  21.  4. Generate the WSDL for Your Web Service  Generate the Web service - From Project Explorer - Select EGLWeb - Right-Click and select Generate After successfully generating the WSDL, you can open it in the Content Area – it’s located under: \WebContent\WEB-INF\wsdl\ • Close ZipService.WSDL – unless you are using WebSphere ***Notes  Next we will test the Web Service, then we will work in the Client Project and call this Web Service from both a batch program and your updatecustomer2 web page. But if you are using WebSphere – before continuing please read the Slide Notes. ***Notes

  22.  5. Test the Web Service – Interactively • RBD offers a nifty interactive Web Services test facility called the Web Services Explorer. You can use this tool to test your Web Service functionality effectively, before embedding calls to it from your service client. From Project Explorer – find: ZipService.wsdl you just generated under \WebContent\WEB-INF\wsdl\ • Right-click over ZipService.wsdl • Select Web Services • Test with Web Services Explorer ***Notes

  23.  5. Test the Web Service – Interactively  This opens the Web Services Explorer – and specifically, it opens your ZipService in the Navigator – and all of the services functions are exposed as Actions for you to test. • Click caTestbk • Enter a zipCode: • Click Go • Note that 90210 returns: 0 • Less than 90000 returns: -1 *** Your Application Server must be still be started ***

  24. Steps for Creating and Consuming Web Services – Client Project  Review of the steps. By following the previous instructions you have created the Service Project, Service and deployed it as a Web Service. • Start Tomcat (see ***Notes) • Customize your project’s Build File • Create and generate a Web Service • Code the service • Generate the service • Generate the WSDL for your Service • Test the WSDL Using Web Services Explorer • Consume the Web Service (If using a 3rd Party WSDL…next workshop) • Import or copy the WSDL to your Client/Project • Add a WSDL entry in the services descriptor file for all Web Services (If you’ve created an EGL Web Service…this workshop) • Create an EGL Client Interface to the WSDL • Generate the services descriptor file • In the client process - code a variable of <serviceName> type • Add a Bindservice property with the appropriate bindkey • Code the call to the ServiceVar.function – passing parameters  Note – we are not using a 3rd Party WSDL in this workshop, so we begin with the step to create an EGL Client Interface to the WSDL

  25.  6. Create an EGL Client Interface to the WSDL (from Project Explorer) • Right-click over ZipService.wsdl • Select: EGL Services > Create EGL Client Interface… • Click Next >

  26.  6. Create an EGL Client Interface to the WSDL From New EGL Interface • Rename the EGL source file name: IZipService • Rename the Interface name: IZipService • Click Next and then Finish See ***Notes

  27.  Debug the Program and Web Service Call To test the Web Service we will call it from an existing EGL program  Open localServiceTest.egl • Add the following lines of code USING CONTENT ASSIST!(please ) Declare an iZipService variable Invoke iZipService.caTestbk - return an int  Add a breakpoint Because we are going to …

  28.  Debug the Program and Web Service Call • From Project Explorer, right-click over localServiceTest.egl then Debug EGL Program • Step Into all of the statements in the program. • When prompted for the Interface Mapping, click OK ***Notes

  29. Optional Workshop – Call the Web Service From a Web Page  Recall that you have an updatecustomer page that allows customers to update their state and zip code. We can invoke the ZipService as a Web Service, and test for California/Zips updatecustomer JSP Page App Server updatecustomer JSFHandler … Edits done server/side locally … Invoke zipService Remote Process zipService.caTestbk(…) App Server

  30.  Call the Web Service • Open updatecustomer2.egl • Add the following lines of code –USING CONTENT ASSIST!(please ) Declare a Web Service variable  Add the when to your case statement, that references the “CA” state, and calls iZipService’s caTestbk function Alternatively, use the complete source code in the slide ***Notes

  31.  Call the Web Service • From Project Explorer, run allcustomers2.jsp on the Server • Select a customer • Try to update their State with an invalid Zip Code

  32. Optional Topic – Consuming a 3rd Party Web Service • EGL/RBD also allows you to call external (3rd Party-Provided) Web Services. If time remains in your lab, try the following short workshop to see for yourself! Here are the steps you follow (from 10,000 feet): Using a 3rd Party WSDL Steps: 1. Identify/Locate the WSDL file from which the interface will be created 2. Download this WSDL to your project 3. Create an EGL Client Interface 4. Create a calling (client) JSFHandler page It’s really that easy! But a note of caution first: • This next lab requires that you be running a live connection to the internet – free and clear of any corporate fire-walls, or it most likely will not execute. (See ***Notes) Not withstanding, if you will be using 3rd Party services it’s probably worth understanding the work-flow steps to implement with EGL. • The web service used in the lab is a true 3rd Party service. As such it may not be running when you test it – as this is not under our control.

  33. Consuming a 3rd Party Web Service – Find the Service 1. Identify the WSDL file from which the interface will be created – and download this WSDL to your project • From the Xmethods.net site • Click: View the FULL LIST

  34. Consuming a 3rd Party Web Service – Select the WSDL • From the Xmethods site full list, then scroll (or Ctrl/Ffind) the Ignyte Retrieve Theaters and Movie Showtimes service • Click the link for the Web Service you wish to copy from the Xmethods site:

  35. Consuming a 3rd Party Web Service – Save the WSDL Save the WSDL to your project’s \WebContent\WEB-INF\wsdl\ folder as:moviefunctions.wsdl(note you will need to rename the extension in the project and probably Refresh (F5) the project directory you save into)

  36. Consuming a 3rd Party Web Service – Create the EGL Interface • Right click over moviefunctions.wsdl – select: - EGL Services > Create EGL Client Interface… - Click Next > two times From New EGL Web Client Binding - ClickFinish

  37. Consuming a 3rd Party Web Service – The EGL Interface • This will create an EGL Interface to the 3rd Party Web Service – that you can now reference in (call from) client business logic. But first we need to generate all the new Java Classes for all these new project resources • (From Project Explorer)Generate your project – note that you will receive Java Generation errors, which will clean themselves up when you create the page (next part of lab)

  38. Consuming a 3rd Party Web Service – Create a New Web Page  (From the \WebContent\ folder) Create a new Web Page named: moviePage.jsp Change the default Header text…

  39.  Consuming a 3rd Party Web Service – Edit the JSFHandler Code • Edit the Page Code, (moviePage.egl) and using Content Assist create the following JSFHandler logic Note – please either use Content Assist to create this logic, or copy/paste the completed code from the Notes section of this slide. • Press Ctrl/S – and clean up any typos or syntax errors 

  40. Consuming a 3rd Party Web Service – Edit the JSFHandler Code From Page Designer • Press Ctrl/S – to refresh/synchronize the tools From Page Data • Hold down the Ctrl key, and select: radius – int zipCode – string findMovies() • Drag and drop them onto the page • Make the fields Input fields  Updating an existing record • Delete any extraneous Submit Buttons created

  41.  Consuming a 3rd Party Web Service – Edit the JSFHandler Code From Page Data • Select: theaters – Theater[] • Drag and drop the array onto the page • Make all columns read-only Displaying an existing record • Click the ellipsis next to Multi-Column Data • Make the nested columns read-only Displaying an existing record • Click Finish twice OPTIONAL • With the table selected, feel free to change display properties: • Outer table: • Border: 1 • Inner table: • From Display options: delete columnClass1

  42.  Consuming a 3rd Party Web Service – Edit the JSFHandler Code • Run the page • Enter a valid U.S. Postal Code (ZipCode: 90210, 54903, etc), and enter an integer number (Radius) which represents how far - in miles, you would be willing to travel to go to the movies. Note that you must have a live, free and clear internet connection (sans Firewall) for this page to work.

  43.  OPTIONAL – Call Google Maps using the Cinema’s Address – 1 of 2 What if you wanted to allow users to click on a cinema address, and have that bring up a GOOGLEMAP of that address? Here are the steps (note that you may need help from your instructor on this). • Copy/paste the code in this slide’s Notes, as a new function: • Ctrl/S – save your code • From Page Designer • From the Palette/Enhanced Faces Components – find: Link – Command  If it’s not on the Palette you will have to Customize the Palette in order to show this option. Please ask your instructor for assistance on this – or, from the EGL-JSF.PPT, read the slides starting with the slide titled: Customizing the Palette • Assuming you have the Link-Command in your Palette • Select the Address field in the dataTable • Double-Click the Link Command • From Properties click the All Attributes icon • From action, click the Browse icon and select: getAddressMapFunc() All Attributes

  44.  OPTIONAL – Call Google Maps using the Cinema’s Address – 2 of 2 Run the page. Find movies and click an Address .

  45. Optional Topic – EGL Interfaces, the Stuff of 3rd Party Web Service Implementation EGL Interfaces are what is generated by the RBD tooling – out of 3rd Party WSDL functions. • Interfaces provide a concise summary of a service, explaining what the service can do without providing all of the details of implementing the service. • Interfaces can also serve as requirements for development or compliance – by creating them before doing services (EGL or otherwise) package interfaces;interface calculatorInterface function addIntegers (intOne intin, intTwo intin)returns (int); function subtractIntegers (intOne intin, intTwo intin)returns (int);end Example of an EGL Interface package services;import interfaces.calculatorInterface;service calculatorService implements calculatorInterface function addIntegers (intOne intin, intTwo intin) returns (int)return (intOne + intTwo);end function subtractIntegers (intOne intin, intTwo intin) returns (int)return (intOne - intTwo);endend This is the code to be GENERATED, TESTED Example of an EGL Services implementing an Interface

  46. 2 3 4 package interfaces; interface IHelloServiceInterface function SayHello(name stringin, city stringin) returns (string); end EGL Interfaces - RBD Can Create Interfaces From Existing Services and 3rd Party Web Services package services;service HelloService msgstring = " + got to service1.myServiceFunction!"; function SayHello (name stringin, city stringin) returns (string) returnString string; returnString = name::", welcome to "::city::"'"; return (returnString);endend 1

  47.  EGL Services and Web Services Summary/Review • Match the following terms and concepts

  48. Topic Summary • Now that you have completed this topic, you should be able to: • Create a new EGL Web Project • Create a new Service in the Project • Define the service as a Web Service • Consume the Web Service from a separate project • Consumed a 3rd Party Web service Summary

More Related