HTTP Clients, JSON and XML Transformations
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Almost every business system has to talk to other systems: a payment service that must be told that an expense claim was approved, a tax service that returns a rate, a partner that sends orders as a file. Most of that talk today travels over HTTP, the protocol of the web, and carries its data as JSON or XML, two plain-text formats for structured data. ABAP programs keep their data in structures and internal tables, so two jobs come up again and again: send a request and read the answer (an HTTP client), and convert ABAP data to JSON or XML and back (a transformation). This page explains both, plus the older SOAP web services that many SAP systems still use. It is written against Standard ABAP release 8.16 and ABAP for Cloud Development release 9.20 (2608). The communication target and communication arrangement approach applies to ABAP Cloud (the SAP BTP ABAP environment, SAP S/4HANA Cloud Public Edition and new development on premise); the classic client class and SM59 destinations belong to Standard ABAP on premise and in SAP S/4HANA Cloud Private Edition. After reading you can choose a way to reach a remote service, send a JSON request, turn a structure into JSON and read a JSON answer into a structure.
Before you read
-
Language Versions and Released APIs: why some classes are allowed in ABAP Cloud and others are not.
-
Classes and Objects: the examples are methods of classes and call methods of other objects.
-
Exceptions: every remote call can fail and raises class-based exceptions.
-
Internal Tables: JSON arrays become internal tables.
-
Database Tables and Structures: the running example table
ZEXP_CLAIM.
Key terms
-
HTTP client: the object that sends an HTTP request to another system and returns its response.
-
Communication scenario: a development object that lists the outbound and inbound services a piece of integration uses.
-
Communication arrangement: the runtime setup, made by an administrator, that links a scenario to a communication system with its address and credentials.
-
Communication target: a development object that generates a class your code uses to get the right destination for an outbound call.
-
Application destination: the destination the system creates from a communication target when an arrangement is saved.
-
JSON: a text format for data made of objects in curly brackets, arrays in square brackets, strings, numbers and truth values.
-
Serialization: turning ABAP data into a text format such as JSON or XML; reading it back is deserialization.
-
Identity transformation: the predefined transformation
IDthat converts ABAP data to XML or JSON and back without any rules written by you. -
asJSON: the fixed JSON layout that the identity transformation produces and expects.
-
Simple transformation: a small declarative program that you write to map ABAP data to XML or JSON and back.
-
XSLT: the W3C language for turning one XML document into another, which ABAP can run as an XSL transformation.
-
XCO library: a released class library of SAP, including a module for JSON.
-
SOAP: an older web service protocol that wraps XML messages in an envelope and is described by a WSDL file.
-
Consumer proxy: a generated class that hides the SOAP message so that calling a web service looks like calling a method.
How an outbound call is put together
A call to another system needs three things that change from system to system: the address, the way to prove who you are, and the data. Hard-coding the first two into the program would break every time the program moves from a test system to the productive one. ABAP Cloud therefore splits the job. The developer writes the code and names a kind of connection. An administrator, in the Communication Management apps of the SAP Fiori launchpad, supplies the address and credentials at runtime. The official documentation names the pieces like this: a communication target (development object, generates a class), an outbound service (of type communication target) that references it, a communication scenario that contains the outbound service, and a communication arrangement (runtime setup) that the administrator creates for the scenario and a communication system. When the arrangement is saved, the system creates an application destination, and your code reaches it through the generated class.
The names in the figure (ZCT_EXP_PAYMENT, ZEXP_PAYMENT) are examples for the running expense claim scenario. The
documentation advises prefix CT_ for a communication target so that its generated class does not clash with an ordinary
CL_ class, and requires fixed name endings for outbound services: _COTA for the communication target type, _REST for
HTTP, _SPRX for SOAP and _SRFC for RFC.
Calling an HTTP service with a communication target
The documentation calls the communication target the recommended approach for HTTP and RFC outbound communication of newly created applications. The steps are: create the communication target (type HTTP) and activate it, which generates a class of the same name; create an outbound service of type communication target that references it; add that service to a communication scenario and publish the scenario; then the administrator creates a communication system and a communication arrangement for it in the Communication Systems and Communication Arrangements apps.
Source: Creating an Outbound Service for HTTP, Creating a Communication Scenario for Outbound HTTP and Creating a Communication Arrangement for Outbound HTTP
The code then has three lines of substance: create the communication target object, ask it for an HTTP client, execute a
method. The next listing sends the approved claim to the payment service as JSON. It uses fields of the running example table
ZEXP_CLAIM. The payload is written by hand here; the sections after this one show how to produce it from a structure. The
listing requires an SAP system, a communication scenario and an arrangement; not run here.
CLASS zcl_exp_send_claim DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS zcl_exp_send_claim IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA(payload) = |\{"claimId":"C-0001","status":"A","totalAmount":250,"currency":"EUR"\}|.
TRY.
DATA(cota) = NEW zct_exp_payment( ).
DATA(client) = cota->create_web_http_client( ).
DATA(request) = client->get_http_request( ).
request->set_header_fields( VALUE #( ( name = if_web_http_header=>content_type value = 'application/json' )
( name = 'Accept' value = 'application/json' ) ) ).
request->set_text( payload ).
DATA(response) = client->execute( if_web_http_client=>post ).
DATA(status) = response->get_status( ).
IF status-code <> 200.
out->write( |The service answered { status-code } { status-reason }.| ).
ELSE.
out->write( response->get_text( ) ).
ENDIF.
client->close( ).
CATCH cx_communication_target_error cx_web_http_client_error INTO DATA(error).
out->write( error->get_text( ) ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
Source: ABAP Integration and Connectivity: Calling the HTTP Service (communication target, create_web_http_client, execute, close, the two exception classes), HTTP Communication via Destination Service (header fields, get_status, get_text) and ABAP Cheat Sheet: Released ABAP Classes (a POST with set_text)
Reading it: nothing in the code says where the service lives or how to log on; the administrator’s arrangement does. A
communication target can have one or several application destinations. If a scenario is used for several communication
systems (for example one payment provider per country), you pass the name of the wanted destination when you create the
target object, as in NEW zct_exp_payment( application_destination = 'APPLDESTNAME' ); the documentation suggests keeping
those names in a customizing table. The status code is always worth checking, because a remote service that refuses a request
still answers, and no exception is raised for it. The methods of the client are the same whether the destination came from a
communication target or from one of the older approaches below.
If the remote service protects itself against cross-site request forgery, the caller must first ask for a token by sending
the header X-CSRF-Token with the value fetch, and then send the token it received in the same header of every further
request of the session. The documentation describes this from the provider side, for an ABAP HTTP service that calls
HANDLE_CSRF of the class CL_HTTP_SERVICE_UTILITY; a call without the token is rejected.
Other ways to get a destination
The client is always created from a destination object, and the destination can come from several places. The documentation lists the communication target first and the rest as other approaches.
| Approach | What it does | When the documentation says to use it |
|---|---|---|
Communication target and application destination |
The generated class gives you the client. No credentials in code. |
Recommended for new HTTP and RFC calls. |
Communication arrangement directly |
|
Older approach. It cannot be used for scenarios delivered by SAP. |
Plain URL |
|
Only for public services and tests, because credentials belong in the destination service or in arrangements. |
SAP Destination service |
|
Static use in code is not recommended. The destination service is advised for principal propagation through the Cloud Connector; for other authentication, local configuration in the communication management apps. Only in SAP BTP. |
SM59 destination |
A wrapper class outside ABAP for Cloud Development uses |
To keep using an existing SM59 destination from ABAP Cloud code. |
The arrangement-based call, as the documentation shows it, creates the destination and then the client with the class
CL_WEB_HTTP_CLIENT_MANAGER. It requires an SAP system; not run here.
TRY.
DATA(destination) = cl_http_destination_provider=>create_by_comm_arrangement(
comm_scenario = 'ZEXP_PAYMENT'
service_id = 'ZEXP_PAYMENT_REST' ).
DATA(client) = cl_web_http_client_manager=>create_by_http_destination( destination ).
DATA(response) = client->execute( if_web_http_client=>get ).
client->close( ).
CATCH cx_http_dest_provider_error cx_web_http_client_error INTO DATA(error).
" handle the error
ENDTRY.
Source: HTTP Communication via Communication Arrangements, Service Consumption via Communication Arrangements and Other Approaches for HTTP Outbound Communication
Further pages of the same chapter cover optional client features: multipart requests, a path prefix, repeating a request, the redirect behavior and server-sent events.
The classic client in Standard ABAP
Older code, and code in a book from before 2018, does not use communication targets. It builds an object of the class
CL_HTTP_CLIENT in one of two ways: cl_http_client=>create with host, port and optional proxy, or
cl_http_client=>create_by_destination with the name of an SM59 destination, the way to a destination that SAP
recommends because it keeps connection details out of the program. Then it sets the request, sends it, receives the answer
and closes the connection, and after each step it asks the client for the last error, because these methods report failure
through sy-subrc and not through exceptions. The listing is the shape of the SAP example, shortened. It requires an SAP
system; not run here. The page is from the older client-side development documentation; a newer page shows a call through a
communication target in Standard ABAP with the same client methods as the cloud listing above.
DATA client TYPE REF TO if_http_client.
cl_http_client=>create_by_destination(
EXPORTING destination = 'ZEXP_PAYMENT'
IMPORTING client = client
EXCEPTIONS OTHERS = 1 ).
IF sy-subrc <> 0.
RETURN.
ENDIF.
client->send( EXCEPTIONS OTHERS = 1 ).
IF sy-subrc = 0.
client->receive( EXCEPTIONS OTHERS = 1 ).
ENDIF.
IF sy-subrc <> 0.
client->get_last_error( IMPORTING code = DATA(code) message = DATA(text) ).
ENDIF.
client->close( EXCEPTIONS OTHERS = 1 ).
Source: Example program: Executing an HTTP Request (older page), Calling an HTTP Service via Communication Targets (Standard ABAP)
In on-premise systems and in SAP S/4HANA Cloud Private Edition, the application destination of a communication target is created in the transactions APPLDEST, APPLDESTCS or APPLDESTCC.
JSON and XML in ABAP
A JSON text is built from a few pieces: objects { } of named members, arrays [ ], strings in double quotes, numbers, the
words true and false, and null. XML nests named elements in tags. ABAP can handle both in three ways, and the choice
of the way is the main decision of this page.
The three ways in the language itself are the identity transformation ID, written transformations (simple
transformations and XSLT) and the readers and writers of the sXML library. The Keyword Documentation says the readers and
writers parse and render general XML data, while transformations mostly serialize ABAP data to JSON and read JSON into ABAP.
The two meet: a reader or writer can be the source or target of a transformation. For JSON they all rest on one idea, the
JSON-XML format, an SAP-specific way of showing JSON as XML (<str> for a string, <num> for a number, <bool>, <null/>,
<array> and <object>), so that the same machinery serves both formats.
CALL TRANSFORMATION and the identity transformation
CALL TRANSFORMATION runs a transformation. The form that needs nothing written is the identity transformation ID: the
SOURCE is either ABAP data given as name-value pairs or an XML or JSON text, and the RESULT is the other side. When the
source is ABAP data, it is serialized to the fixed XML layout asXML or, when the target is JSON, to asJSON; when the source is
asXML or asJSON, the data is deserialized into the ABAP data objects named after RESULT. The documentation lets a JSON
writer of the sXML library stand as the target, and also lists a RESULT JSON and SOURCE JSON form with a string, a byte
string or a JSON reader or writer object.
The layout of asJSON follows a few rules, and one of them causes the most surprises:
-
The top level is an object whose members are the names given after
SOURCEorRESULT, written in upper case when they are given statically. -
A structure becomes an object whose members have the component names, in the order of the components.
-
An internal table becomes an array, and no information about the table category is passed.
-
Numbers (
i,p,decfloat16,decfloat34,f) become JSON numbers; text, number text, dates, times and byte types become strings. -
When reading, the case of the names must match exactly. A JSON member that has no matching component is ignored, and a component without a member keeps its old value, with no error. The option
clearwith the valueallinitializes them.
Because of the last rule, a partner’s JSON with camel-case names such as claimId is silently not read into a structure
with a component claim_id by the plain identity transformation. The option name_handling helps: its documented values
default, lower_case, lower_camel_case and upper_camel_case change the names in asXML and asJSON, as the example from
the documentation shows. It requires an SAP system; not run here. The comments carry the results the documentation asserts.
TYPES: BEGIN OF s,
comp_b TYPE string,
comp_c TYPE string,
END OF s.
DATA(struc) = VALUE s( comp_b = `B` comp_c = `C` ).
DATA json_string TYPE string.
DATA(nh) = `lower_camel_case`.
CALL TRANSFORMATION id OPTIONS name_handling = nh
SOURCE info = struc
RESULT JSON json_string.
" json_string: {"info":{"compB":"B","compC":"C"}}
Source: Keyword Documentation: CALL TRANSFORMATION, CALL TRANSFORMATION, OPTIONS (the documented example with five components asserts {"info":{"compa":"A","compB":"B",...; the two components here follow the same camel-casing rule), asJSON: General Format, asJSON: Mapping of Structures and asJSON: Mapping of Internal Tables
A serialization that runs in the lab
The local ABAP playground of this site (the open-abap lab, with the reduced version of ZEXP_CLAIM that has only claim_id,
status and amount) runs the identity transformation with a JSON writer as target, the asXML form and the way back from
asXML. It does not accept the RESULT JSON and SOURCE JSON additions, and it fails when asked to read JSON text directly,
so those forms are shown only in the listing above. This listing was run in the lab.
REPORT zp_json_trafo.
DATA claims TYPE STANDARD TABLE OF zexp_claim WITH EMPTY KEY.
INSERT zexp_claim FROM @( VALUE #( claim_id = 'C-0001' status = 'A' amount = 250 ) ).
INSERT zexp_claim FROM @( VALUE #( claim_id = 'C-0002' status = 'N' amount = 90 ) ).
SELECT * FROM zexp_claim ORDER BY claim_id INTO TABLE @claims.
" ABAP to JSON: the identity transformation ID with a JSON writer as target
DATA(writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE claims = claims RESULT XML writer.
DATA(json) = cl_abap_conv_codepage=>create_in( )->convert( writer->get_output( ) ).
WRITE / json.
" ABAP to XML (asXML) and back again
DATA xml TYPE string.
CALL TRANSFORMATION id SOURCE claims = claims RESULT XML xml.
WRITE / xml.
DATA back LIKE claims.
CALL TRANSFORMATION id SOURCE XML xml RESULT claims = back.
WRITE / |lines after the round trip: { lines( back ) }|.
WRITE / |amount of the second line: { back[ 2 ]-amount }|.
Output:
{"CLAIMS":[{"CLAIM_ID":"C-0001","STATUS":"A","AMOUNT":250},{"CLAIM_ID":"C-0002","STATUS":"N","AMOUNT":90}]}
<?xml version="1.0" encoding="utf-16"?><asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><CLAIMS><item><CLAIM_ID>C-0001 </CLAIM_ID><STATUS>A</STATUS><AMOUNT>250</AMOUNT></item><item><CLAIM_ID>C-0002 </CLAIM_ID><STATUS>N</STATUS><AMOUNT>90</AMOUNT></item></CLAIMS></asx:values></asx:abap>
lines after the round trip: 2
amount of the second line: 90
Source: JSON: asJSON for Internal Tables (the same call with cl_sxml_string_writer and if_sxml=>co_xt_json) and JSON: Identity Transformation
Reading it: the table became an array inside an object named CLAIMS, in upper case because the name was written
statically. The padding of the fixed-length claim_id in the asXML line and the exact XML header are what the lab produced;
check them against a real system before relying on them. The JSON line shows the member names in upper case, which is why a
partner who expects camel case needs name_handling or one of the tools below.
A JSON writer returns bytes, so the listing converts them with CL_ABAP_CONV_CODEPAGE, the class the documentation names for
changing between text and a byte representation in a code page.
A transformation that fails raises an exception of the class CX_TRANSFORMATION_ERROR, the common superclass of those of
simple transformations (CX_ST_ERROR) and XSL transformations (CX_XSLT_EXCEPTION), so one CATCH handles the family. The
lab does not raise a catchable error for malformed input, which is why no error case is run here.
Source: Keyword Documentation: CALL TRANSFORMATION (section Exceptions)
Reading and writing tokens with sXML
When the data does not map to an ABAP structure, or is too big to hold at once, the readers and writers of the sXML library
process it node by node. cl_sxml_string_writer=>create makes a writer for XML, or for JSON when you pass
if_sxml=>co_xt_json, and cl_sxml_string_reader=>create makes a reader for a string of XML or JSON. They are the objects
the listing above passes to CALL TRANSFORMATION. The Keyword Documentation page on parsing and rendering JSON covers the
node-by-node methods.
XCO JSON and /UI2/CL_JSON
Two class libraries convert between JSON and ABAP data without a transformation call. The XCO library, released for ABAP
Cloud, has a JSON module that can translate a JSON string into an ABAP structure, build a JSON string from scratch with a
builder, and translate an ABAP structure to a string. Its built-in transformations adjust the names and truth values:
pascal_case_to_underscore, underscore_to_pascal_case and boolean_to_abap_bool. The example below, from the XCO page, reads the
answer of a service whose members are in Pascal case. It requires an SAP system with the XCO library; not run here.
TYPES: BEGIN OF ts_input,
session_id TYPE sysuuid_c36,
user_name TYPE string,
is_premium_user TYPE abap_bool,
END OF ts_input.
DATA ls_input TYPE ts_input.
xco_cp_json=>data->from_string( lv_json_string )->apply( VALUE #(
( xco_cp_json=>transformation->pascal_case_to_underscore )
( xco_cp_json=>transformation->boolean_to_abap_bool ) ) )->write_to( REF #( ls_input ) ).
Source: SAP BTP: XCO Library, JSON and Overview of XCO Modules
Writing goes the other way with xco_cp_json=>data->from_abap( structure )->apply( ... )->to_string( ). In Standard ABAP the
XCO APIs exist as well, often without CP in the class name.
The class /UI2/CL_JSON is a widely used serializer with many optional parameters. The ABAP cheat sheet on XML and JSON
shows serialize, deserialize and generate (for JSON without a matching ABAP type) and refers to the class
documentation in the system; the Help Portal has no topic for it, and the cheat sheet of released classes for ABAP Cloud does
not list it, although that list is only a selection. Open the class in ADT and read its API state before you use it in
ABAP Cloud code. The lab ships a copy of the class, and this listing was run there with the same serializer calls as the
cheat sheet; the lab’s copy is a community version, so real systems may differ in detail.
REPORT zp_json_ui2.
TYPES: BEGIN OF ty_claim,
claim_id TYPE string,
status TYPE string,
amount TYPE i,
END OF ty_claim,
ty_claims TYPE STANDARD TABLE OF ty_claim WITH EMPTY KEY.
DATA(claims) = VALUE ty_claims( ( claim_id = `C-0001` status = `A` amount = 250 )
( claim_id = `C-0002` status = `N` amount = 90 ) ).
DATA(json) = /ui2/cl_json=>serialize( data = claims ).
WRITE / json.
DATA(json_camel) = /ui2/cl_json=>serialize( data = claims
pretty_name = /ui2/cl_json=>pretty_mode-camel_case ).
WRITE / json_camel.
DATA received TYPE ty_claims.
/ui2/cl_json=>deserialize( EXPORTING json = `[{"claim_id":"C-0003","status":"R","amount":10}]`
CHANGING data = received ).
WRITE / |lines: { lines( received ) }|.
WRITE / |first claim: { received[ 1 ]-claim_id } { received[ 1 ]-status } { received[ 1 ]-amount }|.
Output:
[{"CLAIM_ID":"C-0001","STATUS":"A","AMOUNT":250},{"CLAIM_ID":"C-0002","STATUS":"N","AMOUNT":90}]
[{"claimId":"C-0001","status":"A","amount":250},{"claimId":"C-0002","status":"N","amount":90}]
lines: 1
first claim: C-0003 R 10
Source: ABAP Cheat Sheet: XML and JSON (section Handling JSON Data with ABAP Classes)
The three tools compare as follows.
Identity transformation ID |
XCO JSON | /UI2/CL_JSON |
|
|---|---|---|---|
What it is |
Language statement with fixed asJSON layout |
Released class library, builder and conversions |
Serializer class, many options |
Names in the JSON |
Upper case component names; |
Names as in the data; |
Upper case by default; |
Available in ABAP Cloud |
Yes, in the Keyword Documentation for ABAP for Cloud Development |
Yes, released |
Not confirmed in the documentation; check the API state |
Simple transformations and XSLT
When a partner dictates the layout, with names, nesting and value types that asJSON will not give, you write a transformation. A simple transformation (ST) is a small XML document that describes the layout once; the same program serializes ABAP data to XML or JSON and deserializes it back. It is declarative and read serially, which makes it efficient for big data. It handles elementary data, structures and internal tables, not references. For JSON, the transformation must create or read JSON-XML. The following transformation turns the table of claims into an array of objects. It is the pattern of the Keyword Documentation example for an internal table, with the claim fields. It requires an SAP system; not run here.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="CLAIMS"/>
<tt:template>
<array>
<tt:loop ref=".CLAIMS">
<object>
<str name="claimId">
<tt:value ref="$ref.claim_id"/>
</str>
<str name="status">
<tt:value ref="$ref.status"/>
</str>
<num name="totalAmount">
<tt:value ref="$ref.total_amount"/>
</num>
</object>
</tt:loop>
</array>
</tt:template>
</tt:transform>
The transformation, saved under a name such as ZEXP_CLAIMS_JSON, is called like the identity transformation, with the
name in place of id. It requires an SAP system; not run here.
DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION zexp_claims_json SOURCE claims = claims RESULT XML json_writer.
DATA(json_bytes) = json_writer->get_output( ).
In ADT you create the transformation with File, New, ABAP Repository Object, Transformations, Transformation and pick a
template, either a simple transformation or an XSLT program. The Transformation Editor checks, activates and tests it, and
supports breakpoints for debugging simple transformations. An XSL transformation is the other kind: an XSLT program for
turning XML into XML or into HTML or another text format, and for mapping XML to ABAP structures. ABAP builds a DOM for it
with the iXML library, so it is heavier than a simple transformation for large data. The ADT template for it starts as this
skeleton, and parameters from CALL TRANSFORMATION ... PARAMETERS are declared in it with xsl:param and an optional
sap:type. The skeleton requires an SAP system; not run here.
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
</xsl:template>
</xsl:transform>
SOAP web services
SOAP is an older protocol that wraps XML in an envelope. A WSDL file describes the operations and data types of a service. Many existing SAP integrations, especially from the time of SAP Process Integration, use it, so you will meet it even when new work uses HTTP and JSON.
Consuming in ABAP Cloud. The documentation requires a service consumption model (type Web service, created from the WSDL
file), which generates a typed proxy. You create an outbound service of type SOAP (name ending _SPRX), add it to a
communication scenario and publish it, and the administrator makes the arrangement. In the code you take the snippet that
the model’s Overview tab copies to the clipboard: create the proxy object, fill the request structure and call the
operation. The documentation recommends reading the logical port name from a customizing table (delivery class L) and
passing it to the proxy; other approaches are the arrangement, the destination service (not in the ABAP environment of
SAP S/4HANA Cloud Public Edition) and a plain URL. Released protocols can add SOAP header elements, HTTP headers and
exactly-once-in-order processing. The skeleton below shows the shape; the class and structure names come from the generated
model. It requires an SAP system; not run here.
TRY.
DATA(proxy) = NEW zco_generated_consumer( ). " proxy class generated for the model
DATA(request) = VALUE zgenerated_request_type( ). " fill the request fields here
proxy->operation_name( EXPORTING input = request
IMPORTING output = DATA(response) ).
CATCH cx_root INTO DATA(error).
" handle the error
ENDTRY.
Providing in ABAP Cloud. ADT cannot model SOAP services. You need a WSDL file, create a SOAP provider model (SPRV) from it and activate it, which generates the proxy objects, the data types, the service definition and an implementing class. You put the logic into that class, add the generated inbound service to a communication scenario and publish it.
On premise. A consumer proxy is generated in SE80 (Create, Enterprise Service, Service Consumer) or in SPROXY, from an
Enterprise Services Repository object or a WSDL document. The proxy class and its data types are generated, and the
configuration creates a logical port, the SAP-specific record of runtime settings such as the URL. Logical ports are
maintained in transaction SOAMANAGER. The call can name the port in the constructor of the proxy; if no port is named and
no default port exists, the system assumes the XI runtime of SAP Process Integration. A provider proxy is an ABAP Objects
interface: you implement a class for it, and the runtime calls its method EXECUTE_SYNCHRONOUS; when the message was
processed successfully, a commit is triggered at the receiver (compare
SAP LUW, Update Tasks and Commit).
What older books show, and what has changed
The book Complete ABAP (1st edition, 2016, written for SAP NetWeaver 7.4 and 7.5) treats web services, XML, XSLT and JSON in
its chapter on integration. That form is still found in legacy systems: CL_HTTP_CLIENT with SM59 destinations, SOAMANAGER
logical ports and ABAP proxies from SPROXY, and an /UI2/CL_JSON or hand-built JSON. The book predates communication
targets, communication arrangements, service consumption models and the XCO library, which are now the documented way in ABAP
Cloud. CALL TRANSFORMATION, simple transformations and XSLT are unchanged in principle and still apply. SM59 destinations
reach ABAP Cloud code only through a released wrapper class.
Summary
-
ABAP Cloud separates code from connection data: you write against a communication target or a scenario, and an administrator’s communication arrangement supplies address and credentials.
-
The HTTP client is created from a destination, then
executesends the request; check the status code and handleCX_WEB_HTTP_CLIENT_ERRORand the destination errors, and close the client. -
Plain URL destinations are for public services and tests; SM59 and the classic
CL_HTTP_CLIENTare Standard ABAP. -
CALL TRANSFORMATION IDserializes data to asXML or asJSON with upper-case names; reading checks the case and silently ignores what does not match, so usename_handling, XCO transformations or a written transformation for partner layouts. -
XCO JSON is the released library for JSON;
/UI2/CL_JSONis common but must be checked for ABAP Cloud. -
Simple transformations describe a layout once for both directions; XSLT turns XML into XML or HTML.
-
SOAP needs a WSDL file, a consumer proxy or a provider model, and a logical port or a scenario.
References
-
ABAP Keyword Documentation: CALL TRANSFORMATION (ABAP Cloud)
-
ABAP Keyword Documentation: CALL TRANSFORMATION (Standard ABAP)
-
ABAP Keyword Documentation: asJSON, Canonical JSON Representation
-
ABAP Keyword Documentation: asJSON, Mapping of Internal Tables
-
ABAP Keyword Documentation: JSON, asJSON for Internal Tables
-
ABAP Keyword Documentation: JSON, Simple Transformation for Internal Tables
-
ABAP Integration and Connectivity: Creating a Communication Target for Outbound HTTP
-
ABAP Integration and Connectivity: Creating an Outbound Service for HTTP
-
ABAP Integration and Connectivity: Creating a Communication Scenario for Outbound HTTP
-
ABAP Integration and Connectivity: Creating a Communication Arrangement for Outbound HTTP
-
ABAP Integration and Connectivity: Other Approaches for HTTP Outbound Communication
-
ABAP Integration and Connectivity: HTTP Communication via Communication Arrangements
-
ABAP Integration and Connectivity: Service Consumption via Communication Arrangements
-
ABAP Integration and Connectivity: HTTP Communication via URL
-
ABAP Integration and Connectivity: HTTP Communication via Destination Service
-
ABAP Integration and Connectivity: Calling an HTTP Service via SM59 Destinations
-
ABAP Integration and Connectivity: APIs for HTTP Outbound Communication
-
ABAP Integration and Connectivity: Developing External Service Consumption
-
ABAP Integration and Connectivity: Protection Against CSRF Attacks
-
ABAP Integration and Connectivity: Enable SOAP Communication in Your ABAP Code
-
ABAP Integration and Connectivity: Generating Provider Proxies From WSDL Files
-
ABAP Platform: Example program, Executing an HTTP Request (older page)
-
ABAP Platform: Calling an HTTP Service via Communication Targets
-
Complete ABAP (SAP PRESS), Kiran Bandari; the copy consulted is the 1st edition