Skip to Content
0

Fetching URL and authentication details from SAP Cloud Platform Cockpit destinations for web service

Sep 26, 2017 at 06:54 AM

67

avatar image

Hi,

I have to post some details from SAP UI5 application to a webservice which requires username password to send data. I have defined webservice details as destination in SAP Cloud Platform Cockpit with basic authentication. I am new to webservice and AJAX post call. I want to fetch URL, username and password from destination in sap ui5 application to send a post call. I searched and came across multiple blogs and archives, but none of them had authentication and SAP Cloud Platform Cockpit destination usage.

I need step by step guidance of fetching destination details like URL, Credentials in application and steps to send a post call with those details. Is there a alternate way to send details to a webservice with encrypted data?

I request you all to please give me suggestions as soon as possible. I have to find a solution for this on urgent basis.

Thanks,

Saurabh.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Saurabh Singh Sep 27, 2017 at 06:34 AM
0

I could not find any help on retrieving details from SAP Cloud Platform Cockpit Destinations so i tried to put values directly in the post call itself. I was able to write down following code after going through lot of blogs and posts:

$.ajax({
            method: "POST",
            crossDomain: true,
            dataType: 'xml',
            contentType:"text/xml; charset=\"utf-8\"", 
            beforeSend: function(xhr) {
                xhr.setRequestHeader("Authorization", "Basic " + btoa("uNameId" + ":" + "uPassword"));
            },
            async:false,
            url: "http://webservicemessageservlet",
            data: {

                inputxml: escape("Encoded message soap xml")

            },
            cache: false,
            success: function(data) {
                console.log(data);
            },
            error: function(jqXHR, textStatus, errorThrown) {
                console.log(textStatus, errorThrown);
            }
        });

This call is happening on click of a button. Previously the call was getting cancelled in the network, but after few trail and errors now it is giving 401 unauthorized error.

Can someone please tell me, where am i going wrong with this?

Thanks,

Saurabh.

Share
10 |10000 characters needed characters left characters exceeded