来源资料待手动核验
ABAP Sdk Nwas
ABAP code for using IBM Watson Developer Services with SAP NetWeaver Application Server, imported via abapGit
项目简介
ABAP code for using IBM Watson Developer Services with SAP NetWeaver Application Server, imported via abapGit
ABAP code for using IBM Watson Developer Services with SAP NetWeaver Application Server, imported via abapGit
ABAP code for using IBM Watson Developer Services with SAP NetWeaver Application Server, imported via abapGit
ABAP client library to use the [IBM Watson APIs][wdc]. This is a Community SDK written by ABAPers for the ABAPers in the Open Source community, to provide easy usage of IBM Watson Developer Services in innovation initiatives combined with any SAP Application which is run on SAP NetWeaver 7.50 and above, such as SAP Business Suite or SAP S/4HANA on-premises edition. It is the choice and responsibility of application developers how this Community SDK is used.
Additionally, as the ABAP SDK is a community release it is not updated with the same schedule as IBM-supported SDKs. Please see more information in Questions.
| abap-sdk-nwas | abap-sdk-scp |
|---|---|
| for SAP NetWeaver AS ABAP 7.50+ | for SAP Cloud Platform ABAP Environment 2002+ |
| tested on SAP Business Suite and SAP S/4HANA on-premises edition | |
this repository |
Version v2.0.0 of the SDK has been released and includes breaking changes - see what's changed in the migration guide.
The client library is provided as ABAP Git Repository. Proceed as follows to clone the ABAP SDK code to your SAP system.
ZIBMC when performing setup of the abapGit repository.The following SAP profile parameter settings are recommended.
icm/HTTPS/client_sni_enabled = TRUE
ssl/ciphersuites = 135:PFS:HIGH::EC_P256:EC_HIGH
ssl/client_ciphersuites = 150:PFS:HIGH::EC_P256:EC_HIGH
wdisp/ssl_ignore_host_mismatch = TRUE
The client library respects the ABAP proxy settings. If you are using a central proxy server that is not already configured in your SAP system, proceed as follows.
Communication between SAP and the IBM Cloud is secured by the Transport Layer Security (TLS) protocol, also known as Secure Sockets Layer (SSL). SSL requires certificates that must be stored on the SAP application server in the Personal Security Environment (PSE). Transaction STRUST is used to maintain the PSE.
If a call to an IBM Cloud service failed due to a missing SSL certificate, check the ICM trace file to find the required certificate. To do so, call transaction SMICM and select menu item Goto → Trace File → Display End. Alternatively, call transaction AL11 and navigate to file DIR_HOME/dev_icm. Find last entry in trace file that indicates error SSSLERR_PEER_CERT_UNTRUSTED, as shown in the example below.
[Thr nn] Peer not trusted
[Thr nn] Certificate:
[Thr nn] Certificate:
[Thr nn] Subject: CN=*.watsonplatform.net, O=INTERNATIONAL BUSINESS MACHINES CORPORATION, L=Armonk, SP=New York, C=US
[Thr nn] Issuer: CN=GeoTrust RSA CA 2018, OU=www.digicert.com, O=DigiCert Inc, C=US
[Thr nn] Serial Number: 05:1C:46:1B:6E:C2:29:48:BD:F0:03:B3:A6:87:1A:5B
[Thr nn] Verification result:
[...]
[Thr nn] SignerCert:
[Thr nn] Certificate:
[Thr nn] Subject: CN=GeoTrust RSA CA 2018, OU=www.digicert.com, O=DigiCert Inc, C=US
[Thr nn] Issuer: CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US
[Thr nn] Serial Number: 05:46:FE:18:23:F7:E1:94:1D:A3:9F:CE:14:C4:61:73
[Thr nn] Verification result:
[...]
[Thr nn] SignerCert:
[Thr nn] Certificate:
[Thr nn] Subject: CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US
[...]
[Thr nn] << ---------- End of Secu-SSL Errorstack ----------
[Thr nn] Target Hostname="stream.watsonplatform.net"
[Thr nn] SSL NI-hdl 463: local=9.152.20.145:56542 peer=169.48.115.62:443
[Thr nn] <<- ERROR: SapSSLSessionStartNB(sssl_hdl=3fef0000c70)==SSSLERR_PEER_CERT_UNTRUSTED
[Thr nn] *** ERROR => SSL handshake with stream.watsonplatform.net:443 failed: SSSLERR_PEER_CERT_UNTRUSTED (-102)
[Thr nn] The peer's X.509 Certificate (chain) is untrusted
The SSL error stack shows the SSL certificate chain, which in the example above looks like follows:
| Certificate Authority Type | Certificate Authority (CA) |
|---|---|
| end-user | *.watsonplatform.net |
| intermediate | GeoTrust RSA CA 2018 |
| root | DigiCert Global Root CA |
You can install any of these SSL certificates. However, it is recommended to install the root CA certificate.
Download the appropriate SSL certificate from the provider's website, for example https://www.digicert.com/digicert-root-certificates.htm. Store the certificate file on your computer.
Proceed as follows to add the downloaded SSL certificate to your SAP system's Standard SSL Client PSE.
SSL client SSL Client (Standard) and selecting Create from context menu. Keep all default settings in next popup dialog.It is recommended to restart the ICM after a new SSL certificate has been applied to the PSE. To do so, proceed as follows.
Before you can access a specific service from your SAP system, you must create a service instance in the IBM Cloud and obtain credentials. The credentials can be shared among multiple end users of the SAP system, but you must ensure that the selected plan is sufficient to support the expected number of calls or the expected data volume. Please note that some plans may have restrictions on the allowed methods, so make sure to select the right plan for your purpose.
All currently supported services support IAM authentication (see below). Service credentials consist of an API Key and a URL. Both the API Key and the URL are character values that can be viewed through the IBM Cloud dashboard and need to be provided as parameters i_apikey and i_url to method zcl_ibmc_service_ext=>get_instance.
You can store the values with your application, but it is suggested to do that in an encrypted format. Using cloud services usually creates costs based on usage for the owner of the service instance, and anyone with the credentials can use the service instance at the owner's expenses. If you want to distribute the costs over multiple cost centers, you need to create a service instance and provide service credentials for each cost center separately.
Service credentials and other parameters that must be specified at Watson service wrapper ABAP class instantiation can also be provided in table ZIBMC_CONFIG. This table has three keys:
| Table Key | Description |
|---|---|
| SERVICE | The ABAP class name without prefix ZCL_IBMC_ |
| INSTANCE_UID | ID chosen by application developer that must be provided by application as parameter to method zcl_ibmc_service_ext=>get_instance() |
| PARAM | The parameter name |
| Parameter Name | Default Value | Description |
|---|---|---|
| URL | service-dependent | Watson service url |
| APIKEY | Watson service API keys | |
| PROXY_HOST | Proxy server | |
| PROXY_PORT | Proxy server port | |
| AUTH_NAME | service-dependent | Authorization, IAM or basicAuth |
| SSL_ID | CLIENT | SSL Identity, defines PSE for SSL certificates: CLIENT or ANONYM |
Identity and Access Management (IAM) is a bearer-token based authentication method. Token management is either performed by the ABAP SDK or must be implemented by the SDK user.
If a value for apikey is provided by the caller in method zcl_ibmc_service_ext=>get_instance(), the ABAP SDK generates a bearer-token under the cover when needed and refreshes it when it is about to expire.
If apikey is not provided for method zcl_ibmc_service_ext=>get_instance(), the ABAP SDK user must implement an individual token management. Before a service method is called the first time, a valid bearer-token must be provided to the Watson service wrapper ABAP class instance as follows:
lo_service_class->set_bearer_token( i_bearer_token = '...' ).
Afterwards, service methods can be called as long as the provided token is valid. When the token has expired, the method above must be called again with a new (refreshed) bearer-token as parameter.
The client library is delivered as package ZIBMC. Once the Git Repository has been cloned to the SAP system, a Watson service instance is wrapped by an ABAP class instance.
The following Watson services are currently supported:
| Service | ABAP Class Name |
|---|---|
| Discovery | ZCL_IBMC_DISCOVERY_V2 |
| Language Translator | ZCL_IBMC_LANG_TRANSLATOR_V3 (*) |
| Natural Language Understanding | ZCL_IBMC_NAT_LANG_UNDRSTND_V1 |
| Speech to Text | ZCL_IBMC_SPEECH_TO_TEXT_V1 |
| Text to Speech | ZCL_IBMC_TEXT_TO_SPEECH_V1 |
| Watson Assistant | ZCL_IBMC_ASSISTANT_V1 |
| ZCL_IBMC_ASSISTANT_V2 |
(*) Deprecated service; will be discontinued in the future.
Using the client library requires two steps:
zcl_ibmc_service_ext=>get_instance. data:
lo_service_class type <ABAP Class Name>.
zcl_ibmc_service_ext=>get_instance(
exporting
i_url = <url>
i_apikey = <api key>
...
importing
eo_instance = lo_service_class ).
try.
lo_service_class->method(
exporting
is_input = ...
importing
es_output = ... ).
catch zcx_ibmc_service_exception into data(lo_service_exception).
...
endtry.
* List all voices provided by Watson Text to Speech
" declare variables
data:
lv_apikey type string value '...',
lo_text_to_speech type ref to zcl_ibmc_text_to_speech_v1,
为保持页面易读性,当前仅展示 README 的前半部分。请打开原始 README 阅读完整内容。