a Web Service in ABAP*
* *It is impossible to implement all of the necessary
functions associated with a complex business problem in the same component or
even technology. A modern enterprise infrastructure system must be in the
position to integrate functions in one
effective process. Until now, the combination of different applications have
been developed using point-to-point solutions which grow complex and impossible
to maintain over time.
Web Services simplify the heterogeneous nature of
most mature enterprise system landscapes. They enable you to combine functions
in a single process, even if they are implemented in widely differing software
components. Web services are standalone, executable entities that can be
published, searched for, and called, across a network.
To consume a web service via the ABAP engine, you need to do the following:
a Logical Port
The creation of a proxy for the Web service in the
ABAP Workbench using a WSDL document can be done in a few clicks. Once the
proxy has been created a logical portal will be needed. Once those two tasks
are completed, the Web Service can be called via a standard API.
This demonstration was built for some much needed ABAP practice and because I never really found a WORKING example. Enjoy..
that SAP only supports WSDL 1.1 ( at least from what I can tell )+
*Create Client Proxy
You can generate client or server proxies in ABAP
to send or receive messages. You generate client proxies in this example. The
client proxy will provide an abstraction to the complexities of the web
Click on *EDIT
Enter the name of the Client Proxy (ZCG_CO_WEATHER_WS) and click the CREATE button.
Destination+ and press the Continue button.
Enter the +WSDL
+in the URL field and press the *Continue *button
For simplicity select Local Object and enter a value in the Prefix field. Press the *Continue
Press the Complete
Remember to *SAVE
*and then *ACTIVATE *you code.
*Create Logical Port
You configure runtime features for Web services
client proxies using logical ports.
These runtime features can be configured when the
Web-service client is activated. An example of such a feature is the URL-call
of the Web service, which, if applicable, must be modified by users.
Enter the Proxy class and Logical Port
name. Make sure that DefaultPort
is selected. Click the Create button
Enter a description for the logical port.
Enter the WSDL URL into the URL fieldCopy the URL defined in that line into the SOAP Action line.
Save and then Activate the Logical Port
*Test the Web Service
To test the web service call load the client proxy in SE80
Click on the TEST
Click on the *Execute
Since the web service simply converts a string to
all upper case, you can now click on the *EXECUTE
+Note: +You can
also now change the default value being sent to the web service
As you can see you can even upload an entire file
If the test is successful you will see your
returned string in all Upper Case
*Call the Web Service
within an ABAP Function*
*” VALUE(INPUT_PARAMETER) TYPE STRING
*” VALUE(OUTPUT_PARAMETER) TYPE STRING
DATA: WSProxy TYPE REF TO ZCG_CO_WS_STRINGS_SOAP .
CREATE OBJECT WSProxy .
CATCH CX_AI_SYSTEM_FAULT .
data: ls_response type ZCG_MAKE_UPPER_SOAP_OUT .
data: ls_request type ZCG_MAKE_UPPER_SOAP_IN .
ls_request-DATA = INPUT_Parameter .
CALL METHOD WSProxy->MAKE_UPPER
INPUT = ls_request
OUTPUT = ls_response .
CATCH CX_AI_SYSTEM_FAULT .
CATCH CX_AI_APPLICATION_FAULT .
OUTPUT_Parameter = ls_response-MAKE_UPPER_RESULT .
For more information, please visit NetweaverCentral </p>