Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hello!

I need to query an external webservice to get a value, how can I do this? thank you!

DRauber

asked 29 Jan '16, 08:13

DRauber's gravatar image

DRauber
226121521
accept rate: 0%


You can create a procedure that contains a URL. Calling the procedure returns a result set that contains the information returned from the web service. Here's an example:

create procedure consume_service() url 'http://example.com/service' type 'http:get';
select * from consume_service() with (attribute long varchar, value long varchar);

The result set contains:

  • a row with Attribute='Status'; value contains the HTTP status (eg. HTTP/1.1 200 OK)
  • a row with Attribute='Body'; value contains the body of the response
  • one row for each HTTP header sent by the HTTP server where Attribute=the header type and Value=the value of the header

There are options for using HTTPS instead of HTTP, using a proxy server, using SOAP, providing parameters, etc. The v17 documentation for this version of the CREATE PROCEDURE statement is here.

permanent link

answered 29 Jan '16, 08:33

Graeme%20Perrow's gravatar image

Graeme Perrow
9.6k379124
accept rate: 54%

edited 29 Jan '16, 10:13

Assuming by external you mean external to the database server, then, the SQL Anywhere database server can consume web content and services.

With SQL Anywhere you can create "Web Service" procedures and functions that can request content from an external webservice that you have rights/permissons to. This can be either an HTTP or SOAP request. The take on a variation of the {CREATE|ALTER} {FUNCTION|PROCEDURE} statements which show up in the index as "CREATE .... [Web service]" entries.

After the request is satisfied you can also access that information using many XML- (OpenXML), HTTP-, and HTML-aware functions as we as the stable of normal functions available in the database to parse and extract the specific informaion you want.

You will have to check for this on DCX a little later (currently, and temporarily, unavailable). Alternatively you can always just install the documentation locally and refer to that as well.

The above is the most direct way of doing that. You may also want to familiarize yourself with our "external enviroments" (PHP, PERL, JAVA, CLR, ...) which might open up other approaches or allow for more involved web requests or non-standard content.

HTH

permanent link

answered 29 Jan '16, 08:53

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 32%

Thank you! I received http://deltainfws.com:8080/dltadm/DltAdmService?Tester URL to test the operation. I need to pass three arguments and get the answer a string. If they want to see details, can pass the arguments: 03703992000101 SICONFI 20160129A

As you can see, it is a request / response SOAP

How i can create function to get this?

Thanks

(29 Jan '16, 10:14) DRauber
1

You can directly use a complex SOAP Service out of the database but in real life, it is definitely more complicated than just specifiying the web procedure call. Basically, it involves building a soap request envelope, sending it to a "raw" web procedure call" and then parse the returned envelope. We have successfully done that a lot of times but as I said, it's nothing you describe in a minute. DRauber, you are not Germany-based, are you?

(10 Feb '16, 09:28) Michael Fischer
Replies hidden

While I would certainly agree that it's usually more complicated "in real life", the mentioned SOAP service consisting of a request with three simple arguments and a string as response seems not too complex, IMHO, and could be handled without the need to build the SOAP envelope in code...

You might have a look at the "soap.globalweather.sql" and "soap.gov.weather.sql" samples in the SQL Anywhere HTTP samples directory.

(10 Feb '16, 09:58) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×66

question asked: 29 Jan '16, 08:13

question was seen: 2,324 times

last updated: 10 Feb '16, 09:59