Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Help needed with RestFull  (Read 9281 times)
Benjamin G.
Posts: 130


« on: June 15, 2022, 09:32:00 pm »

Hi,

I 've a Restful webservice that perfectly worked. Sinds yesterday i always receive a HTTP Error 400 and i don't know why

Here is my curl :

curl http://127.0.0.1:8091/ws/r/webshopv2/v1/gab1 -v -H 'Content-Type: application/json' -d '{"locale":"fr"}'

* Expire in 0 ms for 6 (transfer 0x5589e17759a0)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x5589e17759a0)
* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0)
> POST /ws/r/webshopv2/v1/gab1 HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 15
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 400 Content-type not */xml
< Server: GWS Server (Build 202204201231)
< Connection: close
< Date: Wed, 15 Jun 2022 19:22:14 GMT
< Content-Length: 0
<
* Closing connection 0

Console Debug :
WS-DEBUG (Security Info)
OpenSSL 1.1.1n  15 Mar 2022
WS-DEBUG END

WS-DEBUG (Security Warning)
Crypto library doesn't have any ZLIB compression algorithm.
WS-DEBUG END

WS-DEBUG (Security Warning)
SSL library wasn't compiled with support of RLE compression.
SSL library wasn't able to initiate the ZLIB compression library.
WS-DEBUG END

WS-INFO (Certificate authority) | Loading from directory /opt/fourjs_401_00/fgl/web_utilities/certs | Loading from directory /etc/ssl/certs | Loading from directory /usr/lib/ssl/certs

WS-DEBUG (Receive)
POST /ws/r/webshopv2/v1/gab1 HTTP/1.1
WS-DEBUG END


WS-DEBUG (Receive)
Host: 127.0.0.1:8091
User-Agent: curl/7.64.0
Accept: */*
Content-Type: application/json
Content-Length: 15

WS-DEBUG END


WS-DEBUG (Send)
HTTP/1.1 400 Content-type not */xml
WS-DEBUG END


WS-DEBUG (Send)
Server: GWS Server (Build 202204201231)
Connection: close
Date: Wed, 15 Jun 2022 19:22:14 GMT
Content-Length: ???
Content-Encoding: ???

WS-DEBUG END


And here is my code :

PUBLIC FUNCTION benjamin(jsnGab t_jsnGab ATTRIBUTES (WSMedia = 'application/json'))
               ATTRIBUTES(WSPost
                         ,WSPath = "/v1/gab"
                         ,WSDescription = "Test"
                         ,WSRetCode = "201:Ok"
                         ,WSThrows = "400:Bad Request,500:Internal Server Error")
    RETURNS(STRING ATTRIBUTES(WSMedia = 'application/json'))

    RETURN jsnGab.codlng
END FUNCTION


Any help would be appreciated ...

Thanks in advance


Benjamin G.
Posts: 130


« Reply #1 on: June 16, 2022, 09:42:26 am »

Hi,

After digging it seems that my problem come from the path :

    curl http://127.0.0.1:8091/ws/r/webshopv2/v1/gab -v -H 'Content-Type: application/json' -d '{"locale":"fr"}'

When i start the program outside "studio" (fglrun ...) if i run  curl http://127.0.0.1:8091/webshopv2/v1/gab -v -H 'Content-Type: application/json' -d '{"locale":"fr"}' i get a response

Which path must be used when my webservice server is running from studio ?

    curl http://127.0.0.1:8091/.........../webshopv2/v1/gab -v -H 'Content-Type: application/json' -d '{"locale":"fr"}'

Thanks
Sisavanh S.
Four Js
Posts: 80


« Reply #2 on: June 16, 2022, 11:32:25 am »

Hi,

I was about to reply to you then you solved the path issue.
About running the application from GST.
It depends on how you set up your project.
I guess, you are testing in direct connection to the DVM and your service is webshopv2.
So your url should be ok
http://127.0.0.1:8091/ws/r/webshopv2/v1/gab
With or without /ws/r.

If you get any issues, please contact your local support center.

