# RESTful Web Service - How To???

**URL:** <https://forum.servoy.com/t/restful-web-service-how-to/11509>\
**Category:** Classic Servoy\
**Created:** [December 14, 2009, 10:50am UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509 "2009-12-14T10:50:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kahuna](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@Kahuna](https://forum.servoy.com/u/Kahuna)\
**Post date:** [December 14, 2009, 10:50am UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/1 "2009-12-14T10:50:30Z")

</div>

Hi Folks - we saw a demo at Servoy Camp of using Servoy 5 to make RESTful web services, but it was pretty quick and I did’nt get too many notes and what I did get I’m struggling to make sense of ![:?]( "Confused") (I seem to recall a discussion that the Camp video would make it all clear LOL but that was after the bar opened so I may have hallucinated it ![:lol:]( "Laughing") ).

Are there any step-by-step guides available to implement this plugin (which Plugin is it)?

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [December 14, 2009, 11:07am UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/2 "2009-12-14T11:07:55Z")

</div>

Hi Ian,

it’s not a plugin like ‘the others’. This is what I got from the wiki pages:

> Added a REST webservice plugin, which makes it possible to expose (form) methods as REST API handlers:
> 
> - The REST API is accessible through the url: ```  
> [http://domain](http://domain):port/servoy-service/rest\_ws/solutionName/formName
> 
> ```auto
> * The form needs to have the following methods:
> o GET: ws_read()
> o POST: ws_create()
> o DELETE: ws_delete()
> o PUT: ws_update()
> * A sample solution is included in the Servoy distribution (servoy_sample_rest_ws.servoy), detailing how to retrieve data from the http request and to return a response.
> 
> ```

So basically you need a solution with at least 1 form and 4 form-methods that will hold/call the code to be executed.

The sample solution can be found at “/application\_server/solutions/examples”

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Kahuna](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@Kahuna](https://forum.servoy.com/u/Kahuna)\
**Post date:** [December 14, 2009, 11:40am UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/3 "2009-12-14T11:40:32Z")

</div>

Thanks Marc - that’s a good starter for us. Looked in the Wiki but didn’t search on REST Doh…

Cheers

Ian

---

<div class="post-metadata">

**Author:** ![sbutler](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/sbutler/32/4393_2.png) [@sbutler](https://forum.servoy.com/u/sbutler)\
**Post date:** [December 14, 2009, 5:58pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/4 "2009-12-14T17:58:51Z")

</div>

FYI, I also have a plugin wich allows publishing Web Services from your application from Servoy version 3.x - current. Let me know if you are interested. It hasn’t been released yet, but will be soon. It also offers the ability to serialize JSDatasets to JSON to provider standard way of sharing data from your application.

---

<div class="post-metadata">

**Author:** ![Kahuna](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@Kahuna](https://forum.servoy.com/u/Kahuna)\
**Post date:** [December 14, 2009, 7:24pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/5 "2009-12-14T19:24:25Z")

</div>

> goldcougar:  
> FYI, I also have a plugin wich allows publishing Web Services from your application from Servoy version 3.x - current. Let me know if you are interested. It hasn’t been released yet, but will be soon. It also offers the ability to serialize JSDatasets to JSON to provider standard way of sharing data from your application.

I’d be very interested to hear how that works Scott.

We currently don’t know what information we will need to share but we do know that there are three applications our Clients use that need to have interaction with our Solution (including SAP). Initially we want to make specific items of information available - and the demo of the REST services looks like it will do that, however doubtless we’ll need to share more sophisticated data as the Clients model of what he wants and his experience grows.

---

<div class="post-metadata">

**Author:** ![LOGIsoft](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@LOGIsoft](https://forum.servoy.com/u/LOGIsoft)\
**Post date:** [February 11, 2010, 11:55am UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/6 "2010-02-11T11:55:01Z")

</div>

Hi, using v5.1rc3, when I send the following URL:  
[http://localhost:8080/servoy-service/rest\_ws/servoy\_sample\_rest\_ws/ws\_employees](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees)  
I get this error in FireFox:

> XML Parsing Error: junk after document element  
> Location: [http://localhost:8080/servoy-service/re … \_employees](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees)  
> Line Number 2, Column 15:123456789java.util.ArrayList  
> --------------^

whereas Safari tells me this:

> This page contains the following errors:
> 
> error on line 2 at column 10: Extra content at the end of the document  
> Below is a rendering of the page up to the first error.

I get a similar error if I specify an employee id:  
in FireFox:

> XML Parsing Error: junk after document element  
> Location: [http://localhost:8080/servoy-service/re … mployees/2](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees/2)  
> Line Number 2, Column 30:Andrew2Fuller  
> -----------------------------^

in Safari:

> This page contains the following errors:
> 
> error on line 2 at column 15: Extra content at the end of the document  
> Below is a rendering of the page up to the first error.
> 
> Andrew

Any clue as to what could be wrong? I’m using the original (unmodified) sample methods.

TIA,

Ben

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [February 11, 2010, 12:08pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/7 "2010-02-11T12:08:31Z")

</div>

> goldcougar:  
> FYI, I also have a plugin wich allows publishing Web Services from your application from Servoy version 3.x - current. Let me know if you are interested. It hasn’t been released yet, but will be soon. It also offers the ability to serialize JSDatasets to JSON to provider standard way of sharing data from your application.

Hi Scott,

Is it possible to serialize XML documents into JSON?

So that I can do:

```auto
var str = plugins.serialize.toJSON(myXMLDocument)
var obj = plugins.serialize.fromJSON(str)
return obj; // as result of a webservice

```

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [February 11, 2010, 12:10pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/8 "2010-02-11T12:10:57Z")

</div>

> LOGIsoft:  
> Hi, using v5.1rc3, when I send the following URL:  
> [http://localhost:8080/servoy-service/rest\_ws/servoy\_sample\_rest\_ws/ws\_employees](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees)  
> I get this error in FireFox:
> 
> > XML Parsing Error: junk after document element  
> > Location: [http://localhost:8080/servoy-service/re … \_employees](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees)  
> > Line Number 2, Column 15:123456789java.util.ArrayList  
> > --------------^
> 
> whereas Safari tells me this:
> 
> > This page contains the following errors:
> > 
> > error on line 2 at column 10: Extra content at the end of the document  
> > Below is a rendering of the page up to the first error.
> 
> I get a similar error if I specify an employee id:  
> in FireFox:
> 
> > XML Parsing Error: junk after document element  
> > Location: [http://localhost:8080/servoy-service/re … mployees/2](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees/2)  
> > Line Number 2, Column 30:Andrew2Fuller  
> > -----------------------------^
> 
> in Safari:
> 
> > This page contains the following errors:
> > 
> > error on line 2 at column 15: Extra content at the end of the document  
> > Below is a rendering of the page up to the first error.
> > 
> > Andrew
> 
> Any clue as to what could be wrong? I’m using the original (unmodified) sample methods.
> 
> TIA,
> 
> Ben

Ben how does your call to the webservice look like? (The object/XML dcument that you want to post on the service, not the http call)

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [February 11, 2010, 12:42pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/9 "2010-02-11T12:42:55Z")

</div>

> LOGIsoft:  
> Any clue as to what could be wrong? I’m using the original (unmodified) sample methods.

Ben,

RESTful webservices are not meant for browsers to be clients, you have to use a client that speaks http and understands the xml or json response.

We also shipped the test-page that Jan Blok used in the ServoyCamp demo which is an easy tool for testing/debugging your ws solution, the default url for this is:

[http://localhost:8080/examples/restfulws\_testpage.html](http://localhost:8080/examples/restfulws_testpage.html)

Rob

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [February 11, 2010, 1:20pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/10 "2010-02-11T13:20:25Z")

</div>

Has this test page been updated?

I don’t see the server result on the page

---

<div class="post-metadata">

**Author:** ![LOGIsoft](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@LOGIsoft](https://forum.servoy.com/u/LOGIsoft)\
**Post date:** [February 11, 2010, 1:51pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/11 "2010-02-11T13:51:42Z")

</div>

> RESTful webservices are not meant for browsers to be clients, you have to use a client that speaks http and understands the xml or json response.
> 
> We also shipped the test-page that Jan Blok used in the ServoyCamp demo which is an easy tool for testing/debugging your ws solution, the default url for this is:
> 
> [http://localhost:8080/examples/restfulws\_testpage.html](http://localhost:8080/examples/restfulws_testpage.html)

Aha! That explains it, thanks Rob…

> Ben how does your call to the webservice look like? (The object/XML dcument that you want to post on the service, not the http call)

Martin, I was just issuing a call in my browser address bar, so that was wrong… ![:oops:]( "Embarassed")

Using the testpage, I receive this result when firing a GET from “[http://localhost:8080/servoy-service/rest\_ws/servoy\_sample\_rest\_ws/ws\_employees](http://localhost:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees)”:

```auto
<?xml version="1.0" encoding='UTF-8'?> <list>1</list><list>2</list><list>3</list><list>4</list><list>5</list><list>6</list><list>7</list><list>8</list><list>9</list><list>10</list><javaClass>java.util.ArrayList</javaClass>

```

How can we get the array of the rest of the data (not just a list of the ids), in other words “Nancy1Davolio”, “Andrew2Fuller”, etc. ?

---

<div class="post-metadata">

**Author:** ![LOGIsoft](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@LOGIsoft](https://forum.servoy.com/u/LOGIsoft)\
**Post date:** [February 11, 2010, 1:53pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/12 "2010-02-11T13:53:54Z")

</div>

> martinh:  
> Has this test page been updated?
> 
> I don’t see the server result on the page

On my machine, the path is “file:///Applications/Servoy5.1/application\_server/server/webapps/ROOT/examples/restfulws\_testpage.html”

HTH,

Ben

---

<div class="post-metadata">

**Author:** ![omar.b](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@omar.b](https://forum.servoy.com/u/omar.b)\
**Post date:** [March 4, 2010, 5:31pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/13 "2010-03-04T17:31:30Z")

</div>

Hi guys,  
I’ve got a solution that runs gracefully in smartclient. Now I need to expose data to a webapp through RESTfull WS plugin, so I took the form and wrote the ws\_read() method, but when i try to retrieve data, I get a 500 and this instead:

```auto
org.apache.wicket.WicketRuntimeException: There is no application attached to current thread http-8080-1 
    	at org.apache.wicket.Application.get(Application.java:179) 
    	at org.apache.wicket.Component.getApplication(Component.java:1323) 
    	at org.apache.wicket.Component.<init>(Component.java:920) 
    	at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:113) 
    	at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:49) 
    	at org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.<init>(WebMarkupContainerWithAssociatedMarkup.java:51) 
    	at org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.<init>(WebMarkupContainerWithAssociatedMarkup.java:43) 
    	at org.apache.wicket.markup.html.panel.Panel.<init>(Panel.java:76) 
    	at com.servoy.j2db.server.headlessclient.WebForm.<init>(WebForm.java:1) 
    	at com.servoy.j2db.server.headlessclient.Zf.Ze(Zf.java:56) 
    	at com.servoy.j2db.Zpb.<init>(Zpb.java:996) 
    	at com.servoy.j2db.Zwb.Zg(Zwb.java:10) 
    	at com.servoy.j2db.plugins.ClientPluginAccessProvider$MethodExecutor.run(ClientPluginAccessProvider.java:17) 
    	at com.servoy.j2db.plugins.ClientPluginAccessProvider.executeMethod(ClientPluginAccessProvider.java:87) 
    	at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.wsService(RestWSServlet.java:232) 
    	at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.doGet(RestWSServlet.java:72) 
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    	at com.servoy.j2db.server.servlets.WebServicesServlet.service(WebServicesServlet.java:35) 
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567) 
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) 
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) 
    	at java.lang.Thread.run(Unknown Source)

