Skip to Content
Author's profile photo Former Member

Consuming REST web service (with Parameters) in BODS using HTTP Adapter

Let us try to understand, how to access a REST based web service (with parameters) in batch job from BODS. This feature is supported from BODS 4.0 SP3 patch3.

 

In this example, we will try to call an external web service by passing two values viz. material number and type as arguments and will capture the material attribute details as return by the web service function.

 

To implement this in SAP Data Services, first of all we need to create a HTTP adapter instance, then add an operation to the adapter instance and create HTTP Adapter datastore. Next we need to Import the required function module. Finally build a Job and a Dataflow to consume the function module.

 

To add a HTTP adapter instance in the Administrator

 

  • Select Adapter Instances > Job Server.
  • Click the Adapter Configuration tab.
  • Click Add.
  • Select the adapter from the list of those available on this Job Server.
  • Enter the required information to create an HTTP adapter instance.
  • Click Apply.

Capture1.PNG

Let’s name the Adapter Instance name as HttpAdapter. For the other fields, select default values.

The next step is to configure adapter operations. Adapter operations identify the integration operations available with the configured adapter instance.

 

To add an operation instance to an adapter instance

 

  • Select Adapter Instances > Job Server.
  • Click the Adapter Configuration tab.
  • Under Dependent Objects, click Operations.
  • Click Add to configure a new operation.
  • Select an operation type from the list (here Request/Reply), then click Apply. The options that appear depend on the operation specific design.
  • Complete the operation instance configuration form.
  • Click Apply.

Here for this demonstration I am using the below dummy web service.

 

http://test-batch-webapp/d/api/testcatalog/v1/shcoffering/pid/?client=COMMERCIAL&pid=71240403000

Capture2.PNG

 

  • Give name of the input xsd in ‘Request message format’.

  Input parameters can be converted to xsd as follows(the reason is that BODS can only use xml format as input and output):

Capture3.PNG

  • Give schema name of the reply xml in ‘Response message format’.
  • Give ‘param-value’ in ‘convert input XML to’ column. This is required to convert the input xml to parameters.

   The next step is to create the Datastore. Go to the Datastore tab of the Local Object Library. Right-click and select New to create a Datastore.

For Datastore type, select Adapter. For Job Server, select the Job Server configured to handle HTTP adapter. For Adapter instance name, choose the instance name configured in the Administrator. Click OK to save values and create the datastore.

.

Capture4.PNG

To import message functions

  • In the Designer, double-click the HTTP data store .The Adapter Metadata Browser window opens.
  • Right-click the operation instance to import and select Import from the menu.

  

The operation instance OPERATION_GET_DESC is added to the datastore.

So now we can find the imported function under the Message Functions section of the HTTP Datastore of the Local Object Library.

Double-click the function module to preview the Schema Definition. As mentioned previously this function module expects an input XML Schema as REQUEST and also returns an output XML Schema as REPLY or response.

Capture5.PNG

 

Now a Dataflow in a data services job can consume the function call. Below is the implementation screenshot of the Dataflow.

Capture6.PNG

Here the Source Table has columns CLIENT and PID. The requirement here is to pass this information to web service and get the reply message.

 

Here the query transform Q_Test_Nest is used to generate a XML Schema(TEST_ADAPTER_INPUT) as per the required input template for the Web Service Function. In query transform Q_Test_XML_Func_Call , function OPERATION_GET_DESC is called by using New function call and passed the generated XML schema (TEST_ADAPTER_INPUT)as input arguments to the Web Service Function.

Capture7.PNG

Query Transform Q_Unnest_Records is used to UNNEST the Return Schema and finally the required fields from the response xml is populated to the table C_TEST_STG.

Assigned tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo kamal kumar
      kamal kumar

      Hey ,

      Thanks a lot for your post.

      I successfully implemented above mentioned steps but while executing the job I got following error

      Error calling function:<Adapter Request_Reply: java.security.cert.CertificateException : Untrusted Server Certificate Chain>

      Kindly have a look to resolve the issue.

      Regards,

      Kamal

      Author's profile photo Former Member
      Former Member

      Hi Jincy Mathew,

      Great informative post

      Have a question on ODBC - do you have the steps to emulate an ODBC on Solaris. Tried Datadirect but that did not work.

      Cheers,

      Megha Chanchal A. Puthussery

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Megha,

      Please check link http://scn.sap.com/message/5749481#5749481

      (last comment by Scott Broadway). It may help you.

      Regards,

      Jincy

      Author's profile photo Former Member
      Former Member

      hi Jincy M

      Thank you for the post

      I would like to know if it is necessary to have a extranet connexion to import the operation in the datastore.

      thank you in advance for your reply

      Sder

      Author's profile photo Arun Sasi
      Arun Sasi

      Excellent document Jincy!!

      Arun

      Author's profile photo Former Member
      Former Member

      Great Post!

      Would like to know if there is a way to include custom HTTP header parameters in Adapter/Operation configuration?

      Thank you.

      Author's profile photo Rajendra Chandrasekhar
      Rajendra Chandrasekhar

      Hi,

      My BODS server is sitting behind a proxy server and all the http request goes via Proxy. Is there any way to configure Proxy server authentication in HttpAdapter ?

      My Adapter is working fine without proxy but fails to connect when proxy is enables ( Keep getting Connection Timed out" error.

      Author's profile photo Arun Sasi
      Arun Sasi

      If you are connecting to the adapter from behind a proxy

      server, add the following to the end of the Additional

      Java Launcher options

      -Dhttps.proxyHost=

      <proxy_server_name>

      -Dhttps.proxyPort=

      <proxy_server_port>

      Refer

      http://help.sap.com/businessobject/product_guides/sbods42/en/ds_42_adapters_en.pdf

      Regards

      Arun Sasi

      Author's profile photo Rajendra Chandrasekhar
      Rajendra Chandrasekhar

      Thanks Arun for your quick reply. I was able to configure the Proxy in HttpAdapter. However the proxy need authentication ( i.e user ID and password). Where can we configure this ?

      Thanks

      Rajendra

      Author's profile photo Arun Sasi
      Arun Sasi

      Are you getting any error after adding the proxy parameters.

      Not sure about the parameters for an authenticating proxy. I would have tried with

      -Dhttps.proxyUser=UserName

      -Dhttps.proxyPassword=Password

      Just a copy from Google... 🙂

      http://viralpatel.net/blogs/http-proxy-setting-java-setting-proxy-java/

      Regards

      Arun Sasi

      Author's profile photo Rajendra Chandrasekhar
      Rajendra Chandrasekhar

      Thanks Arun, I was able to make Adapter work without Proxy User ID and Password Authentication. For some reason my earlier restart of Adapter didn't worked , but 2nd attempt did worked.

      Thanks. Rajendra

      Author's profile photo Arun Sasi
      Arun Sasi

      Glad it worked!

      Author's profile photo Former Member
      Former Member

      I am getting connection timeout error. I am not sure where I am missing. What exactly the TARGET URL should be?