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: Post a Request to a Web Service  (Read 33355 times)
Jean G.
Posts: 15


« on: October 28, 2010, 10:47:56 pm »

Hi,

I am new to using web services and xml and I hope someone can help.

I am trying to write a client application that will consume a web service. The first thing I need to do is connect to the service using a url and post a request with the login info in an xml file.

When I run the test program I get the following error message.

ERROR:-15553 (Configuration needed to perform HTTPS connection.)

Below is the test program I wrote and the output from my displays. It is stopping at the CALL req.doTextRequest statement.

IMPORT COM
IMPORT XML

MAIN
   CALL test()
   EXIT PROGRAM
END MAIN

FUNCTION test()
     DEFINE req com.HTTPRequest
     DEFINE resp com.HTTPResponse
     DEFINE doc xml.DomDocument

 TRY
     LET  req = com.HTTPRequest.Create("https://anscert.drfirst.com/getURL")
     DISPLAY "The URL is created."
     --CALL req.setMethod("POST/getURL HTTP/1.0")
     CALL req.setMethod("POST")
     DISPLAY "The Post Method is set."
     CALL req.setCharset("UTF-8")
     CALL req.setKeepConnection(0)
     DISPLAY "The Keep Connection is set."
     CALL req.setTimeOut(120)
     DISPLAY "The Time Out is set."
     CALL req.setMaximumResponseLength(32768)
     DISPLAY "The Max Length is set."

     DISPLAY "Before the doTextRequest Call."
     CALL req.doTextRequest('<?xml version="1.0" encoding="UTF-8"?><RCExtRequest><Caller><VendorName>vendormc9898</VendorName><VendorPassword>accountmc9898</VendorPassword><Application>MM EMR</Application><Version>1</Version><PracticeName>mc9898</PracticeName><Station>Station A</Station></Caller><RcopiaPracticeUsername>mc9898</RcopiaPracticeUsername><Request><Command>get_url</Command></Request></RCExtRequest>')
     DISPLAY "Do text request."
     LET resp = req.getResponse()
     IF resp.getStatusCode() != 200 THEN
        DISPLAY "HTTP Error ("||resp.getStatusCode()||") ",resp.getStatusDescription()
     ELSE
        DISPLAY "HTTP Response is OK."
     END IF
 CATCH
     DISPLAY "ERROR:",STATUS||" ("||SQLCA.SQLERRM||")"
 END TRY
 END FUNCTION

Result:
The URL is created.
The Post Method is set.
The Keep Connection is set.
The Time Out is set.
The Max Length is set.
Before the doTextRequest Call.
ERROR:-15553 (Configuration needed to perform HTTPS connection.)

Thanks,
Jean

.
Four Js
Posts: 65


« Reply #1 on: October 29, 2010, 03:15:45 pm »

Hi Jean,

In fact you don't need to write such code, you just have to use the GWS "fglwsdl" tool to achieve what you want. In your case you will have to do a "fglwsdl" of your wsdl; it will generate a 4gl file which will allow you to access to your services.
I invite you to take a look at GWS documentation and especially at the tutorial to write your GWS client application.

https://4js.com/online_documentation/fjs-gws-2.30.01-manual-html/
https://4js.com/online_documentation/fjs-gws-2.30.01-manual-html/User/WseClientTutorial.html

Otherwise, for this kind of issues I think you can ask to your support center to get help.

Best regards,     
Reuben B.
Four Js
Posts: 1116


« Reply #2 on: November 01, 2010, 02:40:12 am »

Guney,

I'm puzzled by your answer. Isn't the issue to do with the configuration needed for HTTPS instead of HTTP.  In which case I'd look at  https://4js.com/techdocs/genero/gws/devel/DocRoot/User/WseSSLClientTutorial.html in order to create the certificate files and amend FGLPROFILE accordingly

Reuben

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


« Reply #3 on: November 01, 2010, 10:11:45 pm »

