How to test HandleSpecialURL

Hi Guys,

Im currently starting to working out webservices and it seems HandleSpecialURL is the approach. I saw sample use of it but I dont know how to test it.
May question is, how can I test HandleSpecialURL using web browser.

Just run the second example at http://documentation.xojo.com/index.php/WebApplication.HandleSpecialURL

Run and from a new tab point to http://127.0.0.1:8080/API/

It will show you the sample page.

Thanks Michel,

I’m new to xojo webservices and the reference you provided is I believed for those people who are already familiar with it (I had a hard time to understand it).

I just want to know how to test my newly created HandleSpecialURL using web browser.

Run your app, copy the url from your browser to a new tab and add / to the end and go.

Hi Wayne,

I set breakpoint in the first line of HandleSpecialURL event so that I can check if it works.

I run my xojo web thru IDE, and from http://127.0.0.1:8080/ I typed additonal information same as below:

after pressing ENTER, it does not stopped at my break point. It seems it does not recognize what I typed in the URL?’

Actually, my page show “The requested URL “/GetAllCustomers” could not be found. Please check your request and try again.”

Please enlighten me.

If it is a Special URL, then the URL should be http://127.0.0.1:8080/index.cgi/special/getcustomers

Do check for the case as Unix based OS are pretty picky when it comes to character cases.

Hi Edwin,

I tried to use your URL but it responded

"The requested URL “/index.cgi/special/getcustomers” could not be found. Please check your request and try again.’

Any idea?

I think you might be confusing handlespecialurl and handleurl. Unless you are using /api or /special your connection will be routed to the handleurl event.

Place this code in the handleurl event handler

[code]If Request.Path = “” Then Return

Break[/code]

Run your app and copy the url from your browser to a new tab and add /getcustomers.

Hi Wayne,

handleurl is no problem. It function well. I placed breakpoint on it, and it trigger there.

My concern is how to test the HandleSpecialURL using web browser.

[quote=294500:@ronaldo florendo]I’m new to xojo webservices and the reference you provided is I believed for those people who are already familiar with it (I had a hard time to understand it).

I just want to know how to test my newly created HandleSpecialURL using web browser.[/quote]

Please post your code in HandleSpecialURL

@ronaldo florendo : It could be that your HandleSpecialURL handler isn’t returning TRUE, in which case Xojo acts as if the request wasn’t valid, and it returns a 404 response as a result.

Also, if you would like to see an example of a Web API developed using Xojo, you might want to check out Luna. It’s an open source, Xojo-based framework for creating RESTful APIs. It uses “HandleURL” instead of “HandleSpecialURL,” but you could change that if you’d like.

I hope this helps.

Hi Wayne,

Here is my copied code from somewhere. I didn’t modify anything from the source, I just want to check why HandleSpecialURL breakpoint is not triggered.

[quote] Dim data As Text = DefineEncoding(Request.Entity, Encodings.UTF8).ToText
Dim json As JSONItem

Select Case Request.Path
Case “GetAllCustomers”
json = GetAllCustomers

Case “GetCustomer”
json = GetCustomer(data)

Case “UpdateCustomer”
json = UpdateCustomer(data)

Case Else
// Do not process request
Return False
End Select

// Send back data
Request.Print(json.ToString)

Return True[/quote]

What is the url that you are using when debugging?

Hi Wayne,

“What is the url that you are using when debugging?”

Actually, that is my question in this thread. How to test it because I don’ t know if possible to test it in web browser.
I hope you can show me what to type in web browser so that I can test.

Response three hours ago :

[quote=294497:@Michel Bujardet]Run and from a new tab point to http://127.0.0.1:8080/API/
[/quote]

That said, as you code shows, the browser won’t receive anything. So all that will do is run the code in HandleSpecialURL.

If you want to display something in the browser, use Request.Print.

Hi Michel,

There you are! “/API” solved my inquiry.

Still wondering, where “API” comes from? I didn’t see it in anywhere in the code.

Please enlighten me.

http://documentation.xojo.com/index.php/WebApplication.HandleSpecialURL

Hi Norman,

Now I understand what the document is telling.

Thanks to Michel and for everybody.

And again, Ronaldo, that link to the LR reposted by Norman was in the very first response to your query. You must learn how to read what is posted for you. There is a proverb in the Silicon Valley : RTFM.

Hi Michel,

I already read the documentation. But as beginner like me, I can’t understand it yet. I feltl that the documentation assume that the reader has already basic knowledge about this protocols. Which I am not.
Until you provided me the sample URL which I tried to test.
That’s the only time I got the content of the documentation.

Thanks Michel for assisting.