Skip to Content
Author's profile photo Former Member

Consuming Your First Synchronous RESTful Service – Step-by-Step – Proxy Class and Testing


This is the last part of a mini-series blog about how to build a basic SAP-to-REST synchronous interface scenario. The blog’s first part can be found here:  Consuming Your First Synchronous RESTful Service – Step-by-Step – Introduction. This part is to build a proxy class in the sending SAP ECC system and to test our integration scenario.

Let’s get to work

Generating a proxy class and creating a test program.

    • Generating the proxy:
      • Log on to the sender SAP ECC system. Go to either transaction SPROXY or transaction SE80. In SE80, select the “Enterprise Services Browser” object type from the left navigation pane.
    • If the software component version that we created earlier is not visible, click the “Refresh” button in order to re-read the ESR catalog.
    • Once the software component version is visible, expand the nodes of the service interface until you see the “outbound” service interface we created earlier.

    • Now, right-click the outbound service interface and select the “Generate Proxy” option.

    • You will be presented by a wizard screen on which you can either check the “local object” flag or select an existing change request. Make sure to add a prefix in your customer name space (starts with Y or Z). Then, click “Finish.”

    • After a short time, you will be presented with the details of the generated proxy. Click the “Activate” button in the top toolbar.

    • Copy the proxy class name, and go to transaction SE24. Paste the class name there and click the “Display” button in . You can just double-click the class name in proxy details screen above.

    • Find the method with the same name as the outbound service interface. Place the curser on the method name and click the “Parameters” button.

    • Take note of the types of the “output” and “input” parameter fields. These will be needed when creating the test program.

    • Test program:
      • Now, go to transaction SE38 to create the test program. Type a test program name then click the “Create” button.

    • In the “Attributes” screen, enter a short description, select the “Executable” type, and then click the “Save” button.

    • On the next screen, pick a package or assign the program as a local object. Then, click the “Save” button.

    • Write the following program. Note the structure types that we copied from the proxy class. The basic logic of this program is displaying an input zip code field. Then, it will call the proxy method which will return the results in string fields. Those two fields: status and results will be displayed in the output screen. Field “results” contains an XML message in plain-text format. In a more elaborate scenario, you will need to parse the returned XML text to read specific fields.

    • After saving and activating the program, click the “Test” button. Type a zip code then click the “Execute” button.

    • You can see that the status and results fields were read successfully.

This concludes this short SAP-to-REST mini-series. Please do let me know if this was helpful or if I missed something.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo David Gimeno
      David Gimeno

      Nice post!!!

      Do you know if REST adapter is available by default on PI instalations?

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

      It is available in newer releases 7.31 (SP14) and 7.4 (SP9). See this document: New adapter in SAP Process Integration for consumption and provisioning of REST based services.

      Author's profile photo Pavan kumar
      Pavan kumar
      Author's profile photo Jean-Philippe Pain
      Jean-Philippe Pain

      Very useful as I was missing some information for the integration builder !

      Thank you very much.

      Author's profile photo Former Member
      Former Member

      Thank you so much for the excellent post.

      Author's profile photo Samuel Shen
      Samuel Shen

      When I ran the abap program, it dumps. When I try it in WSNAVIGATOR, it is showing any results.

      web service return error. Fault code: "(" fault string: "Server Error"

      I check all my ESR and IB objects and SPROXY, it is the same as yours. Do you know why this error?

      Author's profile photo Samuel Shen
      Samuel Shen

      the REST adapter in the channel monitor shows "not administered". No adapter registered for this channel.

      Author's profile photo Sara Schmidt
      Sara Schmidt

      at first thank you very much for your Engagement! nice blog!
      I'm trying to create the same Scenario in PI 7.50 by calling from SoapUI. i.e. SoapUI <--> PI <--> Google.
      But I get always error in SoapUI:  HTTP 500 Internal Server Error.
      In RWB Message Monitor there is the following error:
      Returning to application. Exception: Error encountered while executing mapping: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_rest_2_sap_; Details:; Cannot create target element /ns0:MT_rest_service_content. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD

      Could anyone help me?

      Thanks a lot in advance!

      Author's profile photo Jon Prow
      Jon Prow



      Make sure you have correct case on your objects.  I had to update  "Status" and "Results" to "status and "results".  After regenerating the sproxy I was getting the desired results.  Hope this helps.



      Author's profile photo Former Member
      Former Member

      Thanks, great information, do you have an example for POST operation?

      Author's profile photo Maxime Tchougoua-Djemen
      Maxime Tchougoua-Djemen

      Amazing work!