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.
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
.getAdapter(IRemoteServiceClientContainerAdapter.class);
adapter.setConnectContextForAuthentication(ConnectContextFactory.createUsernamePasswordConnectContext(
UriContainer.REMOTE_USERNAME,
UriContainer.REMOTE_PASSWORD));
adapter.setResponseDeserializer(deserializer);
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(),
IRestCall.DEFAULT_TIMEOUT);
IRemoteServiceRegistration registration =
adapter.registerCallables(new IRemoteCallable[] { callable },
null);
IRemoteService restClientService =
adapter.getRemoteService(registration.getReference());
return (T)
restClientService.callSync(RestCallFactory.createRestCall(resource,
request.getBody()));
}
On the server side the object i am sending is an
empty string and that's the problem.