Regards,
Sisa.
Benjamin G.
Posts: 130


« Reply #3 on: June 16, 2022, 11:41:29 am »

Thank you for replying but is not working with or without ws/r
I've attached my test program ...
If i run manually "fglrun wbsserver" works fine but thru GST/GAS (Httpdispatch) i always receive error 400
There is something that i'm not understand

root@vmgenerodev02:/prov/gab/excel# curl http://127.0.0.1:8091/wbstst/benjamin -v -H 'Content-Type: application/json' -d '{"locale":"fr"}'
* Expire in 0 ms for 6 (transfer 0x55fcae6819a0)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55fcae6819a0)
* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0)
> POST /wbstst/benjamin HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 15
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 400 Content-type not */xml
< Server: GWS Server (Build 202204201231)
< Connection: close
< Date: Thu, 16 Jun 2022 09:36:47 GMT
< Content-Length: 0
<
* Closing connection 0
root@vmgenerodev02:/prov/gab/excel# curl http://127.0.0.1:8091/ws/r/wbstst/benjamin -v -H 'Content-Type: application/json' -d '{"locale":"fr"}'
* Expire in 0 ms for 6 (transfer 0x556f40f999a0)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x556f40f999a0)
* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0)
> POST /ws/r/wbstst/benjamin HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 15
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 400 Content-type not */xml
< Server: GWS Server (Build 202204201231)
< Connection: close
< Date: Thu, 16 Jun 2022 09:37:07 GMT
< Content-Length: 0
<
* Closing connection 0
root@vmgenerodev02:/prov/gab/excel#



* wbssrv.4gl (2.49 KB - downloaded 1159 times.)
Reuben B.
Four Js
Posts: 1116


« Reply #4 on: June 20, 2022, 06:12:40 am »

I think the piece of the puzzle may depend on how you have configured Studio.  The URL you require is likely to be of this pattern ...

http://localhost:8090/MODULE/PATH
http://localhost:6394/ws/r/XCF/MODULE/PATH


where
PATH is what is specified by WSPath attribute in your code
MODULE is what is specified as second argument of RegisterRestService call
XCF is name of xcf file which is most likely your program name if generated automatically by Studio

localhost is address, could be 127.0.0.1
6394/8090 are default port numbers respectively (I note you are using 8091 so you may have changed)


When you run from the command line i.e fglrun wbsserver, then you would use url of form http://localhost:8090/MODULE/PATH.  I think as Sisa said the search algorithm used maybe relaxed and allow /ws/r in the URL

From Studio, you can start something similar with a configuration that has Display="None" for the front end client and sets FGLAPPSERVER in the environment. 

In Studio what you can also do is use a configuration that has use Display = Application Server checked for the front end client.  Then also in the Configuration properties, check Web Service
checkbox.  Now when you execute the program, a .xcf is generated in $FGLASDIR/appdata/services/.  Then when you specify a URL such as http://localhost:6394/ws/r/XCF/MODULE/PATH to come in via httpdispatch then it needs what it can find in the xcf to see what program to start.  (Note this xcf is not what you would copy and deploy to production as it uses gsproxy so that program can be debugged)

When using GAS and the dispatcher the ws/r is important as it helps  seperate the request out from the other requests that the GAS will be processing, such as /ua/r for Web application plus images, file transfers etc which have a different uri.

You say "but thru GST/GAS (Httpdispatch) i always receive error 400", but the URL you are using " http://127.0.0.1:8091/wbstst/benjamin" /  http://127.0.0.1:8091/ws/r/wbstst/benjamin with 8091 is the format for not using GST/GAS.    What you could be finding is a different web service program that is listening on port 8091 and is expecting xml, hence the error.     If you have compiled and run 'thru GST/GAS (httpdispatch) then I would expect port number to be 6394 (the default) or close to it, and the xcf to form part of the URL

Hope that helps,

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Benjamin G.
Posts: 130


« Reply #5 on: June 20, 2022, 10:52:19 am »

Hello,

Indeed configuring studio with "no display" was the solution.

Thank you.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines