Accessing External Web Services from SAP WebFlow
Accessing External Web Services from SAP WebFlow
Out there on the Web and on your intranet, there are myriad services just waiting for you to make use of them: conference bookings; "who's who" services; hotel, flight, or car reservations; fax and paging functions; procurement services… Wouldn't it be great if you could use these functions in your workflow processes as transparently as calling an SAP transaction? Well, with WebFlow, SAP's workflow technology for intranet/Internet use, this is now possible. We at SAP have implemented a service handler that enables services to be included within a workflow definition, and using plug-in technology, this is available for SAP systems even as early as Release 4.0.
For example, suppose an employee needs to attend a conference. After his manager has approved the WebFlow request, the workflow sends a new work item to the employee to take care of conference registration. When the employee executes this work item, it launches a Web service, where the employee fills in his personal preferences in his Web browser. The registration confirmation number is returned to the workflow.
The same procedure applies to the hotel booking and travel arrangement functions (see Figure 1), although the work item for the travel arrangements will likely be sent to a secretary or the travel department. Finally, an e-mail with a trip summary is automatically sent to the applicant and the departmental secretary. If the employee needs to cancel the trip, WebFlow can take care of it, since all the reservation numbers and details have been stored in the workflow's basic data.
This article describes how to add a Web service to a workflow definition, along with the add-ons you will need to support releases predating the 6.10 SAP Web Application Server. But before you add a service to your workflow definition, there are a few things you need to consider:
The Thorny Question of Standards
There are a number of standards evolving to support services offered on the Web. Several have been recommended by the W3C.1 As a W3C member, SAP is actively involved in the definition of several of these standards, and it is a sure bet that some of these standards will eventually dominate the Web. However, many companies have created their services without using any interface or definition standards, simply to have the service available sooner rather than later - something particularly true of services created within a company's intranet for internal use only.
In order to support the maximum number of existing services, WebFlow implementation does not depend on one standard or another. In this sense, it acts as a simple glue that binds together disparate Web services in a workflow definition. However, in contrast to Wf-XML (a "snap-on" method of integrating workflow systems with each other using a well-defined interface), when using WebFlow Web services you will need to analyze each service to determine whether or not it can be used with WebFlow. This depends on whether the service can be parameterized.
Clearly the ultimate goal is to support major standards as they emerge,2 so the architecture of WebFlow Web services is in an excellent position support W3C interfaces as they are finalized.
Types of Services Supported
By its very nature, workflow supports two types of processes - user interactions and automatic functions - which in turn can be conveniently mapped to two types of services. First, dialog services support user interactions, such as performing research in a search engine or selecting a hotel for a conference. The user will receive a work item in his or her inbox and execute it. At this point, the Web browser is launched with the correct URL, together with the correct parameters. The user can finish the task from within the Web browser.
The second type of service consists of automatic procedures, called background services. In this case, the WebFlow system calls the URL in the background without any user interaction at all. In both cases parameters are passed from the workflow to the service, and results can be returned to the workflow.
With a background service, these results can often be returned right away. In the case of dialog services, results will not be returned immediately because the user interaction will probably take several minutes. Rather than block the system while a user navigates in the Web browser, the WebFlow system surrenders control to the browser and returns to other duties until the service calls back with a result or confirmation. At this point WebFlow kicks back into action and continues with the next step. This is called an asynchronous interaction.
The complete palette of services supported is shown in Table 1. You will see that it does not cover all permutations, but it does cover those that are used in practice.
The distinction between these different types of services and interactions has important practical consequences. For example, with dialog services, the user has the freedom to surf off to other Web sites for additional information before completing a Web service. The user could also cancel an action and execute the work item at a later time.
Asynchronous background services come in handy in cases where there is a time lag - when there might be a matter of days between sending an order (work item started) and receiving the goods-delivered acknowledgement (work item completed).
System Landscape
There are two possible landscapes for WebFlow Web services. You may either use the SAP Web Application Server as the service handler or, alternatively, use a simple standalone Java engine with XML configuration files (for those customers who do not yet have access to a 6.10 Web Application Server).3
In Figure 2, notice that WebFlow's directory of Web services does not reside in the component system. It is stored centrally, so that it can be called by any of the SAP component systems without duplicating the maintenance.
In other words, if you set up one service, it can be used by all other SAP systems in your system landscape, provided they have the WebFlow Service plug-in installed and use a Basis platform that is not older than Release 4.0. The plug-in is simply an independent suite of ABAP code and database table definitions, so it is release independent.
The next step is to configure a Web service and generate a workflow task that integrates that Web service. For this article, our examples will only consider the SAP Web Application Server engine, not the Java engine, although the principles are more or less identical.
Configuring the Web Service
Configuring a Web service in WebFlow's central service directory is a piece of cake using transaction wf_extsrv, shown in Figure 3.
In this example, we are defining a messaging Web service like the one detailed in the sidebar "Messaging from Your Workflow Using Web Services."
Before completing the creation of the Web service, you will need to determine three things:
Each URL, like the one in our messaging example, is divided into the domain and directory (in red) and the parameters that are filled by WebFlow when the workflow executes (in purple):
www.unimobile.com/services/sms?partner_phone=0049123432123
&msginv=How%are%you&partner_id=1234
This information is then stored in the WebFlow Web service directory (see the sidebar, "Messaging from Your Workflow Using Web Services").
Using the New Service in a Workflow Process
There is no need to manually create the workflow task for a Web service. Instead, it is generated directly from the Web service definition, using the Business Service Page (BSP) wf_srv_task_generate/createtask.html, which is part of the SAP Web Application Server or Java add-on. Once you pick the Web service and the component system on which the workflow will run, press the Generate task button. The task can be used just like any other task.
You will notice that createtask.html generates input and export container elements that match the parameters belonging to the Web service. Bind the task into the workflow as usual by selecting the container elements that are to be passed to the Web service and those that will be returned.
Summary
The beauty of this feature is that so many Web services already exist, especially within company intranet Web sites. These have been developed outside the SAP environment, for example, using Active Server Pages (ASP) or Java. Now these services can be used in WebFlow - and without upgrading the whole SAP component that contains the workflow definition.
For more information on WebFlow Web services and how to integrate them into your workflow, or to view a recorded demonstration of how this works in practice, visit the WebFlow Service Portal at http://service.sap.com/webflow.
1 W3C (www.w3c.org) is the international industry consortium and resource for protocols, information, and applications for the World Wide Web.
2 For example, in one feasibility test we integrated a Web service using SOAP (Simple Object Access Protocol), one of the hottest Internet standards to emerge in recent years (authored by Microsoft, SAP, IBM, and others).
|
Post a Comment