Video How-To: Invoke an external web service via coding?
This is part of a series of integration video how-to’s for SAP Cloud Applications Studio. The main blog post can be found here: Video How-To: Integration capabilities of SAP Cloud Applications Studio
I thought it might be good to create dedicated blog post so that I also can provide the code snippet here.
Goal:
– Invoke an external web service with ABSL coding
Again we use my Bonus Plan use case. What we have done so far:
– Business Object “Bonus Plan” is created
– Web Service in C4C is created for Bonus Plan: This allows external applications to create Bonus Plans
We want to consume our own web service in this example as this is the best way to learn it. So we want to create some ABSL coding that can create a bonus plan via web service request and this is basically what I show in the video.
Content:
– Use WSDL to create an External Webservice Integration
– Create your own “Communication Scenario”
– Configure a “Communciation System”
– Configure a “Communication Arrangement”
– Create ABSL coding to invoke a service
Video recommendation: watch in HD (720p) for best experience.
Summary of the relevant content types:
These video tutorials are based on my use case “Bonus Plan” but can also be consumed apart from that. All my videos where I explain everything from the very beginning can be found here: SAP Cloud Applications Studio Video-How-To’s.
Hi Jens,
I need to pass a collection of records in a single call. If my Service Interface accepts "1 to N" records, how do I use ABSL script to populate the request parameters with multiple records ?
Earlier I used to make multiple calls in a far loop, but there is a need to pass the whole collection in one go.
Regards,
Srikanth
Hi Srikanth,
please try to introduce a collection of your "node" of the service:
var myServiceNode:collectionof
Library::WebService.CreateAccount.Request.Customer.Address;
Then you can fill the collection as it allows multiple values an this should generate as many node elements in the xml structure as you put instances there.
Cheers,
Jens
Hi Jens,
The scenario is to replicate the contents of a Custom BO to CRM via PI. The External Web Service Integration object is created using the WSDL downloaded from PI. When I do a CTRL+J after Library::WebService.<ServiceInterface>.MessageType. I do not get a collection option here nor an action like CreateAccount.
When we generate the External Web Service from a Web Service exposed by Custom Object in Cloud as you have shown in the tutorial, we get such options, but I'm not getting such options for the WSDL provided by PI for Custom Object data replication.
Regards,
Srikanth
Hi Jens Limbach
Do you have a written sample code absl insert Item crate sales quotes.
Hi Jens,
Great video, but I have a question, 7:58 minutes describing the inbound and outbound Custom service, in my case these nodes are empty. And when I save I get the message "you must select the services that you 'want to include in the communication scenario".
The service is good, I've tested with soapUI.
Regards,
John Izaguirre
Hi,
this is a displaying issue. Please close the CSD window and save andactivate your external service file of the solution. Then after re-opening the CSD you will see the checkboxes.
Cheers,
Jens
Great!! thanks for the help!!
Now I have an error, although already checked all the permissions to access the Webservice, remains ping failure:
Regards,
John Izaguirre
Hi John,
Are you able to resolve this issue.Am also facing the same error when I tried to Check the Connection.Please share your solution here.
Regards,
Arjun
Hi Jens
- Use WSDL to create an External Webservice Integration
- Create your own "Communication Scenario"
- Configure a "Communciation System"
- Configure a "Communication Arrangement"
- Create ABSL coding to invoke a service
Can create a service consumer use ABAP coding to invoke the service on ECC??
Similar links below:
http://sapignite.com/consuming-a-web-service-in-abap/
Best regards,
Daniel Su
Great Video Jens.
Hi All,
I have one requirement to automate the remittance advice for the payment monitor in the Payment Management. ie., Whenever payment is done, remittance should be generated automatically.
Approach followed as mentioned:
1). Downloaded the ManageRemittanceAdviceIn WSDL to create an External Webservice Integration
2). Create the own "Communication Scenario"
3). Configured the "Communciation System"
4). Configure the "Communication Arrangement"
5). In the before Save Event of Payment BO, Created ABSL coding to invoke a service.
When we trigger the webservice in the before save event of the Payment BO, instead of 1(one) remittance, thousands(1000) of remittance are created.
In the before Save Event of the Payment BO, invoked the web service using the below ABSL code.. var
// Declaration
ZRequestRef : ZPaymentFileIntegration.MaintainBundle.Request;
var ZResponseRef : ZPaymentFileIntegration.MaintainBundle.Response;
var ZPaymentRef : ZPaymentFileIntegration.MaintainBundle.Request.RemittanceAdviceBundleMaintainRequest_sync.RemittanceAdvice;
// Assigning value from XML to External Web Service Integration.
ZPaymentRef.AccountDebitIndicator = false;
ZPaymentRef.BusinessPartnerInternalID = this.BusinessPartner.InternalID;
ZPaymentRef.EffectivePaymentAmount.content = this.TransactionCurrencyAmount.content;
ZPaymentRef.EffectivePaymentAmount.currencyCode = this.TransactionCurrencyAmount.currencyCode;
ZPaymentRef.CompanyID = this.Company.ID;
ZPaymentRef.ExternalAdviceID.content = this.ExternalID.content;
ZPaymentRef.PaymentReference.ID.content = this.ExternalID.content;
// Add the elements of the Remittance into the Remittance Advice Collection
ZRequestRef.RemittanceAdviceBundleMaintainRequest_sync.RemittanceAdvice.Add(ZPaymentRef);
// Execute the Webservice Call –The below response get executed for more than 3 mins and thousands of remittance are created for the single payment.
ZResponseRef = ZPaymentFileIntegration.MaintainBundle(ZRequestRef, "", "ZPaymentIntegration");
ZRequestRef.Clear();
ZResponseRef.Clear();
ZPaymentRef.Clear();
The code line highlighted - response is taking too much time to come out of that and thousands of remittance are created. What is missing from side? Please help 🙂
hi Sabari Nathan Mariappan
Do you have a written sample code absl insert Item crate sales quotes ?.
Hello, Jens,
Thanks for nice blog. I am trying to consume REST service created in hybris. But it is a different scenario. Here when I put End Point details and communication arrangement, it is not providing me Outbound Services even after I restart Cloud Studio.
Any pointers around consuming REST service?
Regards,
Omkar Uthale
Hi All,
I have followed the same process to consume external webservices. In Communication arrangement am getting an error "URL for outbound communication missing"
and when i try to test the created service am getting error " <Note>SOAP:1.048 SRT: HTTP error: ("HTTP Code 200: OK - Details see in error log of transaction SRTUTIL")</Note>"
Kindly let me know what i have to do?
Regards,
Siva M
Hi,
Can we trigger a webservice from an event like after loading
Here is my requirement : https://answers.sap.com/questions/326843/event-afterloading-for-an-opened-status.html
Thanks,
Adithya
Hello Adithya,
You won't need a WebService for your requirement. See my comment there. 🙂
Bye,
. Horst
Hi Horst,
I have a similiar question regarding the video "Invoke External Web Service".
In the studio, Is it possible to consume an internal web service to create an instance of another business object then the one you're doing the XBO scripting for? I found a service integration called "Internal Communication" but that only applies to custom BOs. So i guess using web services is the only way to be able to create instances of other BOs? For example. When creating a Service Order i also want to create a Customer Return Notifications using the information from the Service Order.
I've tried setting this up but i can't get the authorization to work. I know there is some issues with pinging when using external web services(although this is an internal web service) and also testing the service operations in the studio. So i can't really pin point the problem.
Am i suppose the use the same user as in the studio? Because in the video the technical user is used for both the incoming and outgoing communication and i can't get that one to work.
Best regards,
Pierre
Hello Pierre,
In a script you can create instances of any Business Object you want.
As long as this Business Object is in the same Deployment Unit (e.g. Customer Relationship Management) or it is in the special Deployment Unit Foundation.
See the documentation at section 7.2.4.16 Create Instance
HTH,
. Horst
Hi Horst,
Yes i've tried this approach also. Maybe i missed something but creating a new instance of a standard BO just gives me read only objects? So i can't manually map what fields should be what? That's why i resorted to web services. Because i need to create a Customer Return (Notification) without reference to a Sales Order.
Regards,
Pierre
Hello Pierre,
The standard BO returns an instance which adheres the property settings.
Most standard BOs have nearly all fields in the Root node set to read-only.
You should look into the Repository Explorer for this BO the get the details.
HTH,
. Horst
Dear Horst,
Can we consume an external SOAP service that requires token authentication ?
Hello Truong,
As mentioned in the documentation at section 8.15.5.5 "Integrate an External Web Service Using SOAP" you need a Communication Scenario.
Please have a look at the documentation Communication Scenario if it is possible to use token based authentication for SOAP based Communication Scenarios.
Bye,
. Horst
Dear Horst,
I have read the document but I do not see anything about token authentication. So with SAP BYD, we can only call a simple SOAP service ?
Thanks.
Hello Truong,
If there is no more support from the Communication Scenario, then it is like that.
Sorry,
Horst
Hi Jens,
The above mentioned details are to invoke a SOAP service in SDK. I need to invoke a REST service in the SDK . I have created communication arrangement but check connection giving error , as there is no path given. I dont know which path I should give to make it work. Please suggest me steps to execute rest web from communication arrangement or in SDK.
Thanks & Regards,
Manoj
Hello Manoj,
Did you manage to call a rest service from SDK ? Could you provide some hints about steps you followed please ?
Thanks
Dear Limbach
Seems the videos are not available to access, Please check .
Thanks
Video is hidden, not available to watch.
Hi Jens,
Unfortunately, I can't watch the video since it is hidden. Could you please share it again?
Thanks!