[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [ecf-dev] POST ECF Rest call | 
Hi Scott,
Please not that  i have the  same code snippet working for GET request.Or what i mean is that instead of HttpPostRequestType  i use HttpGetRequestType on client side .
On server side i have
public class MyResource extends ServerResource {
@GET
public Object getResource() {
    return "Some data"
} or restlet implemented like that tutorial
I do not provide the server code as it is product specific and do not have anything we can look at.
The working workflow is like that:
1. client: make ECF Rest call  with HttpGetRequstType
2.server: getResource() is invoked and return some data(the code above)
3: client: ecf deserialize() is invoked with parameter responseBody  containing "Some data" string.
So i am able to make a GET ECF Rest request successfully and return response.The problem is i do not know how to make a POST request with ECF Rest API or better say how to invoke the ECF Rest call  on client so that be able to take the sent object from getResource() on server.
Yes.  As I said, I have a Restlet-based ECF remote services provider now...that allows remote Restlet resources to be both discovered (via OSGi EndpointDescriptions), and a functioning proxy to be automatically created at remote service discover time.  This makes the implementation of the Restlet client completely unnecessary (i.e. it's done automatically by the OSGi remote services implementation).
This is the next thing i wanna try.Can i download  the Restlet-based ECF provider from somewhere? I somehow wanted to make the above approach work beforehand.
Thanks
2011/8/9 Scott Lewis 
<slewis@xxxxxxxxxxxxx>
  
    
  
  
    Hi Atanas,
    
    On 8/9/2011 8:53 AM, Атанас Тодоров wrote:
    
Hi Scott,
      
      
      I have tried what you suggested.I also set the
        requestEntityType to 0 
      
        
          
            HttpPostRequestType postRequest = new
              HttpPostRequestType(0); so the code on client side looks
              like that :
           
        
       
      
        
          
            IRemoteCallParameter [] defaultParams =
              RemoteCallParameterFactory.createParameters("default","my
              Default Value"); 
             HttpPostRequestType
              postRequest = new HttpPostRequestType(0);
             IRemoteCallable
              callable = RestCallableFactory.createCallable(url, url,
             
                 defaultParams, postRequest, IRestCall.DEFAULT_TIMEOUT);
             
             IRemoteServiceRegistration
              registration = adapter.registerCallables(
             new
              IRemoteCallable[] { callable }, null);
             IRemoteService
              restClientService = adapter
             .getRemoteService(registration.getReference());
             InputStream
              inputStream = new ByteArrayInputStream("My Test
              value".getBytes(Charset.defaultCharset()));
             return
              (T)
              restClientService.callSync(RestCallFactory.createRestCall(url,
              new Object[]{inputStream}));
           
         
       
    
     
    And what happens as a result of this callSync?
    
    Also...what is the value of url variable?  Perhaps there is some
    problem with the setup/mapping of the callables to Restlet remote
    method calls?  And how exactly does restlet represent the
    getResource method call in terms of the url + path + parameters?  My
    suspicion is that somehow the client is not providing the
    appropriate url+path+params that Restlet server expects for the
    getResource request.  Note the RestClientService class has a number
    of overridable methods (both public and protected) that allow the
    remote call to be made specific to a particular rest framework (e.g.
    Restlet).
    
    
    
      
      
      
        
          
            I guess you are familiar with Restlet Framework.
         
       
    
     
    Yes.  As I said, I have a Restlet-based ECF remote services provider
    now...that allows remote Restlet resources to be both discovered
    (via OSGi EndpointDescriptions), and a functioning proxy to be
    automatically created at remote service discover time.  This makes
    the implementation of the Restlet client completely unnecessary
    (i.e. it's done automatically by the OSGi remote services
    implementation).
    
    
    
      
        
          On server side i have a restlet that expose a web
            resource.Making a remote rest call via ECF i actually invoke
            this method below.
         
       
      
      
      @POST
      public void getResource(){
      org.restlet.Request ---> how take the send inputStream
          from that request
      }
      
      
      I am also  willing to provide some example if we make it work
        of course.
    
     
    If you provide the client code that you are working with, and
    provide access to some service for testing, I'll help debug and we
    can then perhaps make it available as an example and/or test.
    
    Scott
    
  
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev