Skip to Content
avatar image
Former Member

Using PI with RESTful service returning plain text response

We're faced with a couple of integration patterns that have plain text (and in other case JSON) synchronous responses. Since PI seems to require xml in the message payload, we are facing a challenge with the implementation of these scenarios in PI.

Req: ABAP PROXY -> PI -> RESTful service

Response: RESTful service -> PI -> ABAP Proxy

We can successfully call the service using http adapter, but when the response is a plain text string and not xml, we are facing a challenge with using PI in thi scenario.

Surely there is a solution for this problem and we are not the first to have encountered it. We are using 7.1.

Appreciate any and all suggestions!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 08, 2012 at 07:33 AM

    Hi Jereme,

    Is the structure of your plain text data a complex one, with multiple record types and so on? If yes, then go for the Java mapping that Mark suggested. But if not, then you can try using graphical mapping:

    - with the substring() function - if your plain text has no separators, just fixed field lengths;

    - with a simple UDF function below, in case your plain text data has separators;

    String[] results = input.split(";");
    return results[sequence];

    Assuming that you have two input parameters: "input" for input text data and "sequence" for the sequential number of the particular field you want to get, this function will return contents of that particular field of the plain text.

    Hope this helps,

    Greg

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Mark Dihiansan

      Hi Mark,

      I have similar query. Can you please provide a java mapping code to resolve this issue as i am new to SAP PI.

      The response will be plain text like: "The survey has been completed successfully" coming from the vendor which is not supported in PI.

      Please guide 😔

  • Feb 08, 2012 at 06:45 AM

    Hello,

    We can successfully call the service using http adapter, but when the response is a plain text string and not xml, we are facing a challenge with using PI in thi scenario.

    You can use Java Mapping to parse the response message and transform it into your desired xml format (using DOM or SAX), here is a sample API

    http://wiki.sdn.sap.com/wiki/display/XI/UsingPI7.1APIforJavamapping

    1. The key is to read the inputstream payload

    2. Transform/parse the payload

    3. Write to outputstream

    Hope this helps,

    Mark

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 05, 2013 at 04:22 AM

    Hello Jereme,

    I've a similar requirement and trying to perform HTTP GET thorugh PI 7.31 HTTP Java adapter, My target URL looks like

    https://abc.com/api?filterFields=<FilterFields><FilterField><Id>26</Id><Value>1/1/2013,12/31/2013</Value></FilterField></FilterFields>

    I've configured my HTTP receiver adapter (Java) as below

    Addressing mode - URL address

    Target Host - https:abc.com

    Target port: 8080

    Path - /api

    Where should I mention the query path - ?filterFields=<FilterFields><FilterField><Id>26</Id><Value>1/1/2013,12/31/2013</Value></FilterField></FilterFields>

    Actually values inside the tag Value is dynamic and will be populated in message mapping,

    What should be the value of Main Payload Parameter Name in the adapter?

    Thanks in advance for your help.

    Add comment
    10|10000 characters needed characters exceeded

    • Yes, I've tested it from google chrome dev client and from a standalone java program. The url is working fine. I'm just wondering what could be wrong with my configuration for static url.