NetTalk Central

Author Topic: REST with NT  (Read 5871 times)

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
REST with NT
« on: October 23, 2014, 04:39:18 AM »
Hi, somebody use Rest with nettalk?

http://www.restapitutorial.com/lessons/whatisrest.html

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: REST with NT
« Reply #1 on: October 23, 2014, 06:58:18 AM »
yes, it's possible to do REST with NetTalk.
Are you wanting to create a client or a server?

cheers
Bruce

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: REST with NT
« Reply #2 on: October 23, 2014, 07:33:33 AM »
About REST, and SOAP, may I ask some question about these features in NT, because I have some issues ...
Or post another post in forum?
Regards, Oggy

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: REST with NT
« Reply #3 on: October 23, 2014, 09:45:45 AM »
Bruce, both i have a customer that required read data from this services

http://www.satasgis.crimpr.net/crimgis/rest/services/Mapas

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: REST with NT
« Reply #4 on: October 23, 2014, 09:41:52 PM »
Hi Oggy,

Probably a good starting point is to catch up on a few webinars. They provide a basic understanding and will help you get going. After that if you have specific questions you can ask anywhere on these forums.
A sub-set of the ClarionLive webinar list is here;
http://www.capesoft.com/webinars.htm

>> I have a customer that required read data from this services

This would imply that a client is your first priority. A good primer for this is webinar #48.

On the server side, there was quite a lot of stuff added in NetTalk 8. If nothing else this will help you understand what the server side is doing. A good priming webinar for this is #255.

During the User Group Webinars Web Services have come up a few times.
http://www.capesoft.com/accessories/NetTalkUserGroup.htm
#12 is a good one, with a bit of follow-up in #13.

At some point I'll be doing an update on the client side, but that's a little bit down the road.

Cheers
Bruce





oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: REST with NT
« Reply #5 on: October 23, 2014, 10:22:11 PM »
Ok, thanks for reply, but my problem, as always for me :), its not the usual one..
I used Nettalk example num 42, (SoapServer). This works fine. I can start the server and send request as is in example.
Ok, next point: I add another app, plain window, purpose just for testing. From that new window I want to call external procedure where is my SOAP request procedure (client app from example), with some parameter(s). Ok, parameters goes from window to soap-request procedure, and SOAP XML is creates as usually. But, whet its come to POST and SEND request to server, problem started. Here is my routine to post request:

SendPost            routine
  PostURL = 'http://' & clip(loc:url) & '/getInfo'
  ThisWebClient.SetAllHeadersDefault()
  ThisWebClient.Pragma_ = 'No-Cache'                
  ThisWebClient.CacheControl = 'No-Cache'        
  ThisWebClient.ContentType = 'text/xml'              
  ThisWebClient.AcceptEncoding = ''                  
  ThisWebClient.ContentLength = len(clip(PostString)) !
  ThisWebClient.AsyncOpenTimeOut = 1200            
  ThisWebClient.InActiveTimeout  = 2000            
  ThisWebClient.Post(PostURL,PostString)
    ! Return some value if all goes well
    if ID_Korisnika <> 0 and Rezultat.ErrorCode = 0
        Return(ID_Korisnika)                           ! Returning with some ID, thats what I wan
    ELSE
        Return(ID_Korisnika)                           ! Returning with zero ID        
    END
First error is: -60, which means connection was not open (see attachment 1)
Ok, I resolve this error calling manually  ThisWebClient.Init(NET:SimpleClient) procedure.
Now this error gone, but another problem is that ThisWebClient.Post(PostURL,PostString), procedure never open, instead of that, ThisWebClient.Destruct procedure fired?!?. Nor ThisWebClient.Send procedure never ever came in focus. When I manually call these procedures (Send for example), another error "connection not open" appear...
What Im doing wrong?!?
Sorry for such large post...
Oggy



[attachment deleted by admin]
« Last Edit: October 23, 2014, 10:30:46 PM by oggy »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: REST with NT
« Reply #6 on: October 23, 2014, 10:39:39 PM »
this part is wrong;

    ThisWebClient.Post(PostURL,PostString)
    ! Return some value if all goes well
    if ID_Korisnika <> 0 and Rezultat.ErrorCode = 0
        Return(ID_Korisnika)                           ! Returning with some ID, thats what I wan
    ELSE
        Return(ID_Korisnika)                           ! Returning with zero ID       
    END

the POST is asynchronous, meaning that you can't test for a result, or do a RETURN immediately after the call. Rather the post will be made (in the background) and the result will come out through either the .ErrorTrap method, or the .PageReceived method.

So what you need to do is do the Post, and then add code to PageReceived (parsing the result you got back in .Page property) and add code to .ErrorTrap to handle an error.

Of course being asynchronous, ie Event driven, it needs a window structure. So it needs to be based on a Window template, not a source code template. But you can always make the procedure completely "hands-free" if you like, and hide the window as well, so the window itself is invisible.

cheers
Bruce

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: REST with NT
« Reply #7 on: October 23, 2014, 10:46:38 PM »
We do not understand, the problem is not in:
   
    if ID_Korisnika <> 0 and Rezultat.ErrorCode = 0
        Return(ID_Korisnika)                           ! Returning with some ID
    ELSE
        Return(ID_Korisnika)                           ! Returning with zero ID         
    END
it is just for returning some results, but.... As you can see, the ThisWebClient.Post(PostURL,PostString) IS in the code, but Post procedure in class never ever open, I put some messages in embed of Post procedure, but these messages do not flash before me ;)
Second , nor the PageReceived ever opened. never...

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: REST with NT
« Reply #8 on: October 23, 2014, 10:48:43 PM »
Hm, that means, my source is not possible, I must have some event on to goes from one procedure to another !?!?
Thats sound Ok...

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: REST with NT
« Reply #9 on: October 24, 2014, 12:41:24 AM »
Ok, solved as suggested. Now, another one  :D
Where is, if exists, parameter, or timer for ErrorTrap procedure? I want to variable calliing this procedure.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: REST with NT
« Reply #10 on: October 30, 2014, 01:16:30 AM »
post new questions on a new thread.