How to call a Servoy Webservice from another Servoy Solution

Hi there,

i’ve two Servoy solutions:

Solution A:
Provides a Webservice with the Servoy RESTful Web Services Plugin with the following settings:

rest_ws_plugin_client_pool_exhausted_action: grow
rest_ws_plugin_authorized_groups: Webservice
rest_ws_plugin_client_pool_size: 1

In the group Webservice is one user called “webservice”.

Solution B:
Wants to call the Webservice with a CREATE request with the following code:

var poster = plugins.http.getPoster('http://192.168.1.2:8080/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees');
poster.addHeader('Content-type','text/xml; charset=UTF-8')
poster.setCharset('UTF-8');
	
var xml = createWebserviceXml();
var jsFile = plugins.file.createTempFile('data','.xml');
plugins.file.writeXMLFile(jsFile , xml);
poster.addFile(null, 'data.xml', jsFile.getAbsolutePath());
	
var httpCode = poster.doPost('webservice', 'password'); //httpCode 200 is ok

When i deactivate webservice authentification (change settings on solution A and just call poster.doPost()) everything works fine and i get the request in the ws_create() method of solution A.
But when i use authentification, i get the httpCode = 0 and the following error log in servoy-admin/logs from solution A:

2012-05-03 11:22 	http-8084-1 	ERROR 	com.servoy.extensions.plugins.rest_ws.RestWSPlugin 	/servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees
I/O exception, see log for full details: Invalid chunk header

The XML from method createWebserviceXml() looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<company>A Company</company>
<name>My Name</name>
<firstname>My first name</firstname>
<email>email@email.de</email>
<phone>123</phone>
<street>My street</street>
<city>My City</city>
<zipcode>12345</zipcode>
<nation>Germany</nation>
<housenumber>4711</housenumber>
<customer_id>4712</customer_id>
<uuid_webformulare>2A5EF776-D042-4402-A57C-17F88978A7D8</uuid_webformulare>

I’ve also tried to make the XML easier like this:

<?xml version="1.0" encoding="UTF-8"?>
<name>abc</name>

But it makes no difference.

Can anybody help me please?

Thanks a lot!
Alex

P.S.
We use Servoy 5.2.13 on both solutions / application servers

no idea?

I don’t know if this helps, but should ‘vPoster’ just be ‘poster’?

vPoster.addFile(null, 'data.xml', jsFile.getAbsolutePath());

oh sorry, “vPoster” was just a typo… i use “poster” in my code, so this isn’t the reason unfortunately.
Does somebody else use the Servoy Webservice Plugin?

Can somebody post a simple example how to call the RESTful Servoy Webservice Plugin from another Servoy solution, please?

Thanks a lot!
Alex

The full log entry from application-server B is the following:

2012-05-03 11:22:21,041 ERROR [http-8084-1] com.servoy.extensions.plugins.rest_ws.RestWSPlugin - /servoy-service/rest_ws/servoy_sample_rest_ws/ws_employees
java.io.IOException: Invalid chunk header
	at org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:133)
	at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:710)
	at org.apache.coyote.Request.doRead(Request.java:428)
	at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304)
	at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:405)
	at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
	at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:162)
	at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.getBody(RestWSServlet.java:338)
	at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.doPost(RestWSServlet.java:163)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at com.servoy.j2db.server.servlets.WebServicesServlet.service(WebServicesServlet.java:23)
	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)

What’s wrong, when i use authentification?

Alexander,

This looks like a bug in the http plugin to me (or, less likely, in the restws plugin).

What happens if you post to a http-post-test site?

Rob