cancel
Showing results for 
Search instead for 
Did you mean: 

PI - HTTP receiver and REST Web service

Former Member
0 Kudos

Hi,

i have customer which is using simple REST webservices. As there are many, we are considering using HTTP adapter, let's say Proxy-to-HTTP scenarios. Customer has some simple web service which expects HTTP GET with parameter in URL or POST with some data in Body of HTTP protocol. Parameter is simple, date and url looks like server.domain.hr/some_path/?date=29.04.2011

With help of prolog(hardcoded) i got following HTTP protocol:

POST / HTTP/1.0
content-type: text/plain; charset=iso-8859-2
content-length: 152
connection: close
accept: */*
user-agent: SAP NetWeaver Application Server (1.0;711)
host: 10.3.64.75:8080
accept-encoding: gzip

&datum=28.04.2011<?xml version="1.0" encoding="iso-8859-2"?>
<ns0:DatumStr_Req xmlns:ns0="urn:xxx.hr:Proxy_to_HTTP">?datum=28.04.2011</ns0:DatumStr_Req>

Customer is claiming that this should work, only not to send XML in body, means only "&datum=28.04.2011" or use

HTTP GET with parameter &datum=28.04.2011.

My question is, is this doobale in SAP PI with help of HTTP and which way is better?

Also, is there any parameter in which can I with help of DynamicConfiguration change Prolog and/OR Epilog?

Also how to send empty message , because then it would work, according to customer.

thx

Edited by: Mario Slopar on Apr 29, 2011 7:15 PM

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Had a scenario that is very similar to yours. But the one that was used for us was that we are connecting to a jsp page that uses rest webservices.

Customer has some simple web service which expects HTTP GET with parameter in URL or POST with some data in Body of HTTP protocol. Parameter is simple, date and url looks like server.domain.hr/some_path/?date=29.04.2011

The get is easier since the parameters are placed in the URL. For POST, what you need to do is to use Java Mapping to generate the HTTP Body (prologpayloadepilog). We did not use the Plain HTTP Adapter because it is not possible to use dynamic values in an HTTP destination. So SOAP Adapter with No SOAP envelope was used.

With regards to sending an empty message, it is possible to send an empty payload but not an empty HTTP Body.

Hope this helps,

Mark

Former Member
0 Kudos

OK, I'll try with SOAP.

Idea sending empty payload is acceptable, but only thing that comes to my mind is to do "some chemistry" with module on com.channel. Is your idea same or some other....

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Not sure what you really meant by chemistry. You need to use dynamic configuration in determining the URL, also take note of the 200 character limit for URLs in SAP XI. The only module we used was the message transform bean for content type transformation, our REST POST requires application/x-www-form-urlencoded content type.

Hope this helps,

Mark

Former Member
0 Kudos

I mean, if I use dynamic configuration, I can not produce empty message, mapping will fail and if I get something in Body, customer says that this is wrong and because of that WS is complaining about date.

Is there any chance to influence on Prolog and Epilog in DynamicConfiguration?

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

I mean, if I use dynamic configuration, I can not produce empty message, mapping will fail and if I get something in Body, customer says that this is wrong and because of that WS is complaining about date.

Yes, there will always be a message produced, that is why you need to use java mapping to remove the message. Now as for the body, this cannot be eliminated as this is required in PI. You might as well return a "" in your HTTP Body.

Is there any chance to influence on Prolog and Epilog in DynamicConfiguration?

In Plain HTTP Adapter, you can hardcode the values for prolog and epilog, but the actual HTTP body for Plain HTTP is prologxmlpayloadepilog.

http://help.sap.com/saphelp_nw70/helpdata/EN/44/79973cc73af456e10000000a114084/content.htm

The same is the case in SOAP, but you can only build the prolog and epilog using java mapping. I think that the value for payload is &loaderXML=<yourpayloadhere>.See thread below:

Hope this helps,

Mark

Former Member
0 Kudos

Not nay step further ....:-((

Is there any chance to do GET in HTTP?

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

HTTP GET is not natively supported in SAP PI 7.1 and below unless you have PI 7.3. To implement a GET/DELETE/PUT, a java proxy is needed. Why don't you try using a POST with the parameters in the URL first (try it with a payload and then without) and let us know how it goes?

Hope this helps,

Mark

Former Member
0 Kudos

Ok, this sound now weird. What I did, I coded small ABAP program on ERP sideto do GET and POST. I switched HTTP trace in SMICM and trrace shows:

When it does GET I receive correct answer, which is fine

GET /_test/test3
.php?datum=03%2e
05%2e2011 HTTP/1
.0..user-agent:
SAP Web Applicat
ion Server (1.0;
701)..host: server.hr..acc
ept-encoding: gz
ip....

for POST, no proper answer, WS is complaining about date

POST /_test/test
3.php HTTP/1.0..
Content-Type: te
xt/xml..Content-
Length: 16..user
-agent: SAP Web
Application Serv
er (1.0;701)..ho
st: server
.hr..accept-enco
ding: gzip....da
tum=03.05.2011

Could it be thath code-page is not correct? I think customer is using iso-8859-2.

parameter datum in body of HTTP post looks like datum=03.05.2011 and for GET datum=03%2e05%2e2011

%2e is EQ to .

in HTTP .. means new-line

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Could it be thath code-page is not correct? I think customer is using iso-8859-2.

parameter datum in body of HTTP post looks like datum=03.05.2011 and for GET datum=03%2e05%2e2011

The difference between the two is that in GET, the parameter is part of the URL, this is also why you are using an escape for some characters e.g %2e = . . Now as for the POST, the parameter should be placed in the HTTP Body (preferably prolog for REST at least). And you need to add & at the starting line, so this should be &datum=03%2e05%2e2011. Also the content-type matters, for POST it is normally application/x-www-form-urlencoded for REST.

Hope this helps,

Mark

Former Member
0 Kudos

BINGO, changed only text/plain with application/x-www-form-urlencoded in method

client->request->set_header_field( EXPORTING name = 'Content-Type' value = 'application/x-www-form-urlencoded' ).

and it works!!!

thx Mark

Former Member
0 Kudos

PI HTTP receiver and ABAP HTTP program are now working...nice

markangelo_dihiansan
Active Contributor
0 Kudos

Glad to help

Answers (0)