Vous êtes sur la page 1sur 25

Providing Web Services

Part 1
Susanne Rothaug
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Obj ec t i ves
Af t er c ompl et i ng t hi s sessi on, you w i l l be abl e t o:
Use the Web Service Creation Wizard to create a Web service
Manually create and edit a Virtual Interface
This is an overview of the process of Web service creation with the Web Service Creation Wizard
You use already existing functionality (business application)
You generate a Web service with the wizard. The following entities are created automatically: Virtual
Interface, Web Service Definition, Web Service Configuration. (These entities will later be explained in
more detail)
Activate or deploy the Web service. It is now ready to be used.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat i ng a Web Ser vi c e
i n l ess t han ONE mi nut e
1
No Web service specific programming
New or existing applications
Defines standard interfaces
Well known programming models
2
Wizard based approach
Based on preconfi gured profil es
Based on abstract behavi our
Available for ABAP & Java
3
Deployment i n Java
Acti vati on i n ABAP
Activate /
Deploy Web Service
Generate
Web Service
Implement
Business Application
WS Confi guration
WS Definiti on
Virtual Interface
Using the Web Service Creation Wizards is the easiest way of creating a Web service. You dont
have to worry about settings and configuration profiles, because all is done automatically by the
wizard.
You can always edit the created objects afterwards, if you findyou need different settings.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Cr eat i on Wi zar d
- Bac k gr ound -
Out-of-the-box Web services enablement of SAP
solutions
Allows to expose an existing endpoint as a Web
Service with a few mouse-clicks
Only shows the most important settings in the wizard
Default values (profiles) for other settings
Hides technical details
Implicitly creates all necessary objects
This example shows how to use the Web Service Creation Wizard tocreate a Web service based on a
program for checking credit limits. The program is implemented as an EJ B. It will be created and
deployed as a Web service using the Web Service Creation Wizard.
What you see on this screen is the "Web Service Perspective" of the SAP NetWeaver Developer Studio. It
allows you to create and integrate Web services. Here you can perform all the activities necessary for
developing a Web service, as well as start the appropriate editors in the Web Services Toolset. All the
screenshots that you see now are taken in the "Web Services Perspective".
Begin the actual creation of a new Web service by opening the context menu of the "CreditLimitBean
and selecting New -> Web Service.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Cr eat i on Wi zar d - 1 -
EJB
CreditLimitBean
Web
Services
Perspective
This is the start screen of the Web Service Creation Wizard.
Here you specify
the name of your Web service,
the endpoint that it is based on and
the configuration type.
If you make no choice, the default configuration type Simple SOAP is taken.
The following configuration types are available.
Configuration type Simple SOAP:
- Transport Binding: SOAP over http
- Stateless communication
- No Security
Configuration type Basic Auth SOAP:
- Transport Binding: SOAP over http
- Stateless communication
- Authentication: HTTP Basic
- Authorization: yes All EJ B Security roles assigned to all Web service methods
- Transport Guarantee: No
Configuration type Secure SOAP:
- Transport Binding: SOAP over HTTPS
- Stateless communication
- Authentication: Certificates
- Authorization: yes All EJ B Security roles assigned to all Web service methods
- Transport Guarantee: Integrity and Confidentiality
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Cr eat i on Wi zar d - 2 -
On the "Method selection" screen, you can remove methods you do not wish to be part of the Web Service
Interface. In this example, there is only one method available. Thus it does not make much sense to
remove the method from the Web Service interface ;-)
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Cr eat i on Wi zar d - 3 -
On this screen the Virtual Interface (VI) and Web Service Definition (WSD) names are displayed. These
entities are created automatically. You will learn details about the concepts of VI and WSD in a later
chapter.
You need to specify an EAR Project. Make sure that the EAR Project field contains the name of the
corresponding EAR Project, in this case CreditLimitLocalEar. If the project does not exist, as in this
example, it is created automatically.
The last step of the wizard is to choose Finish. The new Web service CreditLimitLocalWebService
was created. The Vi and WSD have been simultaneously created in the background.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Cr eat i on Wi zar d - 4 -
Virtual
Interface
Web Service
Definition
Specify EAR
Project
Now for the last step before deploying the Web service: Buildingthe EAR file. First, open the context
menu of CreditLimitLocalEar. Choose "Build EAR File" from the context menu.
The EAR file has been generated. Choose "OK".
You have reached the final step of Web service creation: deployment. Open the context menu of
CreditLimitLocalEar. Choose "Deploy to J 2EE engine" from the menu.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Cr eat i on Wi zar d - 5 -
Build
AR File
Choose
OK
Choose
Deploy to
J2EE
Engine
Here you can see all the Web services deployed on your local server.
The newly created CreditLimitLocalWebServiceis at the bottom of the list.
Double clicking the Web service name starts the Web Service Homepage and allows you to test the Web
service.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Navi gat or
New Web service
Some more information about the Web Service Navigator
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Navi gat or
is part of SAP NetWeaver Developer Studio
shows deployed Web services from different servers
(SAP and Non SAP)
is the starting point for the Web Service Homepage
can be used as starting point for Web Service Proxy
generation
The following WSDL styles are available:
rpc
document
rpc_enc
They influence the data representation in the body of the SOAP message.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Homepage
is available for each deployed Web Service
shows the documentation for the Web Service
allows to retrieve WSDL descriptions in different styles
allows to generate standalone proxies
offers testing capabilities
can be used to test SAP and NON-SAP Web services
This is what the Web Service Homepage looks like.
The WSDL URL is displayed here.
Choosing the Test button starts the Web service testing.
Clicking on the method name displays the input fields.
Enter the reuireddata and choose Submit
Here the returned value is OK.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
The Web Ser vi c e Homepage: Test a Web Ser vi c e
URL of
WSDL
Choose
Test
Click on
method
name
Enter
idCategory
and idNumber
Response:
OK
Now that you are familiar with the Web Service Creation Wizard, you will learn how to create
the individual parts of a Web service manually.
This step-by-step approach is described in the following chapter.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat i ng a Web Ser vi c e St ep-by-St ep
The Step-by-Step approach
Create all objects by hand
Full flexibility and options
More expenses
but still configuration only
You already learned that the Web Service Creation Wizard automatically creates a Virtual Interface, a
Web Service Definition and a Web Service Configuration.
Now we need to take a closer look at what these entities are andhow they figure in the Web service
concept.
A Virtual Interface (VI) is an abstraction from the implementation layer. It is theview of a Web service
that is visible to the outside world. Several VIscan be defined on top of a single endpoint.
A Web Service Definition (WSD) defines the abstract behaviour of a Web service. VI and WSD are
created by the Web service developer. Several WSDscan be defined for one VI.
A Web Service Configuration (WSC) assigns concrete attributes such as security etc. This isthe task of
the Web service administrator. Various configurations are possible for one WSD.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat i ng a Web Ser vi c e st ep by st ep f or i ndi vi dual needs
1
No Web service specific programming
New or existing applications
Defines standard interfaces
Well known programming models
2
Abstraction from Implemenatation
5
Deployment i n Java
Acti vati on i n ABAP
Activate /
Deploy Web Service
Create
Virtual Interface
Implement
Business Application
WS Confi guration
WS Definiti on
Virtual Interface
Create
Web Service Definition
3
Defines abstract behavi our
Configure
Web Service
4
Indi vi dual Configuration of
Security, Session,
This graphical overview shows you the relationships between the individual Web service entities. Note
that only one concrete Web service exists for each configuration.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Web Ser vi c e Ent i t i es
Business Application
Virtual Interface 1 Virtual Interface 2 Virtual Interface n
WS Definiti on 1 WS Definiti on 2 WS Definiti on m
1:n
1:m
WS Confi guration 1 WS Confi guration 2 WS Confi guration p
1:p
Web Service 1 Web Service 2 Web Service p
1:1
Concrete
Configuration
Web Service
Abstract
Behaviour
Interface
Views
Application
Layer
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Web Ser vi c e Vi r t ual I nt er f ac e Bac k gr ound -
The Vi r t ual I nt er f ac e i s t he
i nt er f ac e vi si bl e t o c l i ent s
(vi a WSDL, UDDI ,)
A Virtual Interface
provides abstraction from concrete implementation (=endpoint)
allows to publish a view on existing implementations as Web Service
Interfaces
i.e. renaming, hiding of parameters/methods, default values
allows to define how the Web Service Interface is represented in the
SOAP message
Note the difference between the implementation layer and the Virtual Interface. In the VI, you can
provide default values for parameters,
rename parameters and methods
hide methods.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Web Ser vi c e Vi r t ual I nt er f ac e Bac k gr ound -
Virtual
Interface
Implementation
Layer
i_credit
segment (I)
i_partner
(I)
e_score
(O)
FSCM_Cr_Limit_Check
e_limit
(O)
e_currency
(O)
e_valid_to
(O)
<SOAP-ENV:Envel ope>
<SOAP-ENV:Body>
<ns1:creditLimitCheck>
<ns1:idNumber>1001</ns1:idNumber>
</ns1:creditLimitCheck>
</SOAP-ENV:Body>
</SOAP-ENV:Envel ope>
<SOAP-ENV:Envel ope>
<SOAP-ENV:Body>
<rpl:creditLi mitCheckResponse>
<rpl:Response>
<tns:score>980</tns:score>
<tns:creditLimit>500000.00</tns:creditLi mit>
<tns:limitCurrency>USD</tns:limitCurrency>
<tns:vali dTo>2005-01-01</tns:validTo>
</rpl:Response>
</rpl:creditLi mitCheckResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envel ope>
idNumber
(I)
score
(O)
credit
Limit (O)
limit
Currency (O)
valid To
(O)
creditLimitCheck
Request
Default Value:
BUP001
Response
Rename
methods
Rename
parameters
Provide default
values/ hide
parameters
Now lets see what the creation of a Virtual Interface in the SAP NetWeaver Developer Studio looks like.
Again, start with opening the context menu of the CreditLimitLocal bean. This time, choose New
Virtual Interface instead of New Web Service (this would start the wizard, as you have seen before).
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat e Vi r t ual I nt er f ac e - 1 -
Choose New
Virtual Interface
On this screen you
select a package and
enter a name of the Vi.
The endpoint that the Web service is based on, the EJ B CreditLimitBean, is already suggested.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat e Vi r t ual I nt er f ac e 2 -
Select a package
Give a name to
the VI
Here you can select the methods to be displayed in the VI. Since"CreditLimitBean" contains only one
method, it does not make much sense to deselect it. ;-)
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat e Vi r t ual I nt er f ac e 3 -
Select or
deselect
methods
The newly created Virtual Interface is now displayed in the EJ B Explorer.
In the editor window to the right the data of method creditLimitCheck is displayed.
Note: The SOAP Extensions entry in the VI editor refers to theoption of editing the SOAP message.
When designing SOAP messages you can edit the following:
method data
parameter data
table data
class data
field data
To specify the format for SOAP messages in the virtual interfaceeditor, do the following:
Choose Window Preferences Java Templates.
Choose SOAP Extensions visible in the virtual interface editor.
More detailed information on SOAP Extensions would be beyond thescope of this training. Please refer to
the online documentation.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Cr eat e Vi r t ual I nt er f ac e 4 -
New VI
Method
creditLimit
Check
Double clicking the method name displays the method data to the right. You can
remove the method. It will then not be displayed in the VI.
change the method name. The name that you enter here appears in the WSDL document.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Vi r t ual I nt er f ac e Edi t Met hod
Remove
method
Change
method name
Double clicking one of the parameters displays the details that you can edit.
You can
change the parameter name,
change the data type and
enter a default value for your parameter. This parameter will then no longer be displayed in the Web
service.
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Vi r t ual I nt er f ac e Edi t Par amet er s
Rename
Type
Rename
Parameter
Provide
Default Value
SAP AG 2004 / Susanne Rothaug / Providing Web Services Part 1
Summar y
Now you shoul d be abl e t o:
Use the Web Service Creation Wizard to create a Web service
Manually create and edit a Virtual Interface

Vous aimerez peut-être aussi