Reputation: 43
I am trying to create an integration layer through the WSO2 ESB (RESTful API Service Integration).
Endpoint - http://www.thomas-bayer.com/
Context - /sqlrest
and
URI-template - /CUSTOMER/3
( API Endpoint - www.thomas-bayer.com/sqlrest/CUSTOMER/3 )
After everything when I'm trying to invoke the api request with ( http://localhost:8280:/sqlrest/CUSTOMER/3 )
I'm getting the response as full HTML with 404 error code rather than the XML Data.
Upvotes: 1
Views: 724
Reputation: 2153
you can use this API in WSO2 ESB:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="sqlrestAPI"
context="/sqlrest">
<resource methods="GET" protocol="http" uri-template="/CUSTOMER/{id}">
<inSequence>
<log level="full"/>
<send>
<endpoint>
<http method="GET"
uri-template="http://www.thomas-bayer.com/sqlrest/CUSTOMER/{uri.var.id}"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
And call it with (OFFSET = 3 in my case):
curl -v http://localhost:8283/sqlrest/CUSTOMER/3
The response:
* About to connect() to localhost port 8283 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8283 (#0)
> GET /sqlrest/CUSTOMER/3 HTTP/1.1
> User-Agent: curl/7.25.0 (i386-pc-win32) libcurl/7.25.0 OpenSSL/0.9.8u zlib/1.2.6 libssh2/1.4.0
> Host: localhost:8283
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/xml
< Date: Thu, 26 Jan 2017 16:40:08 GMT
< Transfer-Encoding: chunked
<
<?xml version="1.0"?><CUSTOMER xmlns:xlink="http://www.w3.org/1999/xlink">
<ID>3</ID>
<FIRSTNAME>Michael</FIRSTNAME>
<LASTNAME>Clancy</LASTNAME>
<STREET>542 Upland Pl.</STREET>
<CITY>San Francisco</CITY>
</CUSTOMER>* Connection #0 to host localhost left intact
* Closing connection #0
Upvotes: 2
Reputation: 12513
The context you provide does not need to be anything from the actual endpoint URL.
For example, you can define context as myapi
. Then you have 2 options.
Option 1:
Configure endpoint as http://www.thomas-bayer.com/
Then you can call your API as http://localhost:8280/myapi/sqlrest/CUSTOMER/3
Option 2:
Configure endpoint as http://www.thomas-bayer.com/sqlrest/
Then you can call your API as http://localhost:8280/myapi/CUSTOMER/3
Upvotes: 0