如何處理消費SAP ABAP Web Service時遇到的Unauthorized錯誤
Previously I have written two documents about how to create document template with Word or Adobe PDF format which support web service created by Web service tool available in CRM Web client UI:
(1) Create Webservice enabled word document in attachment assignment block (2) Create Webservice enabled Adobe PDF attachment in CRM Application
Besides that you could still use external web service from third party or created from a remote function module via tcode SOAMANAGER in ABAP system.
However when you paste the URL of your WSDL as below and press enter key, you meet with the error message “Unauthorized”.
Before we start to trouble shooting, we’d better quickly go through this document how to create and consume web service in ABAP system to have a basic idea about web service creation and consumption in ABAP system.
Why we will see this Unauthorized error message
The position of this error message could easily be found via the tip described in my blog How to quickly locate the source code where raises a given message in webclient UI:
The WSDL URL we input is used to initialize one instance of cl_http_client and then cl_http_client~send and cl_http_client~receive are called to get the content of this WSDL.
Then we get expected 401 Unauthorized error, since we didn’t specify any credentials in this generic code.
go to tcode SICF and find the ICF node /default_host/sap/bc/ ( which is the parent node of the ICF service generated for our web service), the logon procedure for it is set as “Standard”.
According to SAP help, Standard logon procedure means the framework will do authentication check based on the following orders until one avalid credential found. In our case, none of the seven attempts succeed, so finally we see 401 Unauthorized error.
How to resolve the error
According to SAP help, after I add the following code to enable HTTP Basic Authentication, the error is gone.
Of course this could not be used in productive code, we need to find a more generic solution. Go outer callstack of 401 error, I find there is another way to initialize http client instance by RFC destination instead ( line 49 ). Doing a where used list on class attribute mv_destination and soon I found there is a BAdI definition which could allow us to specify a HTTP destination for the external web service being used:
So the solution would be:
(1) Create a HTTP destination in tcode SM59 Maintain “Target Host”, “Service No.”( that is port number ) and paste the left part of WSDL URL to “Path Prefix”.
Maintain user and password:
(2) Create a BAdI implementation on BAdI definition CRM_OI_WEBSERVICE_BADI
Implement the method GET_SERVICE_DESTINATION. fill the changing parameter cv_destination. You could do filtering based on the importing WSDL URL and Operation, in this example I just hard code the name of RFC destination created in step one.
Now this destination will be used to create http client instance and the 401 error message is then resolved.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2721607/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 消費SAP C4C Web Service時遇到的Authorization role missing錯誤Web
- 最詳細的 SAP ABAP Web Service 建立和消費步驟講解Web
- 如何在SAP CRM裡建立和消費Web serviceWeb
- SAP ABAP 透過 https 消費外部 API 遇到錯誤訊息 SSSLERR_SSL_CONNECTHTTPAPI
- 如何在 SAP BTP 平臺 ABAP 程式設計環境裡消費基於 SOAP 的 Web Service程式設計Web
- 如何處理CloudFoundry應用部署時遇到的254錯誤Cloud
- 如何處理SAP CRM Web Service錯誤 - Virtual Interface Method XXXX not supportedWeb
- 如何使用 ABAP 程式消費 SAP ABAP OData 服務
- 如何處理使用 SAP UI5 消費真實的 OData 服務時遇到的跨域問題UI跨域
- 使用soapUI消費SAP Cloud for Customer的web serviceUICloudWeb
- 如何處理ABAP DDIC_TYPE_INCONSISTENCY錯誤
- SAP ABAP 釋放 TR 遇到錯誤訊息 ended with return code 8 的含義和處理辦法
- 如何處理SAP HANA Web-Based Development Workbench的403 Forbidden錯誤WebdevORB
- 使用nodejs消費SAP Cloud for Customer上的Web serviceNodeJSCloudWeb
- 使用 Excel cdata addin 連線 SAP ABAP 系統時遇到錯誤訊息Excel
- 處理SAP HANA Web-Based Development Workbench的403 Forbidden錯誤WebdevORB
- 使用SAP WebIDE消費API Portal裡建立的API時的錯誤訊息WebIDEAPI
- Spring Cloud Stream消費失敗後的處理策略(二):自定義錯誤處理邏輯SpringCloud
- 如何處理用程式碼建立SD Sales order時遇到的錯誤訊息KI 180
- 搭建dataguard時,錯誤處理
- 訪問 SAP 電商雲 Storefront 時遇到的 HTTP 403 錯誤HTTP
- 使用 SAP Fiori Tools 部署 SAP UI5 應用到 ABAP 伺服器時遇到的各種錯誤和解決辦法UI伺服器
- 在 Excel 內使用 ODBC 消費 SAP ABAP CDS viewExcelView
- 錯誤處理:如何通過 error、deferred、panic 等處理錯誤?Error
- SAP ABAP 系統進行 client 複製時遇到的 63999 table too wide 錯誤訊息clientIDE
- Go 語言中遇到 _func not exported by package_ 錯誤,應該如何處理?GoExportPackage
- 使用 SAP WebIDE 將 SAP UI5 應用部署到 ABAP 系統時遇到的關於傳輸請求的錯誤WebIDEUI
- JavaScript 中遇到的錯誤問題,該怎麼處理?JavaScript
- 部署 SAP UI5 應用到 SAP BTP 時遇到的 fiori not found 錯誤訊息UI
- SAP CRM中介軟體下載equipment時遇到的一個錯誤UI
- 如何在Web應用裡消費SAP Leonardo的機器學習APIWeb機器學習API
- 錯誤處理
- 基於spring的web應用,如何處理服務層的錯誤?SpringWeb
- 如何處理SAP雲平臺錯誤訊息 there is no compute unit quota for subaccount
- go的錯誤處理Go
- SAP CRM如何建立支援Web Service的word模板Web
- SAP CRM如何建立支援Web Service的PDF模板Web
- 如何在 Go 中優雅的處理和返回錯誤(1)——函式內部的錯誤處理Go函式