cancel
Showing results for 
Search instead for 
Did you mean: 

PI Axis Receiver channel to consume REST Web service

Former Member
0 Kudos

Hello all.

I'm creating an HTTP scenario like backend->PI->SOAP(AXIS) (synchronous) to consume a rest web service. The goal is to make an HTTP call using method GET (no payload) and the URL must be dynamic. To achieve it I read several links, like:

and it seems to be working fine (the request part).

Using a SICF http service (using like a mock service), I can see that everything is doing fine. This http service, like the real one, returns an xml in the response (not a SOAP envelope).

However, when invoking the real web service, i'm receiving this error:

Exception caught by adapter framework: ; nested exception is:
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x1f) was found in the element content of the document.


I can also test the real scenario using an HTTP requester and it returns an xml, like the one my SICF service returns.


My suspission is that the real webservice is returning a gzip response and this prevents PI from being able to parse the response.


For that I'm, trying to use:

a) AF_Modules/PayloadZipBean to unzip the reponse before parsing

b) set HTTP-Request-Headers{Accept} with "*/*"


Both without success


Regards,

VDO

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi all,

Finally the issue is solved.

The parsing error was related to the fact that the response is gzipped and the default Axis Handler, called "java:com.sap.aii.adapter.axis.ra.transport.http.HTTPSender" used in trp operation, doesn't support it.

The solution was the replace of this handler by another one, that supports it "com.sap.aii.adapter.axis.ra.transport.http.CommonsHTTPSender"

Regards,

VDO

engswee
Active Contributor
0 Kudos

Glad to hear that it's been resolved. Thanks for sharing the final solution, Valter.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Eng,

Yes.

The request header is like:

Accept: */*

Accept-Encoding: gzip, deflate, sdch

The response header is like:

Vary: Accept-Encoding

Content-Encoding: gzip

Transfer-Encoding: chunked

Content-Type: application/xml

The strange thing in the response (in mozilla request I couldn't see like this), is that it is like:
<tag1> <tag2> <... instead of: <tag1><tag2><...

Maybe its the (Unicode: 0x1f) symbol ...

Regards,
VDO

che_eky
Active Contributor
0 Kudos

Not sure what version of PI you are using but from 7.31 SP14 / 7.4 SP09 there is a dedicated REST adapter available. You can also implement REST API calls directly from the ABAP backend system but will need to use JSON parser classes to handle the results.

Che

engswee
Active Contributor
0 Kudos

Hi Valter

I've read up a bit more on your initial error regarding the unicode 0x1F symbol. From the link below, it seems that character is invalid in XML 1.0 (but allowed in XML 1.1)

android - What is character 0x1f? - Stack Overflow

Now, my guess would be that you are actually getting back the same XML response using both Axis channel and HTTP test tool/extension. The test tool does not complain as it does not do anything further with the response. However, the Axis channel is trying to parse the response, and therefore the invalid content in the XML is causing the SAX Parser to raise an exception.

Another useful tool in your debugging would be to have the XPI inspector - details in OSS note 1514898

You can use that to further inspect the HTTP traces.

Rgds

Eng Swee

Former Member
0 Kudos

Thanks for the help.

Regarding the the zip stream. This is not an usual SOAP adapter, I'm using SOAP AXIS adapter. I'm using this module to gzip a message in the previous scenario. But this is not applicable with Axis.

Regarding the accept: "application/xml". It was a good sugestion but it doesn't work,

Regards,

VDO

engswee
Active Contributor
0 Kudos

Did you get to check what the HTTP headers for the request and response look like when you use a test tool or Chrome extension?

engswee
Active Contributor
0 Kudos

Hi Valter

IMHO, for testing REST services, the following extension on Chrome is an indispensable tool.

Advanced REST client - Chrome Web Store

I would suggest that you compare the HTTP request headers being sent to the web service when you test using the Axis adapter vs when you use a test tool.

Maybe when you use the test tool, the "Accept" header is set to application/xml so it returns XML, while gzip could be the default when it is */*, which you specified in you adapter config.

Rgds

Eng Swee

Harish
Active Contributor
0 Kudos

Hi,

Please check the below blog and document which might help

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024...

regards,

Harish