How-to Guide
SAP NetWeaver ‘04
How to Develop a
Simple Web Service
Application Using
SAP NetWeaver
Developer Studio
and SAP NetWeaver
Exchange
Infrastructure 3.0
Version 1.00 – Nov 2005
Prasad Illapani
SAPNetWeaver RIG - XI
SAP Labs LLC, USA
Applicable Releases:
SAP NetWeaver ’04
XI 3.0 SP13 and above
© Copyright 2006 SAP AG. All rights reserved. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP
NetWeaver, and other SAP products and services
No part of this publication may be reproduced or mentioned herein as well as their respective logos
transmitted in any form or for any purpose without are trademarks or registered trademarks of SAP AG
the express permission of SAP AG. The information in Germany and in several other countries all over
contained herein may be changed without prior the world. All other product and service names
notice. mentioned are the trademarks of their respective
companies. Data contained in this document serves
Some software products marketed by SAP AG and informational purposes only. National product
its distributors contain proprietary software specifications may vary.
components of other software vendors.
These materials are subject to change without
Microsoft, Windows, Outlook, and PowerPoint are notice. These materials are provided by SAP AG and
registered trademarks of Microsoft Corporation. its affiliated companies ("SAP Group") for
informational purposes only, without representation
IBM, DB2, DB2 Universal Database, OS/2, Parallel or warranty of any kind, and SAP Group shall not be
Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, liable for errors or omissions with respect to the
OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, materials. The only warranties for SAP
AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Group products and services are those that are set
and Informix are trademarks or registered forth in the express warranty statements
trademarks of IBM Corporation in the United States accompanying such products and services, if any.
and/or other countries. Nothing herein should be construed as constituting
an additional warranty.
Oracle is a registered trademark of Oracle
Corporation. These materials are provided “as is” without a
warranty of any kind, either express or implied,
UNIX, X/Open, OSF/1, and Motif are registered including but not limited to, the implied warranties of
trademarks of the Open Group. merchantability, fitness for a particular purpose, or
non-infringement.
Citrix, ICA, Program Neighborhood, MetaFrame, SAP shall not be liable for damages of any kind
WinFrame, VideoFrame, and MultiWin are including without limitation direct, special, indirect, or
trademarks or registered trademarks of Citrix consequential damages that may result from the use
Systems, Inc. of these materials.
SAP does not warrant the accuracy or completeness
HTML, XML, XHTML and W3C are trademarks or of the information, text, graphics, links or other items
registered trademarks of W3C®, World Wide Web contained within these materials. SAP has no control
Consortium, Massachusetts Institute of Technology. over the information that you may access through the
use of hot links contained in these materials and
Java is a registered trademark of Sun Microsystems, does not endorse your use of third party web pages
Inc. nor provide any warranty whatsoever relating to third
party web pages.
JavaScript is a registered trademark of Sun SAP NetWeaver “How-to” Guides are intended to
Microsystems, Inc., used under license for simplify the product implementation. While specific
technology invented and implemented by Netscape. product features and procedures typically are
explained in a practical business context, it is not
MaxDB is a trademark of MySQL AB, Sweden. 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
4 Summary ..................................................................................................................11
5 References ...............................................................................................................11
6 Appendix: Message Monitoring.............................................................................12
1 Scenario
To develop a Java Web Dynpro Client application using SAP NetWeaver Developer
Studio (NWDS) by importing the web service interface defined in SAP NetWeaver
Exchange Infrastructure (SAP NetWeaver XI) 3.0, then deploy it on the SAP J2EE
Engine.
2 Introduction
In XI 3.0, any the Outbound Interface can be exposed as a Web Service Interface. A
WSDL can be generated for this Interface in the Integration Directory Component of XI
3.0, and you can develop a Web service application (J2EE or .NET) based upon the data
types defined inside the WSDL file. You can also call a web service application from XI
3.0 via the SOAP Adapter by simply importing the Receiver Application WSDL interface
as an External Definition. Based upon this external definition, you define the necessary
Inbound Interfaces and Mapping Objects with in the Integration Repository Object and
the corresponding Configuration Objects.
The Business Scenario example and process flow is described graphically below.
Z_BAPI_PO_CREATE PO Data Req
SAP Java
R/3 4.6C RFC SOAP Web Dynpro
XI 3.0
Application
Z_BAPI_PO_RESP PO Data Resp SAP WAS 6.40
Purchase order data is sent through a web application sender synchronously to XI 3.0
using the SOAP Adapter as the communication channel. The message is then sent to an
SAP R/3 Application via the RFC Adapter, and a BAPI call is executed to create a
purchase order. After the PO is created the PO number is sent back to the Sender in the
BAPI Response message type.
This guide covers the following areas.
1. How to generate a WSDL file in XI 3.0 from an existing Interface
2. How to import the generated WSDL file into SAP NWDS ( Net Weaver Developer
Studio) and create a Web Service Model.
3. Design a simple Java Web Dynpro Application based on the Web Service Model.
-1-
It does not cover topics in XI 3.0 such as design objects (Interfaces, Mapping Objects
etc.) and Integration Directory configuration objects.
2.1 Prerequisites
The prerequisites required to build this scenario are as follows:
1. Knowledge of XI 3.0, SOAP web services, Web Dynpro Java, BAPI/RFC, etc.
2. The necessary system infrastructure: The XI 3.0 system and SAP R/3 system
must be installed and configured in order to build the above example scenario.
3. SAP NWDS is used to develop the Purchase Order Web Dynpro application.
3 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 Web Dynpro Java 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 Component.
Note: All the necessary design and configuration objects must be created and activated in
XI 3.0 (SLD, Int. Rep. Objects, Int. Dir. Objects, etc.) before you generate the WSDL file
below.
1. From the XI 3.0 Integration Builder
Page, log in to Integration Directory
Component . From the Menu go to
ToolsÆ Define Web Service. The Web
Service Wizard opens and click on the
Continue button at the bottom of the
Wizard. In step 2, specify the URL of
the Web Service. In this case we
provide the URL as follows:
http://<HostName>:<Port#>/XISOAPA
dapter/MessageServlet?Version=3.0&
Channel=:XR5_100:PI_SOAPSender
Click the Continue button at the
bottom.
-2-
2. In Step 3 specify the Outbound
Interface defined in the Integration
Repository using the Value help Button
on the right side. The Namespace and
Software Component Version are
entered automatically based upon your
selection.
Click the Continue Button at the
bottom.
3. In the next step specify the Sender
Service, Interface Name and
Namespace.
Click the Continue Button to check the
Overview of the details entered in the
previous steps and finally click on the
Finish Button .
4. You can see the WSDL file
generated and save the file to your
local drive C:/ by clicking the Save
Button at the bottom of the
Wizard. After Saving the file c lose the
Wizard.
3.2 Importing the generated WSDL file in step 3.1 into SAP NWDS and
create a Web Service Model.
-3-
1. Open the NWDS and create a Web
Dynpro Project. For Ex: POWS. Expand
the Web Dynpro Node and Right click on
Models. A Wizard is opened to import
the corresponding web service model.
2. Select the Radio Button Import
Web Service Model. Click the Next
button at the bottom.
3. Enter the following parameters. For
Ex:
Model Name = WSPO
Model Package =
com.sap.xi.wspo.model
Select the Local File System Radio
button for the WSDL Source file
Click the Next button at the bottom.
4. Browse to the location of the
WSDFL file saved in Step2.1
Click the Next button at the bottom.
5. Click the Finish Button at the bottom
to generate the Web Service Model
-4-
6. After the Model is generated you
can browse through the Model
Classes and the Logical Ports etc.
Under the node: Logical Port, check
the Target Address Parameter value
under the Model Port Name. For ex:
http://<Host Name>:
<Port#>/XISOAPAdapter/MessageSer
vlet?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
Right click on Applications. A Wizard is
opened to create a Web Dynpro App.
-5-
2. Enter the Name of the application and
the Package. For Ex:
Name = POWSApp
Package = com.sap.xi.wspo
Click the Next button at the bottom
3. Select Create a New Component
Radio button .
Click the Next button at the bottom.
5. Change the names of the
following default values to:
Component Name =
POWSComponent
Window Name = POWSWindow
View Name = POWSView
Click the Finish Button at the bottom to
generate the Web Dynpro Application .
-6-
6. After the Web Dynpro Application
has been created, you can browse
through the different Web Dynpro
Components.
7. Open the Component:
WSPOComponent by double
clicking on it.
On The RHS of the editor, Scroll
Down to the Used Models Area.
Right click on it and
Choose Add Existing Model. Select
your model you have imported in
Step 2.2. In this Model is WSPO.
Click OK button at the bottom.
-7-
8. Right Click in the Custom
Controller area, and choose Apply
Template. Select the Service
Controller.
Click the next button
9. Select the Model class for the
Model Binding. Enter the value for:
Custom Controller =
POWSModelController
Click the next button to continue
10. Select the Context Elements you
want to bind. Expand the Nodes and
click on each box.
Click the next button to continue
11. Enter the name of the method
and Click on the Finish button at the
-8-
bottom to generate the method.
12. In the left toolbar, choose Create
Data Link. Drag your mouse and join
the POWSView and
POWSModelController blocks. Edit
Context Mapping wizard is opened .
13. Drag the Context folder:
Request_PurchaseOrderOut_purcha
seOrderOut on the right hand side of
the editor and place the folder to the
left side of the editor. An Another
wizard window appears.
Expand the context nodes and select
the fields for context mapping.
Click Ok at the bottom of the Wizard.
14. The final Context Mapping is
complete. Click he Finish button .
-9-
15. Create the necessary User
Interface elements for both the
Request and Response Messages
and the Action Methods to Create a
Purchase Order. For more
information on this check the Help
documentation in SAP Netweaver
Developer Studio
16. Deploy and Run the
Application.
1. In Web Dynpro Explorer expand project
to POWebSer -> Web Dynpro ->
Applications
2. Right-click on POWSApp and choose
Deploy New Archive and Run.
Note: You can deploy the Web Dynpro
Application on your Local J2ee engine or on a
Remote Host J2ee Engine.
To check the details on your SAP NWDS, From
the Menu go to: Window-Æ Preferences and
select SAP J2EE Engine
17. Once the Web Dynpro Application is
successfully deployed on the J2ee engine, The
start page of the application is automatically
- 10 -
opened and you are ready to enter the input data
for the application to create a Purchase Order in
this case.
Check the messages in XI 3.0 using Tr:
SXMB_MONI as shown in the Appendix below.
4 Summary
This guide explains how to use an XI-defined Interface as a web service and build a Web
Dynpro Java application by importing the WSDL file into a Model and generating the
corresponding classes required for the Web Service to communicate with XI. SAP
NetWeaver Developer Studio was used to build the client application. In the example
scenario, SAP R/3 system is also used for executing the BAPI to create a PO using the
RFC Adapter of XI.
The main purpose of this guide is to show how you can use and leverage an XI interface,
expose it as a web service for any client application. The pre requisites mentioned at the
beginning of the guide have to be followed carefully in order for this example scenario to
work successfully.
5 References
- 11 -
1. SAP Help: Exchange Infrastructure
2. SAP Help: Net Weaver Developer Studio
6 Appendix: Message Monitoring
1. Log in to the Integration Server and check the messages in Tr: SXMB_MONI. You
must have 2 messages, one for the request and the other for the response message with a
PO Number coming back to the Sender Application.
Message 1: Payload data details for the PO Request Message
Message 2: Payload Data details for the PO Response Message
- 12 -
Display PO in the R/3 System: Tr: ME23
- 13 -
www.sap.com/netweaver