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: REST Service not found  (Read 12541 times)
Gary C.
Posts: 109


« on: February 23, 2021, 02:58:50 pm »

Hello

I am trying to create a simple web service that will allow a third party to post data in XML format which I then want to save to file.

However, the returned value from com.WebServiceEngine.ProcessServices is -35: No such REST operation found. I am sure that this is something I must be overlooking but I have stared at the screen for too long and cannot see it!

The URL I am using for testing is of the form:

http://<myserver>/gas/ws/r/docparser/data

Here is the xcf file called docparser.xcf

Code:
<APPLICATION Parent="ws.default" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.4js.com/ns/gas/3.10/cfextws.xsd">
  <RESOURCE Id="res.teqdir" Source="INTERNAL">/opt3/teq</RESOURCE>
  <RESOURCE Id="res.teqdir.bin" Source="INTERNAL">$(res.teqdir)/bin</RESOURCE>
  <EXECUTION>
    <ENVIRONMENT_VARIABLE Id="FGLPROFILE">$(res.teqdir)/etc/fglprofile</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="FGLRESOURCEPATH">$(res.teqdir)/etc</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="FGLDIR">$(res.fgldir)</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="GREDIR">$(res.gredir)</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="PATH">$(res.path)</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="FGLWSNOINFO">true</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="FJS_DBGLEVEL">0</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="FJS_LOGLEVEL">0</ENVIRONMENT_VARIABLE>
    <ENVIRONMENT_VARIABLE Id="FGLWSDEBUG">3</ENVIRONMENT_VARIABLE>

    <PATH>$(res.teqdir.bin)</PATH>
    <MODULE>gwsdocp</MODULE>
    <POOL>
        <START>0</START>
        <MIN_AVAILABLE>0</MIN_AVAILABLE>
        <MAX_AVAILABLE>1</MAX_AVAILABLE>
    </POOL>
  </EXECUTION>
</APPLICATION>

The module gwsdocp.4gl is abridged below:

Code:
import com
import fgl gws_dcp

main

  define ret integer
 
  call com.WebServiceEngine.RegisterRestService("gws_dcp", "docparser")
 
  display "Server started"
  call com.WebServiceEngine.Start()
  while true
    let ret = com.WebServiceEngine.ProcessServices(-1)
    case ret
       when 0
         display "Request processed."
.
.
.
       when -35
         display "No such REST operation found."
       when -36
         display "Missing REST parameter."
       otherwise
         display "Unexpected server error " || ret || "."
         exit while
     end case
     if int_flag <> 0 then
       let int_flag = 0
       exit while
     end if     
  end while
 
  display "Server stopped"
 
end main

The module gws_dcp.4gl holds the test service as below:

Code:
import os
import com
import util

public function getDocumentData(sInput string attribute (WSMedia="application/xml"))
  attributes(WSPost,WSPath="/data")
  returns string attribute(WSMedia="text/plain")
 
    define outputChannel base.channel
   
    let outputChannel = base.channel.create()
    call outputChannel.openFile("/tmp/docparser.xml", "w")
    call outputChannel.writeLine(sInput)
    call outputChannel.close()

    return "OK"
end function

The log shows that the proxy is seeing the inbound request, getting the data but not recognising which service to call:

Code:
POST /gas/ws/r/docparser/data HTTP/1.1
Connection: Keep-Alive
X-Forwarded-Server: gws.alsico.co.uk
X-Forwarded-Host: gws.alsico.co.uk
Content-Length: 2416
Expect: 100-continue
Host: 192.168.20.26
Accept: */*
X-Forwarded-Proto: http
X-Forwarded-For: 34.192.44.113
User-Agent: docparser.com
Content-Type: text/xml
X-FourJs-Environment-Variable-REMOTE_ADDR: 192.168.20.1
X-FourJs-Environment-Variable-SERVER_NAME: 192.168.20.26
<?xml version="1.0" encoding="UTF-8"?>
<documents><document>......</document></documents>

HTTP/1.1 400 No matching Rest operation found

X-FourJs-Web-Service: GWS Server (Build 1560416742)
Date: Tue, 23 Feb 2021 13:50:38 GMT
Content-Length: ???
Content-Encoding: ???

No such REST operation found.

I'm hoping that someone here can point out the error in my approach.

Many thanks.

Gary








Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines