Bug 354358 - create example of making a POST ECF Rest call
Summary: create example of making a POST ECF Rest call
Status: RESOLVED FIXED
Alias: None
Product: ECF
Classification: RT
Component: ecf.remoteservices (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.6.0   Edit
Assignee: ecf.core-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-08-10 06:57 EDT by atanas.i.todorov CLA
Modified: 2012-04-24 14:30 EDT (History)
1 user (show)

See Also:


Attachments
client and server bundles (9.65 KB, application/octet-stream)
2011-08-10 07:00 EDT, atanas.i.todorov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description atanas.i.todorov CLA 2011-08-10 06:57:40 EDT
Build Identifier: 

First of all i am not sure if it is a bug or not bug we ageed with Scott to open this bug for the ease of debug.
I have a server-client application that runs in OSGI.Server is jetty.
1.On Server side i use Restlet API to expose restlets the way it is described in this tutorial:
http://wiki.restlet.org/docs_2.0/13-restlet/275-restlet/312-restlet.html
2.On client i use ECF Rest api to make a sync rest call.

The problem is i cannot pass content with post request from client to server.

Reproducible: Always

Steps to Reproduce:
Will attach source.
Comment 1 atanas.i.todorov CLA 2011-08-10 07:00:43 EDT
Created attachment 201230 [details]
client and server bundles

I attached the client and server which are osgi bundles.
The server depends on restlet jars.The client depends on ecf jars.Depenedent packages you can find in the manifests.
Comment 2 atanas.i.todorov CLA 2011-08-10 07:08:50 EDT
Here is the HTTP communication sniffed with wireShark.
I can see that the POST request does not include the String "op" i am trying to pass.


HTTP/1.1 200 OK
Date: Wed, 10 Aug 2011 10:21:19 GMT
Content-Type: application/xml; charset=UTF-8
Content-Length: 509
Date: Wed, 10 Aug 2011 10:21:19 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.0.8
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><configuration><types><type><configurationObjectClassName>java.util.Properties</configurationObjectClassName><description>simple properties test configuration</description><displayName>Test Properties</displayName><id>system.properties</id><restartRequired>false</restartRequired><serializerClassName>com.softwareag.platform.management.common.configuration.serializer.PropertiesConfigurationSerializer</serializerClassName></type></types></configuration>

================================================================================================

POST /spm/configuration/types/SPM-PROCESS/system.properties? HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Content-Length: 0
Authorization: Basic QWRtaW5pc3RyYXRvcjptYW5hZ2U=
Host: localhost:8092

================================================================================================

HTTP/1.1 401 Unauthorized
Date: Wed, 10 Aug 2011 10:21:19 GMT
WWW-Authenticate: basic realm="DummyLogin"
Content-Type: text/html;charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1424
Server: Jetty(7.0.2.v20100331)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 401 Unauthorized</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /spm/configuration/types/SPM-PROCESS/system.properties. Reason:
<pre>    Unauthorized</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                
<br/>                                                

</body>
</html>

================================================================================================

POST /spm/configuration/types/SPM-PROCESS/system.properties? HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8092
Content-Length: 0
Comment 3 atanas.i.todorov CLA 2011-08-11 09:54:55 EDT
I manage to fix that by registring callable with some default RemoteCallParameters and with requestEntityType equal to "1"
 
IRemoteCallParameter[] rcp = RemoteCallParameterFactory.createParameters("", "");
 HttpPostRequestType requestType = new HttpPostRequestType(1);         
 IRemoteCallable callable = RestCallableFactory.createCallable(resource, resource, rcp, requestType,IRestCall.DEFAULT_TIMEOUT);

comment: createCallable method requires as parameter AbstractRequestType(the abstract class) instead of IRemoteCallableRequestType(interface).Probably you can fix that.
Comment 4 atanas.i.todorov CLA 2011-08-11 10:11:53 EDT
What in my mind is not quite intuitive is that user need to instatiate HttpPostRequstType with some int args depending on what is going to be transferred trough the wire(String,inputStream.....) and register callable with some default parameters.
e.g
IRemoteCallParameter[] rcp = RemoteCallParameterFactory.createParameters("","");
Skipping these two actions didn't work for me.
Comment 5 Scott Lewis CLA 2011-08-15 11:23:23 EDT
(In reply to comment #3)
> I manage to fix that by registring callable with some default
> RemoteCallParameters and with requestEntityType equal to "1"
> 
> IRemoteCallParameter[] rcp = RemoteCallParameterFactory.createParameters("",
> "");
>  HttpPostRequestType requestType = new HttpPostRequestType(1);         
>  IRemoteCallable callable = RestCallableFactory.createCallable(resource,
> resource, rcp, requestType,IRestCall.DEFAULT_TIMEOUT);
> 
> comment: createCallable method requires as parameter AbstractRequestType(the
> abstract class) instead of IRemoteCallableRequestType(interface).Probably you
> can fix that.

Hi Atanas.

Good to here that things are working.  Would it be possible for you to attach the working code to this bug?  That way I can possibly take it and turn it into an example for others to use.

Also changing title of bug and changing to enhancement.

Thanks.
Comment 6 Scott Lewis CLA 2011-08-15 11:59:45 EDT
(In reply to comment #4)
> What in my mind is not quite intuitive is that user need to instatiate
> HttpPostRequstType with some int args depending on what is going to be
> transferred trough the wire(String,inputStream.....) and register callable with
> some default parameters.
> e.g
> IRemoteCallParameter[] rcp =
> RemoteCallParameterFactory.createParameters("","");
> Skipping these two actions didn't work for me.

I agree that the post and put API could be simplified.  I'm unable to put a lot of time into it at the moment, so can't take on a redesign at the moment...but if you are willing, please suggest some specific changes without loss of generality...and we can discuss them here and I can/will apply them (for ECF 3.6...that's the earliest that API changes can be applied due to Eclipse dev process).

Thanks.
Comment 7 Scott Lewis CLA 2012-04-24 14:30:35 EDT
An example was created in tests.