They don't have the wsdl files so that is another problem I am facing. I am thinking I will have to create xsd files and use the xml writer and reader to write the functions to do the request and responses.

The error was because I didn't have the certificates created for the client.

Thanks for you help.
Reuben B.
Four Js
Posts: 1116


« Reply #4 on: November 01, 2010, 11:13:04 pm »

Thanks for letting us know.  You are possibly entering the world of RESTful Web Services. http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_web_services

A few years back I took the demo we provide in $FGLDIR/demo/WebServices/calc which is an example using SOAP, and modified it to be REST based.  The source is available here http://code.google.com/p/sourcefourjs/downloads/detail?name=calcrest_1_0.zip .  One day I should take that example and modify it to validate the data in/out using an xsd file using the xml.DomDocument.validate method.

There are quite a REST based Web Services out there.  If you want, have a go at creating a 4gl client to interact with ...

http://code.google.com/apis/maps/documentation/geocoding/index.html
http://developer.yahoo.com/search/web/V1/webSearch.html

I've also got an example somewhere interacting with a REST web service that sends text messages to your phone.

... these can all be interacted with using the low-level methods available in the com and xml libraries.

Reuben

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


« Reply #5 on: November 02, 2010, 08:41:18 pm »

Reuben,

I will take a look at the links you have provided and see if they can help me move forward. I didn't know there was such a thing as RESTful Web Services. I am new to this so I have alot to learn.

Thanks,

Jean
Jean G.
Posts: 15


« Reply #6 on: November 03, 2010, 02:39:22 pm »

Hi Reuben,

I am looking at the client code in calcrest and I see where you are assigning the url string, but I don't recognize the function call SFMT. Can you point me to some documentation?

Thanks,
Jean
.
Four Js
Posts: 115


« Reply #7 on: November 03, 2010, 03:06:42 pm »

Hi Jean,

actually it's more an operator than a function:

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/Operators.html#OP_SFMT

Regards

Sisavanh S.
Four Js
Posts: 80


« Reply #8 on: November 03, 2010, 03:48:03 pm »

Hi Jean,

You have opened a ticket to your local support center.
I've just given them the response.

There are 2 points you were missing:
- doing a "get" request
- the url parameter. Your url should be https://myserver/xxx?xml=mydata

You can achieve this with:
CALL req.doFormEncodedRequest("xml=" || doc.saveToString(),TRUE)

More details in your local support center response.

Many regards,
Sisa.
Jean G.
Posts: 15


« Reply #9 on: November 03, 2010, 04:29:49 pm »

Hi Sisa,

I just discovered this about 10 minutes go, this lets me that I am definitely on the right track.

Thanks,
Jean
Reuben B.
Four Js
Posts: 1116


« Reply #10 on: November 03, 2010, 09:11:03 pm »

Hi Jean,

actually it's more an operator than a function:

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/Operators.html#OP_SFMT

Regards



Pierre-Nicolas,

There is an english saying, "give a man a fish you have feed him for today, teach a man to fish and you have feed him for a lifetime",

Jean,

If you're using the HTML documentation there is an index page https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/SearchIndex.html

If you're using the PDF documentation you can use the search facilities of the PDF reader.

Unfortunately if you are not sure if something is in the FGL, GDC, GAS, Web Services section of the documentation then you may have to repeat that search 4 times.

Fortunately if you are using Genero Studio it comes with all the documentation and you can simply press F1, type the expression into the search field, and it will search across all the documentaton for you.

Finally you'll see that the URL's we use for the documentation normally start https://4js.com/techdocs, that points to the documentation that is being worked on, rather than the documentation for a specific version that you can find here https://4js.com/en/download/documentation.  As all this documentation is on-line, you can also search by entering something like "site:4js.com search-phrase" into Google

As for SFMT, I like to use it rather than cluttering the code with a mess of quotes and commas and trying to figure out what is a string and what is a parameter.  It also helps with localisation where the order of the parameters could be in a different order.

Reuben


Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines