on 2019 Sep 10 9:40 AM
Hi, I have 2 SQL-Anywhere DBs, each of them has several Webservices. Is there a way to call the the Webservice on DB1 from within DB2?
Now I can imagine that I can use CURL for this purpose, and then output the Service response in a text file, and then read the response from this text file.
Is there maybe a ready function in Sybase 10?
Thanks in advance
Of course you can, even with v10, and no need to fiddle with calling external tools. See the following doc topic:
Creating web service client functions and procedures
This forum certainly has a bunch of questions dealing with web client functions/procedures.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One more question please.
If I apply the example in the link sent:
CREATE PROCEDURE MyOperation ( a INTEGER, b CHAR(128) )
URL 'HTTP://localhost'
TYPE 'SOAP:DOC';
++++++++++++
CALL MyOperation( 123, 'abc' )
How can I read the output of MyOperation (I need to get the Response of HTTP://localhost).
in other words, I need something like select * from MyOperation( 123, 'abc' ) Here I get error message (MyOperation does not return result set).
Even with the following block I can not solve the problem!
CREATE function MyOperation ( a INTEGER, b CHAR(128) )
returns varchar
URL 'HTTP://localhost'
TYPE 'SOAP:DOC';
+++++++++++++++
select * from MyOperation( 123, 'abc' )
Hm, v11.0.0 has introduced a facility to log web client requests and responses via the -zoc server option and/or sa_server_option settings. I found that very helpful in developping web client procedures.
Nevertheless, the docs certainly do tell the difference between using web client functions vs. procedures based on their different result (sets). When using functions, you get a XML that can be extracted via openxml.
Thanks for the reply, I still have difficulty with OPENXML. The response of my webservice looks like:
<root>
<row updresult="OK"/>
</root>
How can I read the "OK"?
I tried the following without success:
select * from openxml (get_webservices(), '/row') with ("ResultfromSRV" char(5) '@UpdResult')
FWIW, here's a sample:
select * from openxml( '<root> <row updresult="OK"/> </root>', '//row') with (LocalName long varchar '@mp:localname', LocalText long varchar '@mp:xmltext', ResultfromSRV varchar(5) '@updresult')
returns
LocalName,LocalText,ResultfromSRV
row,<row updresult="OK"/>,OK
I suggest to use those meta properties like @mp:xmltext and the like to check whether you are "looking at the rigt nodes" , in your sample the XPath was not fitting as it missed the initial slash, therefore the '//row'.
In additiion to what Volker said, if you get 403 Forbidden when trying to call a service from a client on the same database, try HEADER 'ASA-Id'.
I'm not sure that also applies to different databases on the same SQL Anywhere server, but it might.
Here's a snippet from my Vast Template Collection :)...
CREATE PROCEDURE c ( urlspec LONG VARCHAR ) RESULT ( attribute LONG VARCHAR, value LONG VARCHAR ) URL '!urlspec' HEADER 'ASA-Id' -- avoid same-server error "HTTP request failed. Status code '403 Forbidden'" TYPE 'HTTP:GET';
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.