Post on 03-Jun-2018
8/12/2019 04 Consuming Web Services
1/13
Consuming a Web Service
Susanne Rothaug
8/12/2019 04 Consuming Web Services
2/13
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Objectives
After completing this session you will be able to: Generate and deploy a Web service proxy
Create a Web service cl ient appl ication
8/12/2019 04 Consuming Web Services
3/13
Creating a Web service client application consists of 3 major steps:
1) Retrieving the URL of the Web service. To do so, you have the following options:
- Search a UDDI registry. The link to the WSDL file is stored there.
Via URL (from server)
From local Server
From file system
From XI repository
- Look at the Web Service Homepage
2) Generate the Web service proxy.
3) Develop the client application.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Creating a Web Service Client Application
1
From UDDI Via URL (from server)
From local Server
From File System
From XI repository
2
Environment specific
Avai lab le for ABAP & Java
3 Focus on Business Application
SOAP / XML handling hidden by proxy
DevelopClient Application
GenerateWeb Service Proxy
Retrieve WSDL
8/12/2019 04 Consuming Web Services
4/13
First, you need to create the Web service client proxy.
The first step to do so is to create a proxy project. ChooseFile New Project. Click on Web
Services and then choose Deployable Proxy Project. With the deployable proxy all information is
either generated during deployment or is retrieved at runtime. Therefore, deployable proxies are to a
certain degree protected from runtime changes. This also means that different client applications can use
this proxy later on. The other option would be a standalone proxy:, i.e., a Web service client that
generates stubs and runs without the J2EE Engine. This proxy can be used only with the SAP Web AS
release for which it has been generated.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create Web Service ClientProxy - 1 -
Deployable vs.
standalone
proxy
8/12/2019 04 Consuming Web Services
5/13
The new project is now displayed in the Client Explorer. Open the context menu and chooseNew
Client Proxy Definition.
You are asked to specify a package and a proxy name. Choose Local File System or URL as WSDL
source.
Select JAX-RPC Service Interface if you want JAX-RPC interface to be generated, and choose a WSDL
source among Local Server, Local File System or URL, and UDDI or URL to find the WSDL document
on which the WS proxy is to be based.
If you select Local Server, a list of deployed Web services on the J2EE Engine is displayed. Select the one
for which you are creating this proxy and choose Next.
If you select Local File System or URL, you have to specify the WSDL URL or browse the WSDL for the
file system.
If you select UDDI or URL, you have to specify the WSDL URL or search the WSDL in the UDDI
registry. Selecting UDDI opens the Search page of the UDDI client browser and by using its features you
can find the required WSDL. To use the UDDI client, you have to configure the HTTP proxy settings in
the Web Services Container Service of the Visual Administrator.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create Web Service ClientProxy - 2 -
Package and
proxy name
Choose WSDL
source
8/12/2019 04 Consuming Web Services
6/13
Now enter the URL of the WSDL of the Web service you want to create a client for.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create Web Service ClientProxy 3 -
Enter WSDLURL
8/12/2019 04 Consuming Web Services
7/13
In the Client Explorer you can view the files that have been created, such as the Logical Ports, the
Proxy Classes and Service Endpoint Interfaces etc.
Logical ports (LPs) contain the configuration of the client-side SOAP runtime, such as the access URL
or security settings. These are required if Web service calls are executed using proxies. To make
maintaining configuration data as flexible as possible, this data is not included in the Web service client
proxy definition, but can be entered or edited using the LPs created as part of the proxy definition in the
Client Explorer. So in short, when you move the proxy from one system to another (testing to
productive, f.ex.), all you have to do is change the target URL in the LP.
- The LPs provided correspond to the Web service configurations created for the Web service.
- Note: If a WS client was generated on the basis of a tModel, no LP is available. A LP can only be
generated from the WSDL document of the business service.
The Service Endpoint Interface (SEI) exposes the business methods provided by a particular Web
service. It is generated from the WSDL PortType and named after the PortType. The way the methods
are generated depends on the PortType and the JAX-RPC 1.0 conventions.
- For SAP Web Service Clients, an additional option is provided generation of RPC-style SEI for
document/literal-style WSDLs. In this case, for each generated method that has only one wrapper
parameter for the input, and one wrapper parameter for the output, an additional method is generated
that has the same name, but in whose signature the input and output parameters are unwrapped.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create Web Service ClientProxy 4 -
Logical Port
Service
Endpoint
Interface
8/12/2019 04 Consuming Web Services
8/13
Use the Web project that is already available in your Developer Studio. It would be too much effort to
write a whole client application, so we use this Web project. It contains, among a lot of other things, a jsp
the coding of which calls the credit limit check Web service.
Switch to the J2EE Explorer in the J2EE Development Perspective. The following steps need to be
executed:
Create an Ear project for the Web project.
Select the Web project and choose Add Web Service Client API Library. This enables you to use the
client API of the deployable proxy. Otherwise the IDE would not know while building the application
what a Web service proxy is. You have to do this only during design time. During runtime there are
other mechanisms.
Choose the proxy you just created from the list and click OK.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create a client application - 1 -
8/12/2019 04 Consuming Web Services
9/13
The second thing to do is to add the necessary JNDI mappings. They are necessary to find different objects
again that have been deployed to the J2EE engine.
Still in the J2EE Development perspective, expand the CreditLimitPrivateWeb project. In the context
menu of web-j2ee-engine.xml, choose Open. Choose the References tab.
To create new mappings, select jndi mapping and choose Add. Enter the required data:
1) Application local JNDI name this is the name under which the proxy is looked up in the application
- is in this example CreditLimitPrivateProxy.
2) Choose interface as the Server Component type.
3) Server Component JNDI name the name of the JNDI context under which the proxy is bound. The
following convention is used: /wsclients/proxies///.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create a client application - 2 -
8/12/2019 04 Consuming Web Services
10/13
In the Enterprise Application project, double click on application-j2ee-engine.xml. Under the General
tab, selectReferences Add. Choose Select application in the reference target type popup and then
choose the proxy project you just created.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create a client application - 3 -
8/12/2019 04 Consuming Web Services
11/13
Finally, select hard as the reference type.
Make sure that you deploy both the proxy and the client application to the J2EE engine.
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Consuming a Web Service: Create a client application - 4 -
8/12/2019 04 Consuming Web Services
12/13
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
In short
The Enterprise Service Architecture (ESA), SAPs
approach for building services-oriented business
applications utilizes Web Services as vital part of itscommunication and integration strategy
SAPs rich business functionality, in conjunction with
state-of-the-art technology, enables you to establish
cross-company business processes as an integrated
part of your development efforts based on Web
Services
SAP Web Application Server 6.40 offers an easy,convenient way to build Web services
8/12/2019 04 Consuming Web Services
13/13
SAP AG2004 / Susanne Rothaug / Consuming a Web Service
Summary
Now you should be able to: Generate and deploy a Web service proxy
Create a Web service cl ient appl ication