Develop Simple Web application using NWDS and XI

17
How-to Guide SAP NetWeaver ‘04 How To Develop a Simple Web Service Application Using SAP NetWeaver Developer Studio & SAP XI 3.0 Version 1.00 – Nov 2005 Applicable Releases: SAP NetWeaver ’04 SPS 13 and above

description

Develop Simple Web application using NWDS and XI

Transcript of Develop Simple Web application using NWDS and XI

How-to Guide SAP NetWeaver ‘04

How To Develop a Simple Web Service Application Using SAP NetWeaver Developer Studio & SAP XI 3.0 Version 1.00 – Nov 2005 Applicable Releases: SAP NetWeaver ’04 SPS 13 and above

© 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. These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. SAP NetWeaver “How-to” Guides are intended to simplify the product implementation. While specific product features and procedures typically are explained in a practical business context, it is not implied that those features and procedures are the only approach in solving a specific business problem using SAP NetWeaver. Should you wish to receive additional information, clarification or support, please refer to SAP Consulting.

Table of Contents 1 Scenario ...............................................................................................................1 2 Introduction...........................................................................................................1 3 The Step-By-Step Solution...................................................................................2

3.1 Generate a WSDL File in XI 3.0 from an Existing Interface Defined in the Integration Repository ..............................................................................................2 3.2 Import the Generated WSDL File into SAP NWDS and Create a Web Service Model...........................................................................................................3 3.3 Design a Simple Java Web Dynpro Application Based on the Web Service Model .....................................................................................................................5

4 Summary: ...........................................................................................................11 Appendix: Message Monitoring..................................................................................12

- 1 -

1 Scenario You develop a Java Web Dynpro client application by using SAP NetWeaver Developer Studio (NWDS), importing the Web service interface defined in SAP Exchange Infrastructure (XI) 3.0, and deploying it on a J2EE Engine.

2 Introduction In XI 3.0, any outbound interface can be exposed as a Web service interface. A Web service description (WSDL file) can be generated for this interface in the Integration Directory and you can develop a Web service application (J2EE or .Net) based on the data types defined in the WSDL file. In XI 3.0, you can also call a Web service application by using the SOAP adapter and simply import the receiver application WSDL interface as an external definition. Based on this external definition, you define the necessary inbound interfaces and mapping objects in the Integration Repository in addition to the corresponding configuration objects in the Integration Directory. The business scenario example and process flow are described graphically below.

A Web application sender sends purchase order data synchronously to XI 3.0 using the SOAP adapter as the communication channel. The message is then sent to an SAP R/3 application by using the RFC adapter, and a BAPI call is executed to create a purchase order (PO). After the PO is created, the PO number is sent back to the sender in the BAPI response message. This guide covers the following:

• How to generate a WSDL file in XI 3.0 from an existing interface • How to import the generated WSDL file into SAP NWDS and create a Web

service model • How to design a simple Java Web Dynpro application based on the Web service

model It does not cover topics such as designing objects (for example, interfaces or mapping objects) in the Integration Repository or creating configuration objects in the Integration Directory. The prerequisites required for this scenario are:

1. Knowledge of XI 3.0, SOAP Web services, Java Web Dynpro, BAPI/RFC, and so on.

PO Data Resp. Z_BAPI_PO_RESP

SAP

R/3 4.6C

Java

Web Dynpro Application

SAPWAS640

SOAP

RFC XI30

Z_BAPI_PO_CREATE PO Data Req.

- 2 -

2. The necessary system infrastructure (the XI 3.0 system and the SAP R/3 system must be installed and configured to reflect the above example scenario).

3. SAP NWDS is used to develop the Purchase Order Web Dynpro application.

3 The Step-By-Step Solution 1. Generate a WSDL file in XI 3.0 from an existing interface. 2. Import the generated WSDL file into SAP NWDS and create a Web service

model. 3. Design a simple Java Web Dynpro application based on the Web service model.

3.1 Generate a WSDL File in XI 3.0 from an Existing Interface Defined in the Integration Repository

You have to create and activate all the necessary design and configuration objects in XI 3.0 before you generate the WSDL file below.

1. From the XI 3.0 Integration Builder start page, log on to the Integration Directory.

Choose Tools Define Web Service. The Web service wizard starts.

Choose Continue.

2. Specify the URL of the Web service as follows:

http://<HostName>:<Port#>/XISOAPAdapter/MessageServlet?Version=3.0&Channel=:XR5_100:PI_SOAPSender Choose Continue.

- 3 -

3. Specify the outbound interface defined in the Integration Repository by using the input help. The namespace and software component version are entered automatically according to your selection.

Choose Continue.

4. Specify the sender service, interface name, and interface namespace.

