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

Can't we setup a put based server on the build server? I believe we only use a fraction of this hardware because of virtualization.Â

we could setup a xmpp/nntp server there as well for testing purposes?

Regards,

Wim

On Tue, Mar 13, 2012 at 5:20 AM, Scott Lewis <slewis@xxxxxxxxxxxxx> wrote:
Hi Atanas,

I decided to go ahead and create a put test/example, even though I currently don't have a working service for it yet.

The example code is here (in org.eclipse.ecf.tests.remoteservice.rest)

http://git.eclipse.org/c/ecf/org.eclipse.ecf.git/tree/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestPutServiceTest.java

The key thing for you will probably be the creation of the IRemoteCallable instance in the setUp method...along with the creation of the remote call parameter and the HttpPutRequestType with default content type and default charset.

Thanks,

Scott


ÂOn 3/12/2012 12:25 PM, ÐÑÐÐÐÑ ÐÐÐÐÑÐÐ wrote:
Hi Scott,
I think i will not be able to make the service public available but i can give you more detailed information which i hope will help you help me .Also i have some questions.

At this row :Â
return (T) restClientService.callSync(RestCallFactory.createRestCall(resource, request.getBody()));
the request.getBody() value is :

[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PortSettings xsi:schemaLocation="/spm/configuration/common/schema/PortSettings.xsd" xmlns="http://namespaces.softwareag.com/Platform/Management/Common/PortSettings" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Port alias="com.softwareag.jmx.connector.pid-">
    <Enabled>true</Enabled>
    <Number>4446</Number>
    <Protocol>JMX</Protocol>
    <ExtendedProperties>
      <Property name="jaasRealm">SSXLoginOS</Property>
      <Property name="secure">false</Property>
    </ExtendedProperties>
  </Port>
</PortSettings>
]
which means the data i want to sent is not empty and is part of the request body.

The information i am trying to send via the wire is xml so i am trying to construct the put request like this:
AbstractRequestType requestType = new HttpPutRequestType(HttpPutRequestType.STRING_REQUEST_ENTITY,"application/xml");

Is this the right way?There is no javadoc nor any examples like POST request examples so it is hard to guess how to use the API in the right way.
For this specific case for example I do not know what's the difference between all the constructors of HttpPutRequestType Âclass and I do not know which one to use.

Sending POST request via ECF do not require to specify content type but seems PUT request require that parameter.And if so why?



2012/3/12 Scott Lewis <slewis@xxxxxxxxxxxxx>
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).

Thanks,

Scott



On 3/8/2012 7:41 AM, ÐÑÐÐÐÑ ÐÐÐÐÑÐÐ wrote:
Hi,
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);

whereÂ

Â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()));
  }




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
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev


_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev




_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev


_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev