cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SA 17.0.10.5866: Can't call my Web service, error “403 Forbidden”

Stalker4
Explorer
0 Kudos
462

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
 

Accepted Solutions (1)

Accepted Solutions (1)

PCollins
Participant

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.

Using the Database Server as a Web Client | SAP Help Portal

VolkerBarth
Contributor
0 Kudos
Ah, I forgot about that limitation... - but basically, why would you need to use a web request to access data from the same database. 🙂
Stalker4
Explorer
0 Kudos

2VolkerBarth: I needed this for testing my web services. It is easier with one database (server) than with two.

Answers (1)

Answers (1)

VolkerBarth
Contributor
0 Kudos

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.

Stalker4
Explorer
0 Kudos

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”:

 

Spoiler
[23/09/2024:11:47:39.620 0300] - 0.001 - 127.0.0.1:49962 - 8050 - "POST /WebComplain/wsWebTest1 HTTP/1.1" - 200 OK - 242 -
--> @HttpURI: /WebComplain/wsWebTest1
--> Accept: */*
--> @HttpVersion: HTTP/1.1
--> Host: 127.0.0.1:8050
--> Cache-Control: no-cache
--> Content-Length: 0
--> User-Agent: PostmanRuntime/7.42.0
--> Postman-Token: 11f8f8fe-8a91-46e9-b4a8-d88db4f33451
--> Accept-Encoding: gzip, deflate, br
--> Connection: keep-alive
--> @HttpMethod: POST
<-- Connection: Keep-Alive
<-- Expires: Mon, 23 Sep 2024 08:47:39 GMT
<-- Content-Type: text/plain; charset=windows-1251
<-- Date: Mon, 23 Sep 2024 08:47:39 GMT
<-- Server: SQLAnywhere/17.0.10.5866
<-- Transfer-Encoding: chunked

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”:

 

Spoiler

 [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

Spoiler

[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.