Choose Continue, check the Overview of the details entered in the previous steps, and choose Finish.

5. You can see the generated WSDL file and save it to your local file system by choosing Save. Once you have done this, close the wizard.

3.2 Import the Generated WSDL File into SAP NWDS and Create a Web Service Model

1. Open SAP NWDS and create a Web Dynpro project, such as POWebSer, for example.

Expand the Web Dynpro node and click Models with the secondary mouse button.

A wizard starts to import the corresponding Web service model.

- 4 -

2. Select Import Web Service Model and choose Next.

3. Enter values for the following parameters, for example: • Model Name: WSPO • Model Package:

com.sap.xi.wspo.model Select Local File System or URL for the WSDL source file and choose Next.

4. Browse to the location of the WSDL

file saved above and choose Next.

5. Choose Finish to generate the Web service model.

- 5 -

6. When the model is generated, you can browse through the logical ports, the model classes, and so on.

Under Logical Ports, check the value of the Target Address parameter under the model port name, for example:

http://<Host Name>: <Port#>/XISOAPAdapter/MessageServlet?Version=3.0&Channel=:<BS Name>:<Communication Channel Name>

3.3 Design a Simple Java Web Dynpro Application Based on the Web Service Model

1. Expand the Web Dynpro node and click Applications with the secondary mouse button. A wizard starts to create a Web Dynpro application.

2. Enter the name of the application and the package, for example: • Name: POWSApp • Package: com.sap.xi.wspo

Choose Next.

- 6 -

3. Select Create a New Component and choose Next.

4. Change the default names as

follows:

• Component Name: POWSComponent

• Window Name: POWSWindow • View Name: POWSView

Choose Finish to generate the Web Dynpro application.

5. When the Web Dynpro application

has been created, you can browse through the various Web Dynpro components.

- 7 -

6. Choose POWSComponent. On the right side of the editor, scroll down to Used Models. Click it with the secondary mouse button and choose Add Existing Model. Select the model you have imported above (for example, WSPO) and choose OK.

7. Click Custom Controller with the

secondary mouse button and choose Apply Template.

Select the service controller and choose Next.

8. Select the model class for the model binding and enter the following value:

Custom Controller: POWSModelController

Choose Next.

- 8 -

9. Select the context elements you want to bind by expanding the relevant nodes and selecting each checkbox.

Choose Next.

10. Enter the name of the method and

choose Finish to generate the method.

11. In the left toolbar, choose Create

Data Link and drag your mouse to join the POWSView and POWSModelController blocks. The Edit Context Mapping wizard starts.

- 9 -

12. Drag the context folder Request_PurchaseOrderOut_purchaseOrderOut from the right side of the editor to the left side of the editor. Another wizard is started.

Expand the Context nodes and select the fields for context mapping.

Choose OK.

13. The final context mapping is

complete. Choose Finish.

- 10 -

14. Create the necessary user interface elements for both the request and the response messages, and create the action methods to create a purchase order. For more information, see the documentation available in SAP NWDS.

15. Deploy and run the application.

• In the Web Dynpro Explorer, choose POWebSer Web Dynpro Applications.

• Click POWSApp with the secondary mouse button and choose Deploy New Archive and Run.

Note: You can deploy the Web Dynpro application on your local J2EE Engine or on a remote J2EE Engine.

16. To check the details on your SAP NWDS, in the menu, choose Window Preferences and select SAP J2EE Engine.

- 11 -

17. Once the Web Dynpro application is successfully deployed on the J2EE Engine, the start page of the application opens automatically and you can enter the input data for the application to create a purchase order.

Use transaction SXMB_MONI to check the messages in XI 3.0 as outlined in the Appendix below.

4 Summary: This guide explains the steps required to use an XI-defined interface as a Web service, and how to build a Java Web Dynpro application by importing the WSDL file into a model and generating the classes required for the Web service to communicate with XI. SAP NWDS was used to build the client application. In the example scenario, an SAP R/3 system is used to execute the BAPI to create a PO using the RFC adapter of XI. The main purpose of this guide is to outline how you can use and leverage an XI interface by exposing it as a Web service for any client application. The prerequisites mentioned at the beginning of the guide must be met for this example scenario to work successfully. References: SAP Help: Exchange Infrastructure SAP Help: NetWeaver Developer Studio

- 12 -

Appendix: Message Monitoring Log on to your Integration Server and check the messages by using transaction SXMB_MONI. You must have two messages: a request message, and a response message with a PO number that is sent back to the sender application.

Message 1: Payload Data Details for the PO Request Message

- 13 -

Message 2: Payload Data Details for the PO Response Message

Display the PO in the R/3 system by calling transaction ME23.

www.sdn.sap.com/irj/sdn/howtoguides