Tuesday, September 20, 2022

How to use a SOAP web service as Rest call using Basic or OAuth 2.0

Let us take example where we want to invoke a BIP report  using ExternalReportWSSService

This is a SOAP service but we can still use it as a REST service by following the below steps.

Let us take SOAP UI to test this:

Get the web service wsdl url:

https://<<FA Domain:443>>/xmlpserver/services/ExternalReportWSSService?wsdl

https://xxxx-dev1.fa.us6.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService?wsdl

Remove ?wsdl from the url and keep like below:

https://xxxx-dev1.fa.us6.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService

 Now go to SOAP UI and Create REST project :

 

 

 

Provide the URL like below and click ok:

 

https://xxxx-dev1.fa.us6.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService

 

 

Change the Method to POST 

The Method , request and Endpoint will look like below:


 

 Now in the Media type  enter below:

application/soap+xml;charset=utf-8

 

 

In the payload copy the runReport  payload that we use in the SOAP call/SOAP Project.

The payload would look like below:

 

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">
   <soap:Header/>
   <soap:Body>
      <pub:runReport>
         <pub:reportRequest>
            <pub:parameterNameValues>
               <!--Zero or more repetitions:-->
               <pub:item>
                  <pub:name>P_DS_DATE</pub:name>
                  <pub:values>
                     <!--Zero or more repetitions:-->
                     <pub:item>08-21-2022</pub:item>
                  </pub:values>
               </pub:item>
            </pub:parameterNameValues>
            <pub:reportAbsolutePath>/Custom/FAH/Transactional Reports/PaaS To SaaS Reconciliation/Consolidated Count Reports/Consolidated Count AllApplication LedgerWise Report.xdo</pub:reportAbsolutePath>
            <pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>
         </pub:reportRequest>
      </pub:runReport>
   </soap:Body>
</soap:Envelope> 


After this provide the Authentication,

 

 


The complete request would look like below:

 

POST https://xxxx-dev1.fa.us6.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=utf-8
Content-Length: 983
Host: xxxx-dev1.fa.us6.oraclecloud.com:443
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/12.0.1)
Authorization: Basic c3VtaXRfa3VtYdhYURTEVsY29tZUAxMjM=
 

 

Now we are good to submit the request:

Click on the Green play button to submit the request.

We get the successful response as below:

 

 Now let us see how We can use OAuth 2.0 Authorization instead of basic auth.

For this we need to create a client and resource confidential app in IDCS.

We will get Client id, secret, scope etc and we can use that to generate the token.

We can either pass the existing token or we can generate a new one:

Here we already have generate a token using the IDCS confidential client app: we will be passing the token:

Add New Authorization

 

Select OAuth 2.0, provide the profile name and click ok.

 

 


 

We get the option like this:

Here we can provide existing token which is not yet expired or we can click on Get Token to generate new one after providing the required retails.

In our example we will be a token which we have already generated and is not yet expired:

After providing the token we can submit the request. 

We get the successful Response:

 

The above can be tested from POSTMAN as well.



No comments:

Post a Comment