sap composite application framework€¦ · composite application framework (caf) capabilities. the...

22
Integrating a Web Service in a Composite Application SAP Composite Application Framework Document Version 1.00 – November 2005

Upload: others

Post on 13-Oct-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

Integrating a Web Service in a Composite Application

SAP Composite Application Framework Document Version 1.00 – November 2005

Page 2: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

SAP AG Neurottstraße 16 69190 Walldorf Germany T +49/18 05/34 34 24 F +49/18 05/34 34 20 www.sap.com

© Copyright 2005 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. Disclaimer Some components of this product are based on Java™. Any code change in these components may cause unpredictable and severe malfunctions and is therefore expressively prohibited, as is any decompilation of these components. Any Java™ Source Code delivered with this product is only to be used by SAP’s Support Services and may not be modified or altered in any way.

Page 3: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

T yp o g r a p h i c C o n v e n t i o n s I c o n s Type Style Represents Example Text Words or characters quoted from

the screen. These include field names, screen titles, pushbuttons labels, menu names, menu paths, and menu options. Cross-references to other documentation.

Example text Emphasized words or phrases in body text, graphic titles, and table titles.

EXAMPLE TEXT Technical names of system objects. These include report names, program names, transaction codes, table names, and key concepts of a programming language when they are surrounded by body text, for example, SELECT and INCLUDE.

Example text Output on the screen. This includes file and directory names and their paths, messages, names of variables and parameters, source text, and names of installation, upgrade and database tools.

Example text Exact user entry. These are words or characters that you enter in the system exactly as they appear in the documentation.

<Example text> Variable user entry. Angle brackets indicate that you replace these words and characters with appropriate entries to make entries in the system.

EXAMPLE TEXT Keys on the keyboard, for example, F2 or ENTER.

Icon Meaning

Caution

Example

Note

Recommendation

Syntax

Page 4: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

Contents Introduction......................................................................................................................... 2

About This Document................................................................................................ 2 Prerequisites ............................................................................................................. 2 Disclaimer.................................................................................................................. 2

Create the Development Component Project .................................................................... 2 Import a Web Service as an External Service.................................................................... 5 Encapsulate the Web Service in an Entity Service ............................................................ 8 Runtime External Service Configuration .......................................................................... 14 Test the External Service ................................................................................................. 17

Page 5: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

Introduction About This Document This tutorial is a part of a series that describes how to implement a composite application using SAP Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your composite application using the capabilities of the CAF Service and UI layer.

Prerequisites The following table describes the prerequisites for running this tutorial. Software The tutorial is compliant with:

• Sneak Preview SAP NetWeaver 04 – Web Application Server 6.40 Java. You can download the sneak preview at http://sdn.sap.com

• SAP NetWeaver 2004s SPS04 Documents Before you start with this tutorial, see:

• Creating a Local Entity with Maintenance UI

Disclaimer Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.

Create the Development Component Project ...

1. Launch the SAP NetWeaver Developer Studio. 2. Chose Window → Open Perspective → Other... → Composite Application Services. 3. Navigate to File → New → Project and choose to create a new development component

project.

Choose Next.

Page 6: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

4. Select Local Development → MyComponents and choose Next.

Page 7: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

This tutorial does not describe development using the SAP NetWeaver Development Infrastructure (NWDI). For more information about NWDI, see the relevant documentation available in the SAP NetWeaver Developer’s Guide at http://sdn.sap.com/irj/sdn/developersguide.

5. In the next screen, enter the following data, and then choose Next. Field Value Name user_example (use only small letters) Caption User Example Application Domain SAP xApps Type Composite Application Services

6. Choose Next again.

You see a list of the projects that are generated as a part of your development component (DC). 7. To complete the procedure, choose Finish.

Page 8: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

You see the new project in the Service Explorer view.

Import a Web Service as an External Service ...

1. In the Service Explorer view, select <your project name> → External Services, and open the context menu using the secondary mouse button.

2. Choose Import.

3. Select the option Web Service and choose Next.

Page 9: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

4. Select Local File System or URL as the source system for the Web service metadata.

