[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Sending PUT Request using ECF

Hi Atanas,

Yes, I believe we probably can help you.  One of the difficulties of testing/example/demoing this, however, is to have a PUT-based web service available.  Is there a put-based web service that you can make available (even temporarily) for us to use?

...or point to some public put-based service that resembles your service (in terms of parameters, serialization, etc).



On 3/8/2012 7:41 AM, Атанас Тодоров wrote:
Can you help me send a PUT request using ECF framework.I have a web resource exposed via REST and i want to update it with some data.

NOTE: GET,POST,DELETE requests work for me.

The code i use is:

AbstractRequestType requestType = new HttpPutRequestType();
Request request = new Request(requestType, new Object[] { configuration }); // configuration is String and is not empty or null.
RemoteServiceProxy proxy =  new RemoteServiceProxy<Object>(deserializer, host) // deserializer is custom impl of BaseRemoteResponseDeserializer
proxy.makeRestSyncCall(url.toString(), request);


 public T makeRestSyncCall(String resource, Request request) throws ECFException {
        IContainer originalContainer = ContainerFactory.getDefault().createContainer(REST_CONTAINER_TYPE, url);
        RestID restID = null;
        try {
         restID = new RestID(originalContainer.getConnectNamespace(), new URI(url));
        } catch (Exception ex) {
         //TODO log exception when we have logger
         return null;
        IContainer container = new SPMRestClientContainer(restID);
        IRemoteServiceClientContainerAdapter adapter = (IRemoteServiceClientContainerAdapter) container
            UriContainer.REMOTE_USERNAME, UriContainer.REMOTE_PASSWORD));
        IRemoteCallParameter[] rcp = null;
        if (request.getRequestType() instanceof HttpPostRequestType) {
            rcp = RemoteCallParameterFactory.createParameters("", "");//$NON-NLS-1$ //$NON-NLS-2$
        IRemoteCallable callable = RestCallableFactory.createCallable(resource, resource, rcp, request.getRequestType(),
        IRemoteServiceRegistration registration = adapter.registerCallables(new IRemoteCallable[] { callable }, null);
        IRemoteService restClientService = adapter.getRemoteService(registration.getReference());

        return (T) restClientService.callSync(RestCallFactory.createRestCall(resource, request.getBody()));

I think the problem is in the way i construct the HttpPutRequestType as it is the only difference comparing to POST,GET,DELETE.
On the server side the object i am sending is an empty string and that's the problem.

Hope can help me,
Best Regards,
Atanas Todorov

ecf-dev mailing list