```

any suggestion?

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [March 5, 2010, 9:30am UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/14 "2010-03-05T09:30:37Z")

</div>

Omar,

Do you have elements on the form?

Try use a form with the ws\_\* methods and no UI elements on the form.

Rob

---

<div class="post-metadata">

**Author:** ![bobcusick](https://avatars.discourse-cdn.com/v4/letter/b/ba9def/32.png) [@bobcusick](https://forum.servoy.com/u/bobcusick)\
**Post date:** [March 5, 2010, 4:43pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/15 "2010-03-05T16:43:19Z")

</div>

You can check out ALL the ServoyCamp 2009 videos here:

> **[Sign in - Google Accounts](https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fsites.google.com%2Fsite%2Fservoycamp%2Fhome%2Fservoycamp2009-media&followup=https%3A%2F%2Fsites.google.com%2Fsite%2Fservoycamp%2Fhome%2Fservoycamp2009-media&ifkv=ASSHykr8Y1o-N1K88cqmIAS3pGzGMkiBLJ7128WlrlKYaOac2Up1PvAoM-Jhrw7_lf0XT-2bcYzH&osid=1&passive=1209600&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S-1274467152%3A1741757130023408)**

MANY thanks to Harjo and Karel for making this happen!

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [March 5, 2010, 4:55pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/16 "2010-03-05T16:55:49Z")

</div>

Omar,

Btw, what version are you on?  
Please try the latest (5.1).

Rob

---

<div class="post-metadata">

**Author:** ![omar.b](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@omar.b](https://forum.servoy.com/u/omar.b)\
**Post date:** [March 8, 2010, 3:44pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/17 "2010-03-08T15:44:12Z")

</div>

Thanks to everyone for the answers, reading carefully the Wiki I found the problem, it was the Authentication, that is not supported.  
Once removed I found a lot of problems with some “particular” listeners that I have in my solution, so I stop the tests because I can’t do anything without authentication.

I started a new Solution and everything goes well.

Thanks to all again.

---

<div class="post-metadata">

**Author:** ![omar.b](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@omar.b](https://forum.servoy.com/u/omar.b)\
**Post date:** [March 9, 2010, 1:29pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/18 "2010-03-09T13:29:37Z")

</div>

Hi guys, I’ve got another question: is possible to reach the WS via https anyway? I tried with “https//: etcetera” and the result was 404 for each call.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [March 9, 2010, 1:32pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/19 "2010-03-09T13:32:35Z")

</div>

You have to configure the tomcat instance first so that it has a https connecter that accepts stuff on 443 (default https port)

---

<div class="post-metadata">

**Author:** ![omar.b](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@omar.b](https://forum.servoy.com/u/omar.b)\
**Post date:** [March 9, 2010, 1:37pm UTC](https://forum.servoy.com/t/restful-web-service-how-to/11509/20 "2010-03-09T13:37:08Z")

</div>

> jcompagner:  
> You have to configure the tomcat instance first so that it has a https connecter that accepts stuff on 443 (default https port)

I’ll try, thanks for your quick response

[Next page](https://forum.servoy.com/t/restful-web-service-how-to/11509.md?page=2)