Choose Next.

5. Set the WSDL to the following URL:

http://<host>:<port>/EDMFoundationWS/default?wsdl

For example, http://localhost:53000/EDMFoundationWS/default?wsdl.

Page 10: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

6. Choose Finish. 7. In the Service Explorer view, select the new external service and double click to open it.

8. Switch to the Operations tab page and select the function getAllEmployees, for example.

Page 11: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

You can enter a description of the function in the right-hand cell. A list of all input and output parameters is displayed as well.

To save the changes that you have done, choose File → Save all metadata.

Encapsulate the Web Service in an Entity Service ...

To use this external service, you must encapsulate it in an entity service. 1. Select <your project name> → Entity Services, and open its context menu using the secondary

mouse button. 2. Choose New.

Page 12: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

3. Enter a name for the entity service, and choose Finish.

Page 13: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

4. To create the necessary attributes for the entity service, switch to the Attributes tab, open the context menu with the secondary mouse button, and choose Create Attribute.

5. Enter firstName for the name, and First Name for the description of the new attribute, and choose Finish.

6. Repeat the above steps to add the following attributes: Field Name Data Type Description Key pers_no com.sap.caf.core.long Employee number Yes firstName com.sap.caf.core.long

Text First Name

lastName com.sap.caf.core.longText

Last Name

id com.sap.caf.core.shor User Id

Page 14: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

tText

7. Switch to the Operations tab page and choose Add….

8. Enter the following data: Operation name: getUserDetailById Descriptio: Gets all user details by its ID

Page 15: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

9. Switch to the Persistency tab page and disable the option Local Persistency. This is required sp that the operation can be mapped to external services.

10. Switch to the Datasource tab page and select the getUserDetailById operation. In the right-

hand cell, choose (Select) to map the operation to an external service.

Page 16: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

11. Select the getEmployee service and choose OK.

12. Now you can define the parameter mapping by selecting an entity service parameter and

dragging the cursor to select the relevant external operation parameter.

You must map the parameters as follows: Entity Service Parameter External Operation Parameter Input → Id → minValue Input → parameters → getEmployee →

employeeIdOutput → Result → pers_no Output → parameters → getEmployee →

employeeIdOutput → Result → firstName Output → parameters → getEmployee →

firstNameOutput → Result → lastName Output → parameters → getEmployee →

lastName

Page 17: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

Output → Result → id Output → parameters → getEmployee → eMail

13. Switch to the Permissions tab page and disable the option Permission checks enabled.

Save the metadata, build the project and deploy it.

Runtime External Service Configuration ...

1. Open the CAF Runtime Configuration page using the following URL:

http://<host>:<port>/caf

http://localhost:53000/caf

2. Then choose Administrative Tools.

Page 18: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

3. Now choose External Service Configuration.

4. Choose Service Registry on the left. In the service registry you can define and maintain the backend connections for your external services.

Page 19: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

5. Select the external service you have created and choose Open Definition….

6. Select the root node of the external operation (the Web service itself).

7. Under Service Configuration, enter the WSDL description URL as follows, and then choose

Save.

http://<host>:<port>/EDMFoundationWS/default?wsdl

http://localhost:53000/EDMFoundationWS/default?wsdl

Page 20: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

8. Now select the function node of the external operation – getEmployee.

9. Enter the endpoint URL as follows, and then choose Save:

http://<host>:<port>/EDMFoundationWS/default?style=document

http://localhost:53000/EDMFoundationWS/default?style=document

Test the External Service You can test an external services using the entity service you create to encapsulate the external one. Therefore, testing an external service is similar to testing an entity. ...

1. Open the CAF Runtime Configuration page:

http://<host>:<port>/caf

2. Choose Test tools.

Page 21: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

3. Choose Service Browser.

4. Navigate to the getUserDetailById operation.

Page 22: SAP Composite Application Framework€¦ · Composite Application Framework (CAF) capabilities. The tutorial describes how to integrate a Web service as an external service in your

5. Enter a valid user ID (for example, 25) and choose Execute query.

The user details are displayed in a table.