(Migrated) Invoking Zato Service from an external website

(This message has been automatically imported from the retired mailing list)

Hello,

I am trying to invoke a service in Zato from an external website by passing
parameters using GET. The service payload is JSON. I am using JSONP route
to circumvent CORS issue, which would result as the external website isnt
in the same domain.

My payload is on localhost:11223 as given in the tutorial. I am getting an
invalid HTTP destination port error while doing this. I just wanted to
confirm if I can invoke my services on the localhost:11223 and still access
using external websites or do I have to configure Zato before this is
possible.

Error Text :

{“error”:{“lang”:“en-US”,“description”:“Invalid URL
http://localhost:11223/tutorial/first-service: Invalid HTTP
destination port”}}

Thanks.

Regards,
Sharad Tanwar

On 03/04/15 20:58, Sharad Tanwar wrote:

{“error”:{“lang”:“en-US”,“description”:“Invalid URL http://localhost:11223/tutorial/first-service: Invalid HTTP destination port”}}

Hi Sharad,

http://localhost:11223/tutorial/first-service as such is a valid URL and
the error message is not returned by Zato, this must be something in
front of it that produces this message.

Judging by a quick web scan, this is your browser not letting you access
the address, but I don’t understand why, there is nothing wrong with
this URL, it’s a correct one.

hello Dariusz,

The issue was actually because of Yahoo Query Language or YQL. I was using
it to circumvent CORS. Indeed a simple JSONP callback worked beautifully.
The problem is passing parameters to the raw SQL query and getting JSON
back as payload.

Please check the sample code I am using for this.

def handle(self):
###### The below statement is for JSONP callback
#self.response.payload = ‘callback([{“map” : “1”}])’

            ###### URL Request Parameter

qs = parse_qs(self.wsgi_environ[‘QUERY_STRING’])

varqs = qs[‘name’]
self.logger.info(varqs)

template = ‘select name,address from sample_table where name="’ +
str(varqs[0]) +’"’

with closing(self.outgoing.sql.get(‘LCCCD’).session()) as session:

result = session.execute(template).fetchall()
self.logger.info(“this is the result”)
self.response.payload = 'this is the payload’
for index in result:
#self.logger.info(str(index))
payloadoutput = str(payload) + str(index) + ‘\n’

self.response.payload = payloadoutput

The output of the raw SQL is as (‘Sharad’,‘Chicago’) and the corresponding
lines from the output. I was just wondering if there would be an easier way
to get data JSON or do I have to parse it by creating JSON output manually.

Thanks.

Regards,
Sharad

On Fri, Apr 3, 2015 at 2:50 PM, Dariusz Suchojad dsuch@zato.io wrote:

On 03/04/15 20:58, Sharad Tanwar wrote:

{“error”:{“lang”:“en-US”,“description”:“Invalid URL
http://localhost:11223/tutorial/first-service: Invalid HTTP destination
port”}}

Hi Sharad,

http://localhost:11223/tutorial/first-service as such is a valid URL and
the error message is not returned by Zato, this must be something in
front of it that produces this message.

Judging by a quick web scan, this is your browser not letting you access
the address, but I don’t understand why, there is nothing wrong with
this URL, it’s a correct one.


Dariusz Suchojad

https://zato.io
ESB, SOA, REST, APIs and Cloud Integrations in Python