2024 Sep 22 12:46 PM - edited 2024 Sep 23 10:11 AM
Hi,
On the server “SQL Anywhere Network Server Version 17.0.10.5866” MyBase.db” database is running.
I create the following code in it:
CREATE PROCEDURE "dba"."WebTest1"()
RESULT( cReturn long varchar )
BEGIN
select 'ok';
END
go
GRANT EXECUTE ON "dba"."WebTest1" TO "PUBLIC";
CREATE SERVICE "wsWebTest1" TYPE 'RAW' AUTHORIZATION OFF
USER "PUBLIC" METHODS 'HEAD,POST'
AS call "dba"."WebTest1"();
CREATE PROCEDURE "dba"."WebTest1Run"( in "nCustomerID" integer,in "cResultText" char(250) )
result( "cAttribute" long varchar,"cValue" long varchar,"npp" integer )
url 'url 'http://127.0.0.1:8050/WebComplain/wsWebTest1''
type 'HTTP:POST';
I call the web service “wsWebTest1” from “Postman v10.23”. it returns the string “ok” as expected.
I call the same web service from ISQL:
select * from dba.WebTest1Run(1, 'test')
or
call dba.WebTest1Run(1, 'test')
I'm getting an error:
HTTP request failure. Status code '403 Forbidden'
SQLCODE=-983, ODBC 3 State="HY000"
Question: What am I doing wrong ?
How do I call my web service from ISQL
Request clarification before answering.
A web client procedure cannot make an outbound HTTP request to itself; it cannot call a SQL Anywhere web service running on the same database. In the following steps, you create a new database, start a second database server, and connect to the new database.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't comment on the exact error message.
However, to understand and check web requests and responses, particularly for newly embedded web services, we usually have to turn on "Web client logging debugging" temporarily, as described here.
FWIW, the usage of this feature via "dbsrvX -zoc MyWebClientLog.txt" or
call sa_server_option('WebClientLogFile', 'MyWebClientLog.txt');
call sa_server_option('WebClientLogging', 'On');
has not changed for newer versions.
You can also log the web service's requests via the LOG network protocol option and its variants.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Run server:
dbsrv17.exe @lconfig_base.txt
lconfig_base.txt
-dt C:\TEMP
-n MyServer
-x tcpip(MyIP=127.0.0.1;DoBroadCast=No)
-xs http(MyIP=127.0.0.1;Port=8050;LOPT=ALL,HEADERS;LOG=WebAccsess.log)
WebComplain.db -n WebComplain
executed the code as you wrote
call sa_server_option('WebClientLogFile', 'MyWebClientLog.txt');
call sa_server_option('WebClientLogging', 'On');
As I wrote earlier, when calling the web service from “Postman” everything is called without errors, below is the log (WebAccsess.log) of calling the web service from “Postman”:
When calling the same Web service from “ISQL” (via the WebTest1Run procedure), a “403 Forbidden” error occurs. Below is the WebAccsess.log when calling from “ISQL”:
[23/09/2024:11:48:24.369 0300] - 0.000 - 127.0.0.1:49966 - 8050 - "POST /WebComplain/wsWebTest1 HTTP/1.0" - 403 Forbidden - 397 -
--> Content-Type: application/x-www-form-urlencoded; charset=windows-1251
--> Accept-Charset: windows-1251, UTF-8, *
--> Connection: close
--> ASA-Id: 4882e4c1a79f42d8b617f1d162eafbda
--> Host: 127.0.0.1:8050
--> @MediaType: application/x-www-form-urlencoded
--> Content-Length: 30
--> User-Agent: SQLAnywhere/17.0.10.5866
--> Date: Mon, 23 Sep 2024 08:48:24 GMT
<-- Connection: close
<-- Content-Type: text/html; charset=ISO-8859-1
<-- Expires: Mon, 23 Sep 2024 08:48:24 GMT
<-- Date: Mon, 23 Sep 2024 08:48:24 GMT
<-- Server: SQLAnywhere/17.0.10.5866
File MyWebClientLog.txt
[connid = 14, [23/09/2024:11:48:24.366 0300]]
[connid = 14, [23/09/2024:11:48:24.366 0300], REQUEST]
POST /WebComplain/wsWebTest1 HTTP/1.0
Connection: close
Host: 127.0.0.1:8050
Content-Type: application/x-www-form-urlencoded; charset=windows-1251
ASA-Id: 4882e4c1a79f42d8b617f1d162eafbda
User-Agent: SQLAnywhere/17.0.10.5866
Date: Mon, 23 Sep 2024 08:48:24 GMT
Accept-Charset: windows-1251, UTF-8, *
Content-Length: 30
nCustomerID=1&cResultText=test
[connid = 14, [23/09/2024:11:48:24.374 0300], RESPONSE]
HTTP/1.1 403 Forbidden
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Expires: Mon, 23 Sep 2024 08:48:24 GMT
Date: Mon, 23 Sep 2024 08:48:24 GMT
Server: SQLAnywhere/17.0.10.5866
<!doctype html public "-//IETF//DTD HTML 2.0//EN">
<html><head><title>403 Forbidden</title></head>
<body><h1>
403 Forbidden
</h1><hr><address>SQLAnywhere/17.0.10.5866</address></body></html>
[connid = 14, Protocol Error]
[connid = 14, socket closed]
It seems to me that the error in WebTest1Run, something I do it wrong, because from Postman everything is called normally, with an error is called only from the procedure WebTest1Run.
User | Count |
---|---|
40 | |
15 | |
10 | |
9 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.