You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Julio Carlos Barrera Juez <ju...@i2cat.net> on 2013/10/16 10:18:03 UTC
Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Hi.
I'm creating a REST client using JAXRSClientFactoryBean and
ProxyClassLoader based on a JAXRS annotated Java interface.
I want to send a DELETE with body, which is not recommended by RESTful
philosophy, but it is allowed by HTTP 1.1 RFC.
The body is not sent by the client and I have read a lot of problems to
allow it.
Is it possible send a body in my DELETE requests with this configuration?
Thank you!
Regards, Julio
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
I added earlier a code which was blocking DELETE with bodies, now it works
Sergey
On 17/10/13 15:45, Julio Carlos Barrera Juez wrote:
> I tried the same without changing the URI, only changing the method and
> it didn't work neither. I changed the original method to HEAD (changing
> the JAX-RS annotated interface), changing it to DELETE in the filter.
> The client sends HEAD requests anyway. Why is not my filter changing the
> request method?
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
> On 17 October 2013 16:37, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>> wrote:
>
> On 17/10/13 14:49, Julio Carlos Barrera Juez wrote:
>
> Bad news then.
>
>
> I'm not sure why did you expect DELETE with body to work, we
> discussed it yesterday and confirmed it was not yet possible, please
> make sure you watch that JIRA I linked to to try it once it gets
> fixed (though I don't know yet how feasible it is)
>
>
> Anyway the filter does not work, because the
> calls requestContext.setUri(...) did not change the real URI
> used at the
> end. But the method requestContext.setMEthod(...) worked...
>
> Right, setUri does not work from client filters, thanks for catching it.
> I've been certain a test is there, but it is only pre-matching
> container request filters which are tested on setRequestUri, so it
> needs to be fixed
>
> Cheers, Sergey
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
> On 17 October 2013 13:45, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>> wrote:
>
> Hi
>
> The method is definitely returned in CXF 2.7.7, I've just
> added a
> test confirming that. A lot of fixes went into the
> client-side 2.0
> code, some of it is still on the trunk only as they deal
> more with
> various very edgy TCK issues, I'm not sure yet if they
> should make
> to CXF 2.7.8 or not, but a method getter works in 2.7.7
>
> Re the actual exception, I guess this is because we don't have
> DELETE with body supported yet
>
> Sergey
>
> On 17/10/13 11:51, Julio Carlos Barrera Juez wrote:
>
> Hi Sergey.
>
> First of all, excuse me by the duplicate message.
>
> I have just written a Filter like this:
>
> public class PostToDeleteWithBodyFilter implements
> ClientRequestFilter {
>
> public final static StringEXTRA_PATH=
> "/mutatePOSTtoDELETE";
>
>
> @Override
> public void filter(ClientRequestContext requestContext)
> throws
> IOException {
> String method = requestContext.getMethod();
> String path = requestContext.getUri().____getPath();
>
>
> if (path != null && path.endsWith(EXTRA_PATH)) {
> // remove EXTRA_PATH
> requestContext.setUri(URI.____create(path.substring(0,
> path.length() -
>
> EXTRA_PATH.length())));
> // transform POST into DELETE
> requestContext.setMethod("____DELETE");
>
> }
> }
> }
>
> I have some issues again. The method var is null. And
> the most
> important, an exception is thrown when I use this filter:
>
> Caused by: java.io.IOException: IOException invoking
> http://<my_server>/real_path/____mutatePOSTtoDELETE:
> insufficient
> data written
> at
>
> sun.reflect.____NativeConstructorAccessorImpl.____newInstance0(Native
> Method)
> at
>
> sun.reflect.____NativeConstructorAccessorImpl.____newInstance(____NativeConstructorAccessorImpl.____java:39)
> at
>
> sun.reflect.____DelegatingConstructorAccessorI____mpl.newInstance(____DelegatingConstructorAccessorI____mpl.java:27)
> at
>
> java.lang.reflect.Constructor.____newInstance(Constructor.__java:__513)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.____mapException(HTTPConduit.java:____1338)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.close(____HTTPConduit.java:1322)
> at
>
> org.apache.cxf.transport.____AbstractConduit.close(____AbstractConduit.java:56)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit.close(__HTTPConduit.__java:622)
> at
>
> org.apache.cxf.interceptor.____MessageSenderInterceptor$____MessageSenderEndingInterceptor____.handleMessage(____MessageSenderInterceptor.java:____62)
>
> ... 31 more
> Caused by: java.io.IOException: insufficient data written
> at
>
> sun.net.www.protocol.http.____HttpURLConnection$____StreamingOutputStream.close(____HttpURLConnection.java:2861)
> at
>
> sun.net.www.protocol.http.____HttpURLConnection.____getInputStream(____HttpURLConnection.java:1175)
> at
>
> java.net.HttpURLConnection.____getResponseCode(____HttpURLConnection.java:379)
> at
>
> org.apache.cxf.transport.http.____URLConnectionHTTPConduit$____URLConnectionWrappedOutputStre____am.getResponseCode(____URLConnectionHTTPConduit.java:____260)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.____handleResponseInternal(____HTTPConduit.java:1517)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.____handleResponse(HTTPConduit.____java:1490)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.close(____HTTPConduit.java:1309)
>
> ... 34 more
>
> I tried to detect the special message to be mutated
> using an
> extra path
> string appended to the real path. It worked, it was
> detected, but
> something went wrong...
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027> <tel:%2B34%2093%20357%2099%__2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
>
> On 17 October 2013 12:17, Sergey Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__> wrote:
>
> Hi
>
> Can you register an instance of JAX-RS 2.0
> ClientRequestFilter (as a
> provider) and set your method & request URI if
> needed there ?
> That should make it simpler for you.
>
> Re using a custom CXF interceptor, it really
> should have the
> properties which you check already set on the
> message passed to
> handleMessage(), that message is an out message,
> so you
> should have
> "message ==
> message.getExchange().______getOutMessage()" hold
>
> true.
>
>
> Cheers, Sergey
>
>
> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>
> I'm trying to workaround this problem with an
> output CXF
> interceptor. I
> have modified the DELETE request to be a POST
> request
> allowing a
> body. I
> want that my interceptor will detect the POST
> request
> and will
> change it to
> a DELETE. I'm having some problems to achieve
> it. How
> can the
> interceptor
> modify the message object to achieve my goal?
>
> I have written something like this:
>
> public class
> PostToDeleteWithBodyIntercepto______r extends
> AbstractPhaseInterceptor<______Message> {
>
>
>
> public final static String EXTRA_PATH =
> "/mutatePOSTtoDELETE";
>
> public PostToDeleteWithBodyIntercepto______r() {
>
>
> super(Phase.PRE_PROTOCOL);
> }
>
> public void handleMessage(Message message) {
> String path = (String)
>
>
> message.getExchange().______getOutMessage().get(Message.______REQUEST_URI);
> String method = (String)
>
>
> message.getExchange().______getOutMessage().get(Message.______HTTP_REQUEST_METHOD);
>
>
> if (method != null && method.equals("POST")
> && path
> != null &&
> path.endsWith(EXTRA_PATH)) {
> // TODO remove EXTRA_PATH
> // TODO transform POST into DELETE
> }
> }
> }
>
> I have a few doubts:
>
> - I don't know how to modify the path and the
> method of the
> request. I
>
> have tried modifying the content of the
> - I don't know what is the exact phase
> where apply it.
> - Why do I need to look for exchange, out
> message
> to see
> current path
>
> and method? It should be in the message,
> but the
> values are
> null.
>
> Thank you!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:54, Sergey Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__> wrote:
>
> Hi,
>
> On 16/10/13 15:36, Julio Carlos Barrera
> Juez wrote:
>
> Yes, the server is not under my
> control. I want to
> develop a client
> because
> I like how CXF works and it is a
> dependency for
> other
> issues in my
> project.
> Obviously I would never develop a
> service with
> body in
> DELETE requests.
>
> The, taking into account that I'm
> using CXF
> 2.7.x, is it
> possible to
> workaround my problem using CXF?
>
> Probably not at the moment,
>
> I've opened
> https://issues.apache.org/**______jira/browse/CXF-5337
> <https://issues.apache.org/**____jira/browse/CXF-5337>
> <https://issues.apache.org/**____jira/browse/CXF-5337
> <https://issues.apache.org/**__jira/browse/CXF-5337>>
>
> <https://issues.apache.org/**____jira/browse/CXF-5337
> <https://issues.apache.org/**__jira/browse/CXF-5337>
> <https://issues.apache.org/**__jira/browse/CXF-5337
> <https://issues.apache.org/**jira/browse/CXF-5337>>><https:/__/____issues.apache.org/jira/____browse/__CXF-5337
> <http://issues.apache.org/jira/__browse/__CXF-5337>
> <http://issues.apache.org/__jira/browse/__CXF-5337
> <http://issues.apache.org/jira/browse/__CXF-5337>>
>
>
> <https://issues.apache.org/____jira/browse/CXF-5337
> <https://issues.apache.org/__jira/browse/CXF-5337>
>
> <https://issues.apache.org/__jira/browse/CXF-5337
> <https://issues.apache.org/jira/browse/CXF-5337>>>>
>
>
> Please watch it.
>
> In meantime, may be it is possible to
> 'tunnel' it,
> example,
> use POST but
> set some header with the real/intended
> HTTP verb
> such as
> DELETE, the target
> server would need to replace POST with
> DELETE, the
> easy way
> is to say
> create Servlet filter which will use
> HTTPServletRequest
> wrapper to return
> DELETE, some work is needed there but no
> changes to the
> server code itself
> will be required.
>
> Otherwise - try snapshots once CXF-5337
> gets resolved
>
> Thanks, Sergey
>
> Thank you Sergey!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and Networks
> Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:23, Sergey Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__> wrote:
>
> Right, looks like the following has
> to be
> done with
> HTTPClient:
>
>
> https://code.google.com/p/****______rest-client/source/browse/__**
> <https://code.google.com/p/****____rest-client/source/browse/**>
>
> <https://code.google.com/p/***__*__rest-client/source/browse/*__* <https://code.google.com/p/****__rest-client/source/browse/**>>
>
>
> <https://code.google.com/p/***____*rest-client/source/browse/*__* <https://code.google.com/p/***__*rest-client/source/browse/**>
>
> <https://code.google.com/p/***__*rest-client/source/browse/**
> <https://code.google.com/p/****rest-client/source/browse/**>>__>__<h__ttps://code.google.com/__p/*__*__rest-client/source/__browse/*__*
> <http://code.google.com/p/*__*__rest-client/source/browse/*__*>
>
> <http://code.google.com/p/**____rest-client/source/browse/**
> <http://code.google.com/p/**__rest-client/source/browse/**>>
>
>
> <https://code.google.com/p/**____rest-client/source/browse/**
> <https://code.google.com/p/**__rest-client/source/browse/**>
>
> <https://code.google.com/p/**__rest-client/source/browse/**
> <https://code.google.com/p/**rest-client/source/browse/**>>>__>
>
>
> restclient-lib/src/main/java/*______***org/wiztools/__restclient/____http/****
>
>
> EntityEnclosingDelete.java<______htt**ps://code.google.com/p/______rest-**
> <http://code.google.com/p/____rest-**>
> <http://code.google.com/p/____rest-**
> <http://code.google.com/p/__rest-**>>
>
> <http://code.google.com/p/____rest-**
> <http://code.google.com/p/__rest-**>
> <http://code.google.com/p/__rest-**
> <http://code.google.com/p/rest-**>>>
>
>
> client/source/browse/**______restclient-lib/src/main/java/*______*
>
>
> org/wiztools/restclient/http/*______*EntityEnclosingDelete.__java<__ht__tps://code.google.__com/p/__rest-__client/source/__browse/____restclient-lib/src/__main/java/____org/wiztools/__restclient/http/______EntityEnclosingDelete.java
> <http://code.google.com/p/__rest-__client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java>
>
> <http://code.google.com/p/__rest-__client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java
> <http://code.google.com/p/rest-__client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>>
>
>
>
> <https://code.google.com/p/____rest-client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java
> <https://code.google.com/p/__rest-client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>
>
>
> <https://code.google.com/p/__rest-client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java
> <https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>>>>
>
>
>
>
> This is the code based on the
> advice from
> HttpClient
> forums.
>
> I guess we should check if CXF Async
> Conduit can be
> updated respectively
>
> By the way, I'm assuming you have
> to do
> DELETE with
> a body because you
> have some existing/legacy service
> expecting
> it this
> way ? Now and then
> users ask about it, and I don't
> mind to get the
> Async HTTP conduit
> updated
> a bit anyway, but if you have say
> a CXF server
> listening, then I'm sure
> there could be an easier way :-)
>
> Cheers, Sergey
>
>
> On 16/10/13 15:11, Julio Carlos
> Barrera
> Juez wrote:
>
> Looking for logs, I've realized
> that the
> property
> is producing changes.
>
> I
> mean the Async HTTP client is
> being used.
> However my DELETE request has
> no
> body. My client interface is
> JAX-RS
> annotated,
> my Resource class is JaxB
> annotated:
>
> @Path("/server/path")
> @DELETE
>
> @Consumes(MediaType.****______APPLICATION_JSON)
>
>
>
>
> public void
> deleteResource(Resource resource);
>
> I have a create method working
> with de same
> configuration and it works:
>
> @Path("/server/path")
> @POST
>
> @Consumes(MediaType.****______APPLICATION_JSON)
>
>
>
>
> public void
> createResource(Resource resource);
>
> I'm using Jackson as JSON
> serializer, but I
> guess it has no relation
> with
> this problem.
>
> These log lines show that the
> DELETE
> request has
> content-lenght 0 and
> the Async HTTP client is
> being used
>
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.cxf.transport.http.______****asyncclient.****______AsyncHTTPConduitFactory$2
>
>
>
> -
>
> Connection leased: [id: 2][route:
> {}->http://my_server][total kept
> alive:
> 0; route allocated: 1 of 1000;
> total
> allocated:
> 0 of 5000]
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.cxf.transport.http.______****asyncclient.****______AsyncHTTPConduitFactory$3
>
>
>
> -
> [exchange: 3] Connection
> allocated:
>
> [id:2][route:{}->http:/my_****______server][state:null]
>
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][r:__]:
>
>
> Set
> attribute
> http.nio.exchange-handler
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][__rw:]__:
>
>
> Event
> set [w]
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][__rw:]__:
>
>
> Set
>
>
> attribute
> http.nio.http-exchange-state
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.cxf.transport.http.______****asyncclient.****______AsyncHTTPConduitFactory$3
>
>
>
> -
>
> [exchange: 3] Attempt 1 to
> execute request
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][__rw:]__:
>
>
> Set
> timeout
> 60000
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.****
>
> protocol.RequestAuthCache
>
> -
> Auth cache not set in the context
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.http.client.****______protocol.****______RequestTargetAuthentication
>
>
> -
>
> Target
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.http.client.****______protocol.****______RequestProxyAuthentication
>
>
> -
>
> Proxy
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >> *
> DELETE* /server/path HTTP/1.1
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Accept: text/plain
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> User-Agent: Apache CXF 2.7.4
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> *Content-Length:
> 0*
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Host:
> my_server
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Connection: Keep-Alive
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and
> Networks
> Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 15:17,
> Julio Carlos
> Barrera
> Juez <
> juliocarlos.barrera@i2cat.net
> <ma...@i2cat.net>
> <mailto:juliocarlos.barrera@__i2cat.net
> <ma...@i2cat.net>>
> <mailto:juliocarlos.barrera@
> <mailto:juliocarlos.barrera@>____i2cat.net <http://i2cat.net>
>
> <mailto:juliocarlos.barrera@__i2cat.net
> <ma...@i2cat.net>>>> wrote:
>
> I don't know how to
> install CXF
> Async HTTP
> transport. I have the maven
>
> artifact in my project
> dependencies, but
> nothing else.
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357
> 99 27 <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and
> Networks Area
> (DANA)
> i2CAT Foundation,
> Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 13:14,
> Sergey
> Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__>
>
> wrote:
>
> I guess you don't have CXF
> Async HTTP
> transport installed ?
>
> Other than that I've
> no idea, if it
> won;t work with the
> Async module
> then
> I guess it is possible
> to do
> Sergey
>
> On 16/10/13 11:49,
> Julio Carlos
> Barrera
> Juez wrote:
>
> I tried to use
> this information
> before, but I don't
> know how to
> solve
>
> my
> problem.
>
> I have something
> like this:
>
> ProxyClassLoader
> classLoader = new
> ProxyClassLoader();
>
>
>
> classLoader.addLoader(******______IServiceInterface.class.****
> getClassLoader());
>
>
> classLoader.addLoader(******______JAXRSClientFactoryBean.__class.*____*****
>
>
>
>
>
> getClassLoader());
>
>
> JAXRSClientFactoryBean bean
> = new
>
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
>
> bean.setResourceClass(******______IServiceInterface.class);
>
>
> bean.setClassLoader(******______classLoader);
>
>
>
>
>
>
> client
> (IServiceInterface)
> bean.create();
>
> Then I can use the
> client
> object as
> usual. But if
> fails sending
> DELETE
> requests with body.
>
> I tried doing this:
>
> ProxyClassLoader
> classLoader = new
> ProxyClassLoader();
>
>
>
> classLoader.addLoader(******______IServiceInterface.class.****
> getClassLoader());
>
>
> classLoader.addLoader(******______JAXRSClientFactoryBean.__class.*____*****
>
>
>
>
>
> getClassLoader());
>
>
> JAXRSClientFactoryBean bean
> = new
>
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
>
> bean.setResourceClass(******______IServiceInterface.class);
>
>
> bean.setClassLoader(******______classLoader);
>
>
>
>
>
>
> // allow body in
> DELETE
> requests
> Client client =
> bean.create();
>
>
>
> WebClient.getConfig(client).**______****getRequestContext().__put(__"*__*
>
>
> use.****
> async.http.conduit",
> true);
>
> (IServiceInterface)
>
> client.******______whateverMethodThatSendsDelete(______**
>
>
>
> ****);
>
>
>
> But it didn't work.
>
> What am I missing?
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34
> 93 357 99
> 27 <tel:%2B34%2093%20357%2099%__2027>
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed
> Applications and
> Networks Area (DANA)
> i2CAT Foundation,
> Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013
> 12:00,
> Sergey
> Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__>
>
>
> wrote:
>
> Hi
>
>
> On 16/10/13 09:18,
> Julio Carlos
> Barrera Juez
> wrote:
>
> Hi.
>
>
> I'm
> creating a REST
> client
> using
> JAXRSClientFactoryBean and
>
> ProxyClassLoader
> based on a
> JAXRS
> annotated
> Java interface.
>
> I want to
> send a
> DELETE with
> body,
> which is not
> recommended by
> RESTful
>
> philosophy, but it is
> allowed by
> HTTP 1.1
> RFC.
>
> The body
> is not
> sent by the
> client and
> I have
> read a lot of
> problems
> to
> allow it.
>
> Is it
> possible send
> a body
> in my DELETE
> requests with this
> configuration?
>
>
> Please check
> this thread
>
>
> http://cxf.547215.n5.nabble.**______******com/JaxRS-Client-__with-__**
>
> Deletes-****
>
>
> td5731444.html<http://cxf.****______54**7215.n5.nabble.com/____JaxRS-*__***
> <http://7215.n5.nabble.com/__JaxRS-*__***>
> <http://7215.n5.nabble.com/__JaxRS-*__***
> <http://7215.n5.nabble.com/JaxRS-*__***>>
>
> <http://7215.n5.nabble.com/____JaxRS-****
> <http://7215.n5.nabble.com/__JaxRS-****>
> <http://7215.n5.nabble.com/__JaxRS-****
> <http://7215.n5.nabble.com/JaxRS-****>>><http://7215.n5.____nabble.com/__JaxRS-**
> <http://nabble.com/__JaxRS-**>
> <http://7215.n5.nabble.com/____JaxRS-**
> <http://7215.n5.nabble.com/__JaxRS-**>>
>
> <http://7215.n5.nabble.com/____JaxRS-**
> <http://7215.n5.nabble.com/__JaxRS-**>
> <http://7215.n5.nabble.com/__JaxRS-**
> <http://7215.n5.nabble.com/JaxRS-**>>>>
>
> <http://547215.n5.nabble.com/*______*JaxRS-**
> <http://547215.n5.nabble.com/*____*JaxRS-**>
> <http://547215.n5.nabble.com/*____*JaxRS-**
> <http://547215.n5.nabble.com/*__*JaxRS-**>>
>
> <http://547215.n5.nabble.com/*____*JaxRS-**
> <http://547215.n5.nabble.com/*__*JaxRS-**>
> <http://547215.n5.nabble.com/*__*JaxRS-**
> <http://547215.n5.nabble.com/**JaxRS-**>>><http://547215.n5.______nabble.com/JaxRS-**
> <http://nabble.com/JaxRS-**>
> <http://nabble.com/JaxRS-**>
>
> <http://547215.n5.nabble.com/____JaxRS-**
> <http://547215.n5.nabble.com/__JaxRS-**>
> <http://547215.n5.nabble.com/__JaxRS-**
> <http://547215.n5.nabble.com/JaxRS-**>>>>
>
>
>
>
> Client-with-Deletes-td5731444.______******html<http://cxf.____547215.
> <http://cxf.547215.>__n5.
>
> <http://cxf.547215.n5.>****
> nabble.com/JaxRS-Client-with-*______***Deletes-td5731444.html
> <http://nabble.com/JaxRS-Client-with-*____***Deletes-td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-with-*__***Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-with-*__***Deletes-td5731444.html>>
>
>
> <http://nabble.com/JaxRS-____Client-with-****Deletes-____td5731444.html
> <http://nabble.com/JaxRS-__Client-with-****Deletes-__td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-with-****Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html>>><http__://nabb__l__e.com/JaxRS-Client-__with-*__*__Deletes-td5731444.html
> <http://nabbl__e.com/JaxRS-Client-__with-**__Deletes-td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-__with-**Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-__with-**Deletes-td5731444.html>>
>
>
> <http://nabble.com/JaxRS-____Client-with-**Deletes-____td5731444.html
> <http://nabble.com/JaxRS-__Client-with-**Deletes-__td5731444.html>
> <http://nabble.com/JaxRS-__Client-with-**Deletes-__td5731444.html <http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>>>>
>
>
> <http:/**/cxf.547215.n5.__nabb____le.com/**JaxRS-Client-____with-__Deletes-**
> <http://nabb__le.com/**JaxRS-Client-__with-__Deletes-**>
> <http://nabble.com/**JaxRS-__Client-__with-Deletes-**
> <http://nabble.com/**JaxRS-Client-__with-Deletes-**>>
>
>
> <http://cxf.547215.n5.nabble.____com/**JaxRS-Client-with-____Deletes-**
>
> <http://cxf.547215.n5.nabble.__com/**JaxRS-Client-with-__Deletes-**
> <http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>>>
>
>
>
> td5731444.html<http://cxf.__54____7215.n5.nabble.com/JaxRS-______Client-with-Deletes-__td5731444.____html
> <http://54__7215.n5.nabble.com/JaxRS-____Client-with-Deletes-td5731444.____html>
>
> <http://547215.n5.nabble.com/__JaxRS-__Client-with-Deletes-__td5731444.__html
> <http://547215.n5.nabble.com/JaxRS-__Client-with-Deletes-td5731444.__html>>
>
>
>
> <http://cxf.547215.n5.nabble.____com/JaxRS-Client-with-__Deletes-__td5731444.html
>
>
> <http://cxf.547215.n5.nabble.__com/JaxRS-Client-with-Deletes-__td5731444.html
> <http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>>>>
>
>
>
>
>
>
>
>
> Cheers, Sergey
>
>
>
>
> Thank you!
>
>
> Regards, Julio
>
>
> [image: i2cat]
> Julio C.
> Barrera Juez
> Office
> phone: +34
> 93 357 99
> 27
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed
> Applications and
> Networks
> Area (DANA)
> i2CAT
> Foundation,
> Barcelona,
> Spain
> http://dana.i2cat.net
>
>
>
>
>
>
> --
>
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog:
> http://sberyozkin.blogspot.com
>
>
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
>
>
>
>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 17/10/13 15:45, Julio Carlos Barrera Juez wrote:
> I tried the same without changing the URI, only changing the method and
> it didn't work neither. I changed the original method to HEAD (changing
> the JAX-RS annotated interface), changing it to DELETE in the filter.
> The client sends HEAD requests anyway. Why is not my filter changing the
> request method?
This is because the CXF interceptor which runs JAX-RS 2.0 client request
filters used to run after CXF HTTPConduit has been already initialized,
has just been fixed (CXF 2.7.8, trunk).
So for now, the custom CXF interceptors is the way to go,
check http://cxf.apache.org/docs/interceptors.html
use the stage before WRITE, says USER_LOGICAL
Cheers, Sergey
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
> On 17 October 2013 16:37, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>> wrote:
>
> On 17/10/13 14:49, Julio Carlos Barrera Juez wrote:
>
> Bad news then.
>
>
> I'm not sure why did you expect DELETE with body to work, we
> discussed it yesterday and confirmed it was not yet possible, please
> make sure you watch that JIRA I linked to to try it once it gets
> fixed (though I don't know yet how feasible it is)
>
>
> Anyway the filter does not work, because the
> calls requestContext.setUri(...) did not change the real URI
> used at the
> end. But the method requestContext.setMEthod(...) worked...
>
> Right, setUri does not work from client filters, thanks for catching it.
> I've been certain a test is there, but it is only pre-matching
> container request filters which are tested on setRequestUri, so it
> needs to be fixed
>
> Cheers, Sergey
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
> On 17 October 2013 13:45, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>> wrote:
>
> Hi
>
> The method is definitely returned in CXF 2.7.7, I've just
> added a
> test confirming that. A lot of fixes went into the
> client-side 2.0
> code, some of it is still on the trunk only as they deal
> more with
> various very edgy TCK issues, I'm not sure yet if they
> should make
> to CXF 2.7.8 or not, but a method getter works in 2.7.7
>
> Re the actual exception, I guess this is because we don't have
> DELETE with body supported yet
>
> Sergey
>
> On 17/10/13 11:51, Julio Carlos Barrera Juez wrote:
>
> Hi Sergey.
>
> First of all, excuse me by the duplicate message.
>
> I have just written a Filter like this:
>
> public class PostToDeleteWithBodyFilter implements
> ClientRequestFilter {
>
> public final static StringEXTRA_PATH=
> "/mutatePOSTtoDELETE";
>
>
> @Override
> public void filter(ClientRequestContext requestContext)
> throws
> IOException {
> String method = requestContext.getMethod();
> String path = requestContext.getUri().____getPath();
>
>
> if (path != null && path.endsWith(EXTRA_PATH)) {
> // remove EXTRA_PATH
> requestContext.setUri(URI.____create(path.substring(0,
> path.length() -
>
> EXTRA_PATH.length())));
> // transform POST into DELETE
> requestContext.setMethod("____DELETE");
>
> }
> }
> }
>
> I have some issues again. The method var is null. And
> the most
> important, an exception is thrown when I use this filter:
>
> Caused by: java.io.IOException: IOException invoking
> http://<my_server>/real_path/____mutatePOSTtoDELETE:
> insufficient
> data written
> at
>
> sun.reflect.____NativeConstructorAccessorImpl.____newInstance0(Native
> Method)
> at
>
> sun.reflect.____NativeConstructorAccessorImpl.____newInstance(____NativeConstructorAccessorImpl.____java:39)
> at
>
> sun.reflect.____DelegatingConstructorAccessorI____mpl.newInstance(____DelegatingConstructorAccessorI____mpl.java:27)
> at
>
> java.lang.reflect.Constructor.____newInstance(Constructor.__java:__513)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.____mapException(HTTPConduit.java:____1338)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.close(____HTTPConduit.java:1322)
> at
>
> org.apache.cxf.transport.____AbstractConduit.close(____AbstractConduit.java:56)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit.close(__HTTPConduit.__java:622)
> at
>
> org.apache.cxf.interceptor.____MessageSenderInterceptor$____MessageSenderEndingInterceptor____.handleMessage(____MessageSenderInterceptor.java:____62)
>
> ... 31 more
> Caused by: java.io.IOException: insufficient data written
> at
>
> sun.net.www.protocol.http.____HttpURLConnection$____StreamingOutputStream.close(____HttpURLConnection.java:2861)
> at
>
> sun.net.www.protocol.http.____HttpURLConnection.____getInputStream(____HttpURLConnection.java:1175)
> at
>
> java.net.HttpURLConnection.____getResponseCode(____HttpURLConnection.java:379)
> at
>
> org.apache.cxf.transport.http.____URLConnectionHTTPConduit$____URLConnectionWrappedOutputStre____am.getResponseCode(____URLConnectionHTTPConduit.java:____260)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.____handleResponseInternal(____HTTPConduit.java:1517)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.____handleResponse(HTTPConduit.____java:1490)
> at
>
> org.apache.cxf.transport.http.____HTTPConduit$____WrappedOutputStream.close(____HTTPConduit.java:1309)
>
> ... 34 more
>
> I tried to detect the special message to be mutated
> using an
> extra path
> string appended to the real path. It worked, it was
> detected, but
> something went wrong...
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027> <tel:%2B34%2093%20357%2099%__2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
>
> On 17 October 2013 12:17, Sergey Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__> wrote:
>
> Hi
>
> Can you register an instance of JAX-RS 2.0
> ClientRequestFilter (as a
> provider) and set your method & request URI if
> needed there ?
> That should make it simpler for you.
>
> Re using a custom CXF interceptor, it really
> should have the
> properties which you check already set on the
> message passed to
> handleMessage(), that message is an out message,
> so you
> should have
> "message ==
> message.getExchange().______getOutMessage()" hold
>
> true.
>
>
> Cheers, Sergey
>
>
> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>
> I'm trying to workaround this problem with an
> output CXF
> interceptor. I
> have modified the DELETE request to be a POST
> request
> allowing a
> body. I
> want that my interceptor will detect the POST
> request
> and will
> change it to
> a DELETE. I'm having some problems to achieve
> it. How
> can the
> interceptor
> modify the message object to achieve my goal?
>
> I have written something like this:
>
> public class
> PostToDeleteWithBodyIntercepto______r extends
> AbstractPhaseInterceptor<______Message> {
>
>
>
> public final static String EXTRA_PATH =
> "/mutatePOSTtoDELETE";
>
> public PostToDeleteWithBodyIntercepto______r() {
>
>
> super(Phase.PRE_PROTOCOL);
> }
>
> public void handleMessage(Message message) {
> String path = (String)
>
>
> message.getExchange().______getOutMessage().get(Message.______REQUEST_URI);
> String method = (String)
>
>
> message.getExchange().______getOutMessage().get(Message.______HTTP_REQUEST_METHOD);
>
>
> if (method != null && method.equals("POST")
> && path
> != null &&
> path.endsWith(EXTRA_PATH)) {
> // TODO remove EXTRA_PATH
> // TODO transform POST into DELETE
> }
> }
> }
>
> I have a few doubts:
>
> - I don't know how to modify the path and the
> method of the
> request. I
>
> have tried modifying the content of the
> - I don't know what is the exact phase
> where apply it.
> - Why do I need to look for exchange, out
> message
> to see
> current path
>
> and method? It should be in the message,
> but the
> values are
> null.
>
> Thank you!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:54, Sergey Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__> wrote:
>
> Hi,
>
> On 16/10/13 15:36, Julio Carlos Barrera
> Juez wrote:
>
> Yes, the server is not under my
> control. I want to
> develop a client
> because
> I like how CXF works and it is a
> dependency for
> other
> issues in my
> project.
> Obviously I would never develop a
> service with
> body in
> DELETE requests.
>
> The, taking into account that I'm
> using CXF
> 2.7.x, is it
> possible to
> workaround my problem using CXF?
>
> Probably not at the moment,
>
> I've opened
> https://issues.apache.org/**______jira/browse/CXF-5337
> <https://issues.apache.org/**____jira/browse/CXF-5337>
> <https://issues.apache.org/**____jira/browse/CXF-5337
> <https://issues.apache.org/**__jira/browse/CXF-5337>>
>
> <https://issues.apache.org/**____jira/browse/CXF-5337
> <https://issues.apache.org/**__jira/browse/CXF-5337>
> <https://issues.apache.org/**__jira/browse/CXF-5337
> <https://issues.apache.org/**jira/browse/CXF-5337>>><https:/__/____issues.apache.org/jira/____browse/__CXF-5337
> <http://issues.apache.org/jira/__browse/__CXF-5337>
> <http://issues.apache.org/__jira/browse/__CXF-5337
> <http://issues.apache.org/jira/browse/__CXF-5337>>
>
>
> <https://issues.apache.org/____jira/browse/CXF-5337
> <https://issues.apache.org/__jira/browse/CXF-5337>
>
> <https://issues.apache.org/__jira/browse/CXF-5337
> <https://issues.apache.org/jira/browse/CXF-5337>>>>
>
>
> Please watch it.
>
> In meantime, may be it is possible to
> 'tunnel' it,
> example,
> use POST but
> set some header with the real/intended
> HTTP verb
> such as
> DELETE, the target
> server would need to replace POST with
> DELETE, the
> easy way
> is to say
> create Servlet filter which will use
> HTTPServletRequest
> wrapper to return
> DELETE, some work is needed there but no
> changes to the
> server code itself
> will be required.
>
> Otherwise - try snapshots once CXF-5337
> gets resolved
>
> Thanks, Sergey
>
> Thank you Sergey!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and Networks
> Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:23, Sergey Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__> wrote:
>
> Right, looks like the following has
> to be
> done with
> HTTPClient:
>
>
> https://code.google.com/p/****______rest-client/source/browse/__**
> <https://code.google.com/p/****____rest-client/source/browse/**>
>
> <https://code.google.com/p/***__*__rest-client/source/browse/*__* <https://code.google.com/p/****__rest-client/source/browse/**>>
>
>
> <https://code.google.com/p/***____*rest-client/source/browse/*__* <https://code.google.com/p/***__*rest-client/source/browse/**>
>
> <https://code.google.com/p/***__*rest-client/source/browse/**
> <https://code.google.com/p/****rest-client/source/browse/**>>__>__<h__ttps://code.google.com/__p/*__*__rest-client/source/__browse/*__*
> <http://code.google.com/p/*__*__rest-client/source/browse/*__*>
>
> <http://code.google.com/p/**____rest-client/source/browse/**
> <http://code.google.com/p/**__rest-client/source/browse/**>>
>
>
> <https://code.google.com/p/**____rest-client/source/browse/**
> <https://code.google.com/p/**__rest-client/source/browse/**>
>
> <https://code.google.com/p/**__rest-client/source/browse/**
> <https://code.google.com/p/**rest-client/source/browse/**>>>__>
>
>
> restclient-lib/src/main/java/*______***org/wiztools/__restclient/____http/****
>
>
> EntityEnclosingDelete.java<______htt**ps://code.google.com/p/______rest-**
> <http://code.google.com/p/____rest-**>
> <http://code.google.com/p/____rest-**
> <http://code.google.com/p/__rest-**>>
>
> <http://code.google.com/p/____rest-**
> <http://code.google.com/p/__rest-**>
> <http://code.google.com/p/__rest-**
> <http://code.google.com/p/rest-**>>>
>
>
> client/source/browse/**______restclient-lib/src/main/java/*______*
>
>
> org/wiztools/restclient/http/*______*EntityEnclosingDelete.__java<__ht__tps://code.google.__com/p/__rest-__client/source/__browse/____restclient-lib/src/__main/java/____org/wiztools/__restclient/http/______EntityEnclosingDelete.java
> <http://code.google.com/p/__rest-__client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java>
>
> <http://code.google.com/p/__rest-__client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java
> <http://code.google.com/p/rest-__client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>>
>
>
>
> <https://code.google.com/p/____rest-client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java
> <https://code.google.com/p/__rest-client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>
>
>
> <https://code.google.com/p/__rest-client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java
> <https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>>>>
>
>
>
>
> This is the code based on the
> advice from
> HttpClient
> forums.
>
> I guess we should check if CXF Async
> Conduit can be
> updated respectively
>
> By the way, I'm assuming you have
> to do
> DELETE with
> a body because you
> have some existing/legacy service
> expecting
> it this
> way ? Now and then
> users ask about it, and I don't
> mind to get the
> Async HTTP conduit
> updated
> a bit anyway, but if you have say
> a CXF server
> listening, then I'm sure
> there could be an easier way :-)
>
> Cheers, Sergey
>
>
> On 16/10/13 15:11, Julio Carlos
> Barrera
> Juez wrote:
>
> Looking for logs, I've realized
> that the
> property
> is producing changes.
>
> I
> mean the Async HTTP client is
> being used.
> However my DELETE request has
> no
> body. My client interface is
> JAX-RS
> annotated,
> my Resource class is JaxB
> annotated:
>
> @Path("/server/path")
> @DELETE
>
> @Consumes(MediaType.****______APPLICATION_JSON)
>
>
>
>
> public void
> deleteResource(Resource resource);
>
> I have a create method working
> with de same
> configuration and it works:
>
> @Path("/server/path")
> @POST
>
> @Consumes(MediaType.****______APPLICATION_JSON)
>
>
>
>
> public void
> createResource(Resource resource);
>
> I'm using Jackson as JSON
> serializer, but I
> guess it has no relation
> with
> this problem.
>
> These log lines show that the
> DELETE
> request has
> content-lenght 0 and
> the Async HTTP client is
> being used
>
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.cxf.transport.http.______****asyncclient.****______AsyncHTTPConduitFactory$2
>
>
>
> -
>
> Connection leased: [id: 2][route:
> {}->http://my_server][total kept
> alive:
> 0; route allocated: 1 of 1000;
> total
> allocated:
> 0 of 5000]
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.cxf.transport.http.______****asyncclient.****______AsyncHTTPConduitFactory$3
>
>
>
> -
> [exchange: 3] Connection
> allocated:
>
> [id:2][route:{}->http:/my_****______server][state:null]
>
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][r:__]:
>
>
> Set
> attribute
> http.nio.exchange-handler
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][__rw:]__:
>
>
> Event
> set [w]
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][__rw:]__:
>
>
> Set
>
>
> attribute
> http.nio.http-exchange-state
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.cxf.transport.http.______****asyncclient.****______AsyncHTTPConduitFactory$3
>
>
>
> -
>
> [exchange: 3] Attempt 1 to
> execute request
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2
> 192.168.254.86:35152 <http://192.168.254.86:35152>
> <http://192.168.254.86:35152>
>
>
> <http://192.168.254.86:35152><____->server___****ip[ACTIVE][__rw:]__:
>
>
> Set
> timeout
> 60000
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.****
>
> protocol.RequestAuthCache
>
> -
> Auth cache not set in the context
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.http.client.****______protocol.****______RequestTargetAuthentication
>
>
> -
>
> Target
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
>
>
> org.apache.http.client.****______protocol.****______RequestProxyAuthentication
>
>
> -
>
> Proxy
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >> *
> DELETE* /server/path HTTP/1.1
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Accept: text/plain
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> User-Agent: Apache CXF 2.7.4
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> *Content-Length:
> 0*
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Host:
> my_server
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Connection: Keep-Alive
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and
> Networks
> Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 15:17,
> Julio Carlos
> Barrera
> Juez <
> juliocarlos.barrera@i2cat.net
> <ma...@i2cat.net>
> <mailto:juliocarlos.barrera@__i2cat.net
> <ma...@i2cat.net>>
> <mailto:juliocarlos.barrera@
> <mailto:juliocarlos.barrera@>____i2cat.net <http://i2cat.net>
>
> <mailto:juliocarlos.barrera@__i2cat.net
> <ma...@i2cat.net>>>> wrote:
>
> I don't know how to
> install CXF
> Async HTTP
> transport. I have the maven
>
> artifact in my project
> dependencies, but
> nothing else.
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357
> 99 27 <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed Applications and
> Networks Area
> (DANA)
> i2CAT Foundation,
> Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 13:14,
> Sergey
> Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__>
>
> wrote:
>
> I guess you don't have CXF
> Async HTTP
> transport installed ?
>
> Other than that I've
> no idea, if it
> won;t work with the
> Async module
> then
> I guess it is possible
> to do
> Sergey
>
> On 16/10/13 11:49,
> Julio Carlos
> Barrera
> Juez wrote:
>
> I tried to use
> this information
> before, but I don't
> know how to
> solve
>
> my
> problem.
>
> I have something
> like this:
>
> ProxyClassLoader
> classLoader = new
> ProxyClassLoader();
>
>
>
> classLoader.addLoader(******______IServiceInterface.class.****
> getClassLoader());
>
>
> classLoader.addLoader(******______JAXRSClientFactoryBean.__class.*____*****
>
>
>
>
>
> getClassLoader());
>
>
> JAXRSClientFactoryBean bean
> = new
>
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
>
> bean.setResourceClass(******______IServiceInterface.class);
>
>
> bean.setClassLoader(******______classLoader);
>
>
>
>
>
>
> client
> (IServiceInterface)
> bean.create();
>
> Then I can use the
> client
> object as
> usual. But if
> fails sending
> DELETE
> requests with body.
>
> I tried doing this:
>
> ProxyClassLoader
> classLoader = new
> ProxyClassLoader();
>
>
>
> classLoader.addLoader(******______IServiceInterface.class.****
> getClassLoader());
>
>
> classLoader.addLoader(******______JAXRSClientFactoryBean.__class.*____*****
>
>
>
>
>
> getClassLoader());
>
>
> JAXRSClientFactoryBean bean
> = new
>
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
>
> bean.setResourceClass(******______IServiceInterface.class);
>
>
> bean.setClassLoader(******______classLoader);
>
>
>
>
>
>
> // allow body in
> DELETE
> requests
> Client client =
> bean.create();
>
>
>
> WebClient.getConfig(client).**______****getRequestContext().__put(__"*__*
>
>
> use.****
> async.http.conduit",
> true);
>
> (IServiceInterface)
>
> client.******______whateverMethodThatSendsDelete(______**
>
>
>
> ****);
>
>
>
> But it didn't work.
>
> What am I missing?
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34
> 93 357 99
> 27 <tel:%2B34%2093%20357%2099%__2027>
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed
> Applications and
> Networks Area (DANA)
> i2CAT Foundation,
> Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013
> 12:00,
> Sergey
> Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>
>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>__>
>
>
> wrote:
>
> Hi
>
>
> On 16/10/13 09:18,
> Julio Carlos
> Barrera Juez
> wrote:
>
> Hi.
>
>
> I'm
> creating a REST
> client
> using
> JAXRSClientFactoryBean and
>
> ProxyClassLoader
> based on a
> JAXRS
> annotated
> Java interface.
>
> I want to
> send a
> DELETE with
> body,
> which is not
> recommended by
> RESTful
>
> philosophy, but it is
> allowed by
> HTTP 1.1
> RFC.
>
> The body
> is not
> sent by the
> client and
> I have
> read a lot of
> problems
> to
> allow it.
>
> Is it
> possible send
> a body
> in my DELETE
> requests with this
> configuration?
>
>
> Please check
> this thread
>
>
> http://cxf.547215.n5.nabble.**______******com/JaxRS-Client-__with-__**
>
> Deletes-****
>
>
> td5731444.html<http://cxf.****______54**7215.n5.nabble.com/____JaxRS-*__***
> <http://7215.n5.nabble.com/__JaxRS-*__***>
> <http://7215.n5.nabble.com/__JaxRS-*__***
> <http://7215.n5.nabble.com/JaxRS-*__***>>
>
> <http://7215.n5.nabble.com/____JaxRS-****
> <http://7215.n5.nabble.com/__JaxRS-****>
> <http://7215.n5.nabble.com/__JaxRS-****
> <http://7215.n5.nabble.com/JaxRS-****>>><http://7215.n5.____nabble.com/__JaxRS-**
> <http://nabble.com/__JaxRS-**>
> <http://7215.n5.nabble.com/____JaxRS-**
> <http://7215.n5.nabble.com/__JaxRS-**>>
>
> <http://7215.n5.nabble.com/____JaxRS-**
> <http://7215.n5.nabble.com/__JaxRS-**>
> <http://7215.n5.nabble.com/__JaxRS-**
> <http://7215.n5.nabble.com/JaxRS-**>>>>
>
> <http://547215.n5.nabble.com/*______*JaxRS-**
> <http://547215.n5.nabble.com/*____*JaxRS-**>
> <http://547215.n5.nabble.com/*____*JaxRS-**
> <http://547215.n5.nabble.com/*__*JaxRS-**>>
>
> <http://547215.n5.nabble.com/*____*JaxRS-**
> <http://547215.n5.nabble.com/*__*JaxRS-**>
> <http://547215.n5.nabble.com/*__*JaxRS-**
> <http://547215.n5.nabble.com/**JaxRS-**>>><http://547215.n5.______nabble.com/JaxRS-**
> <http://nabble.com/JaxRS-**>
> <http://nabble.com/JaxRS-**>
>
> <http://547215.n5.nabble.com/____JaxRS-**
> <http://547215.n5.nabble.com/__JaxRS-**>
> <http://547215.n5.nabble.com/__JaxRS-**
> <http://547215.n5.nabble.com/JaxRS-**>>>>
>
>
>
>
> Client-with-Deletes-td5731444.______******html<http://cxf.____547215.
> <http://cxf.547215.>__n5.
>
> <http://cxf.547215.n5.>****
> nabble.com/JaxRS-Client-with-*______***Deletes-td5731444.html
> <http://nabble.com/JaxRS-Client-with-*____***Deletes-td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-with-*__***Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-with-*__***Deletes-td5731444.html>>
>
>
> <http://nabble.com/JaxRS-____Client-with-****Deletes-____td5731444.html
> <http://nabble.com/JaxRS-__Client-with-****Deletes-__td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-with-****Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html>>><http__://nabb__l__e.com/JaxRS-Client-__with-*__*__Deletes-td5731444.html
> <http://nabbl__e.com/JaxRS-Client-__with-**__Deletes-td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-__with-**Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-__with-**Deletes-td5731444.html>>
>
>
> <http://nabble.com/JaxRS-____Client-with-**Deletes-____td5731444.html
> <http://nabble.com/JaxRS-__Client-with-**Deletes-__td5731444.html>
> <http://nabble.com/JaxRS-__Client-with-**Deletes-__td5731444.html <http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>>>>
>
>
> <http:/**/cxf.547215.n5.__nabb____le.com/**JaxRS-Client-____with-__Deletes-**
> <http://nabb__le.com/**JaxRS-Client-__with-__Deletes-**>
> <http://nabble.com/**JaxRS-__Client-__with-Deletes-**
> <http://nabble.com/**JaxRS-Client-__with-Deletes-**>>
>
>
> <http://cxf.547215.n5.nabble.____com/**JaxRS-Client-with-____Deletes-**
>
> <http://cxf.547215.n5.nabble.__com/**JaxRS-Client-with-__Deletes-**
> <http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>>>
>
>
>
> td5731444.html<http://cxf.__54____7215.n5.nabble.com/JaxRS-______Client-with-Deletes-__td5731444.____html
> <http://54__7215.n5.nabble.com/JaxRS-____Client-with-Deletes-td5731444.____html>
>
> <http://547215.n5.nabble.com/__JaxRS-__Client-with-Deletes-__td5731444.__html
> <http://547215.n5.nabble.com/JaxRS-__Client-with-Deletes-td5731444.__html>>
>
>
>
> <http://cxf.547215.n5.nabble.____com/JaxRS-Client-with-__Deletes-__td5731444.html
>
>
> <http://cxf.547215.n5.nabble.__com/JaxRS-Client-with-Deletes-__td5731444.html
> <http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>>>>
>
>
>
>
>
>
>
>
> Cheers, Sergey
>
>
>
>
> Thank you!
>
>
> Regards, Julio
>
>
> [image: i2cat]
> Julio C.
> Barrera Juez
> Office
> phone: +34
> 93 357 99
> 27
>
> <tel:%2B34%2093%20357%2099%____2027>
>
>
> Distributed
> Applications and
> Networks
> Area (DANA)
> i2CAT
> Foundation,
> Barcelona,
> Spain
> http://dana.i2cat.net
>
>
>
>
>
>
> --
>
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog:
> http://sberyozkin.blogspot.com
>
>
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
>
>
>
>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
I tried the same without changing the URI, only changing the method and it
didn't work neither. I changed the original method to HEAD (changing the
JAX-RS annotated interface), changing it to DELETE in the filter. The
client sends HEAD requests anyway. Why is not my filter changing the
request method?
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 17 October 2013 16:37, Sergey Beryozkin <sb...@gmail.com> wrote:
> On 17/10/13 14:49, Julio Carlos Barrera Juez wrote:
>
>> Bad news then.
>>
>
> I'm not sure why did you expect DELETE with body to work, we discussed it
> yesterday and confirmed it was not yet possible, please make sure you watch
> that JIRA I linked to to try it once it gets fixed (though I don't know yet
> how feasible it is)
>
>
> Anyway the filter does not work, because the
>> calls requestContext.setUri(...) did not change the real URI used at the
>> end. But the method requestContext.setMEthod(...) worked...
>>
>> Right, setUri does not work from client filters, thanks for catching it.
> I've been certain a test is there, but it is only pre-matching container
> request filters which are tested on setRequestUri, so it needs to be fixed
>
> Cheers, Sergey
>
>> i2cat
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net <http://dana.i2cat.net/>
>>
>>
>> On 17 October 2013 13:45, Sergey Beryozkin <sberyozkin@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>> Hi
>>
>> The method is definitely returned in CXF 2.7.7, I've just added a
>> test confirming that. A lot of fixes went into the client-side 2.0
>> code, some of it is still on the trunk only as they deal more with
>> various very edgy TCK issues, I'm not sure yet if they should make
>> to CXF 2.7.8 or not, but a method getter works in 2.7.7
>>
>> Re the actual exception, I guess this is because we don't have
>> DELETE with body supported yet
>>
>> Sergey
>>
>> On 17/10/13 11:51, Julio Carlos Barrera Juez wrote:
>>
>> Hi Sergey.
>>
>> First of all, excuse me by the duplicate message.
>>
>> I have just written a Filter like this:
>>
>> public class PostToDeleteWithBodyFilter implements
>> ClientRequestFilter {
>>
>> public final static StringEXTRA_PATH= "/mutatePOSTtoDELETE";
>>
>>
>> @Override
>> public void filter(ClientRequestContext requestContext) throws
>> IOException {
>> String method = requestContext.getMethod();
>> String path = requestContext.getUri().__**getPath();
>>
>>
>> if (path != null && path.endsWith(EXTRA_PATH)) {
>> // remove EXTRA_PATH
>> requestContext.setUri(URI.__**create(path.substring(0,
>> path.length() -
>>
>> EXTRA_PATH.length())));
>> // transform POST into DELETE
>> requestContext.setMethod("__**DELETE");
>>
>> }
>> }
>> }
>>
>> I have some issues again. The method var is null. And the most
>> important, an exception is thrown when I use this filter:
>>
>> Caused by: java.io.IOException: IOException invoking
>> http://<my_server>/real_path/_**_mutatePOSTtoDELETE: insufficient
>> data written
>> at
>> sun.reflect.__**NativeConstructorAccessorImpl.**__newInstance0(Native
>> Method)
>> at
>> sun.reflect.__**NativeConstructorAccessorImpl.**__newInstance(__*
>> *NativeConstructorAccessorImpl.**__java:39)
>> at
>> sun.reflect.__**DelegatingConstructorAccessorI**
>> __mpl.newInstance(__**DelegatingConstructorAccessorI**__mpl.java:27)
>> at
>> java.lang.reflect.Constructor.**__newInstance(Constructor.**
>> java:__513)
>> at
>> org.apache.cxf.transport.http.**__HTTPConduit$__**
>> WrappedOutputStream.__**mapException(HTTPConduit.java:**__1338)
>> at
>> org.apache.cxf.transport.http.**__HTTPConduit$__**
>> WrappedOutputStream.close(__**HTTPConduit.java:1322)
>> at
>> org.apache.cxf.transport.__**AbstractConduit.close(__**
>> AbstractConduit.java:56)
>> at
>> org.apache.cxf.transport.http.**__HTTPConduit.close(**
>> HTTPConduit.__java:622)
>> at
>> org.apache.cxf.interceptor.__**MessageSenderInterceptor$__**
>> MessageSenderEndingInterceptor**__.handleMessage(__**
>> MessageSenderInterceptor.java:**__62)
>>
>> ... 31 more
>> Caused by: java.io.IOException: insufficient data written
>> at
>> sun.net.www.protocol.http.__**HttpURLConnection$__**
>> StreamingOutputStream.close(__**HttpURLConnection.java:2861)
>> at
>> sun.net.www.protocol.http.__**HttpURLConnection.__**
>> getInputStream(__**HttpURLConnection.java:1175)
>> at
>> java.net.HttpURLConnection.__**getResponseCode(__**
>> HttpURLConnection.java:379)
>> at
>> org.apache.cxf.transport.http.**__URLConnectionHTTPConduit$__**
>> URLConnectionWrappedOutputStre**__am.getResponseCode(__**
>> URLConnectionHTTPConduit.java:**__260)
>> at
>> org.apache.cxf.transport.http.**__HTTPConduit$__**
>> WrappedOutputStream.__**handleResponseInternal(__**HTTPConduit.java:1517)
>> at
>> org.apache.cxf.transport.http.**__HTTPConduit$__**
>> WrappedOutputStream.__**handleResponse(HTTPConduit.__**java:1490)
>> at
>> org.apache.cxf.transport.http.**__HTTPConduit$__**
>> WrappedOutputStream.close(__**HTTPConduit.java:1309)
>>
>> ... 34 more
>>
>> I tried to detect the special message to be mutated using an
>> extra path
>> string appended to the real path. It worked, it was detected, but
>> something went wrong...
>>
>> i2cat
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%**2027>
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net <http://dana.i2cat.net/>
>>
>>
>>
>> On 17 October 2013 12:17, Sergey Beryozkin <sberyozkin@gmail.com
>> <ma...@gmail.com>
>> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>**>
>> wrote:
>>
>> Hi
>>
>> Can you register an instance of JAX-RS 2.0
>> ClientRequestFilter (as a
>> provider) and set your method & request URI if needed there ?
>> That should make it simpler for you.
>>
>> Re using a custom CXF interceptor, it really should have the
>> properties which you check already set on the message passed
>> to
>> handleMessage(), that message is an out message, so you
>> should have
>> "message == message.getExchange().____**getOutMessage()"
>> hold
>>
>> true.
>>
>>
>> Cheers, Sergey
>>
>>
>> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>>
>> I'm trying to workaround this problem with an output CXF
>> interceptor. I
>> have modified the DELETE request to be a POST request
>> allowing a
>> body. I
>> want that my interceptor will detect the POST request
>> and will
>> change it to
>> a DELETE. I'm having some problems to achieve it. How
>> can the
>> interceptor
>> modify the message object to achieve my goal?
>>
>> I have written something like this:
>>
>> public class PostToDeleteWithBodyIntercepto**____r
>> extends
>> AbstractPhaseInterceptor<____**Message> {
>>
>>
>>
>> public final static String EXTRA_PATH =
>> "/mutatePOSTtoDELETE";
>>
>> public PostToDeleteWithBodyIntercepto**____r() {
>>
>>
>> super(Phase.PRE_PROTOCOL);
>> }
>>
>> public void handleMessage(Message message) {
>> String path = (String)
>>
>> message.getExchange().____**getOutMessage().get(Message.__**
>> __REQUEST_URI);
>> String method = (String)
>>
>> message.getExchange().____**getOutMessage().get(Message.__**
>> __HTTP_REQUEST_METHOD);
>>
>>
>> if (method != null && method.equals("POST") && path
>> != null &&
>> path.endsWith(EXTRA_PATH)) {
>> // TODO remove EXTRA_PATH
>> // TODO transform POST into DELETE
>> }
>> }
>> }
>>
>> I have a few doubts:
>>
>> - I don't know how to modify the path and the
>> method of the
>> request. I
>>
>> have tried modifying the content of the
>> - I don't know what is the exact phase where apply
>> it.
>> - Why do I need to look for exchange, out message
>> to see
>> current path
>>
>> and method? It should be in the message, but the
>> values are
>> null.
>>
>> Thank you!
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027> <tel:%2B34%2093%20357%2099%__*
>> *2027>
>>
>>
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 16:54, Sergey Beryozkin
>> <sberyozkin@gmail.com <ma...@gmail.com>
>> <mailto:sberyozkin@gmail.com
>>
>> <ma...@gmail.com>>**> wrote:
>>
>> Hi,
>>
>> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>>
>> Yes, the server is not under my control. I want
>> to
>> develop a client
>> because
>> I like how CXF works and it is a dependency for
>> other
>> issues in my
>> project.
>> Obviously I would never develop a service with
>> body in
>> DELETE requests.
>>
>> The, taking into account that I'm using CXF
>> 2.7.x, is it
>> possible to
>> workaround my problem using CXF?
>>
>> Probably not at the moment,
>>
>> I've opened
>> https://issues.apache.org/**__**__jira/browse/CXF-5337<https://issues.apache.org/**____jira/browse/CXF-5337>
>> <https://issues.apache.org/**_**_jira/browse/CXF-5337<https://issues.apache.org/**__jira/browse/CXF-5337>
>> >
>> <https://issues.apache.org/**_**
>> _jira/browse/CXF-5337<https://issues.apache.org/**__jira/browse/CXF-5337>
>> <https://issues.apache.org/****jira/browse/CXF-5337<https://issues.apache.org/**jira/browse/CXF-5337>
>> >><https:/**/____issues.apache.org/jira/__**browse/__CXF-5337<http://issues.apache.org/jira/__browse/__CXF-5337>
>> <http://issues.apache.org/**jira/browse/__CXF-5337<http://issues.apache.org/jira/browse/__CXF-5337>
>> >
>>
>> <https://issues.apache.org/__**jira/browse/CXF-5337<https://issues.apache.org/__jira/browse/CXF-5337>
>>
>> <https://issues.apache.org/**jira/browse/CXF-5337<https://issues.apache.org/jira/browse/CXF-5337>
>> >>>
>>
>>
>> Please watch it.
>>
>> In meantime, may be it is possible to 'tunnel' it,
>> example,
>> use POST but
>> set some header with the real/intended HTTP verb
>> such as
>> DELETE, the target
>> server would need to replace POST with DELETE, the
>> easy way
>> is to say
>> create Servlet filter which will use
>> HTTPServletRequest
>> wrapper to return
>> DELETE, some work is needed there but no changes to
>> the
>> server code itself
>> will be required.
>>
>> Otherwise - try snapshots once CXF-5337 gets resolved
>>
>> Thanks, Sergey
>>
>> Thank you Sergey!
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>> <tel:%2B34%2093%20357%2099%__**2027>
>>
>>
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 16:23, Sergey Beryozkin
>> <sberyozkin@gmail.com
>> <ma...@gmail.com> <mailto:sberyozkin@gmail.com
>>
>> <ma...@gmail.com>>**> wrote:
>>
>> Right, looks like the following has to be
>> done with
>> HTTPClient:
>>
>>
>> https://code.google.com/p/******____rest-client/source/browse/**
>> ** <https://code.google.com/p/****____rest-client/source/browse/**>
>> <https://code.google.com/p/******__rest-client/source/browse/****<https://code.google.com/p/****__rest-client/source/browse/**>
>> >
>>
>> <https://code.google.com/p/*****__*rest-client/source/browse/****<https://code.google.com/p/***__*rest-client/source/browse/**>
>> <https://code.google.com/p/******rest-client/source/browse/**<https://code.google.com/p/****rest-client/source/browse/**>
>> >**>__<h__ttps://code.google.com/**p/*__*__rest-client/source/**
>> browse/*__*<http://code.google.com/p/*__*__rest-client/source/browse/*__*>
>> <http://code.google.com/p/**__**rest-client/source/browse/**<http://code.google.com/p/**__rest-client/source/browse/**>
>> >
>>
>> <https://code.google.com/p/**_**_rest-client/source/browse/**<https://code.google.com/p/**__rest-client/source/browse/**>
>> <https://code.google.com/p/****rest-client/source/browse/**<https://code.google.com/p/**rest-client/source/browse/**>
>> >>**>
>>
>> restclient-lib/src/main/java/***____***org/wiztools/**
>> restclient/____http/****
>>
>> EntityEnclosingDelete.java<___**_htt**ps://code.google.com/p/_**
>> ___rest-** <http://code.google.com/p/____rest-**>
>> <http://code.google.com/p/__**rest-**<http://code.google.com/p/__rest-**>
>> >
>> <http://code.google.com/p/__**rest-**<http://code.google.com/p/__rest-**>
>> <http://code.google.com/p/**rest-**<http://code.google.com/p/rest-**>
>> >>
>>
>> client/source/browse/**____**restclient-lib/src/main/java/***
>> ____*
>>
>> org/wiztools/restclient/http/***____*EntityEnclosingDelete.**
>> java<__ht__tps://code.google.**com/p/__rest-__client/source/**
>> browse/____restclient-lib/src/**main/java/____org/wiztools/**
>> restclient/http/____**EntityEnclosingDelete.java<http://code.google.com/p/__rest-__client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java>
>> <http://code.google.com/p/**rest-__client/source/browse/__**
>> restclient-lib/src/main/java/_**_org/wiztools/restclient/http/**
>> __EntityEnclosingDelete.java<http://code.google.com/p/rest-__client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>
>> >
>>
>>
>> <https://code.google.com/p/__**rest-client/source/browse/__**
>> restclient-lib/src/main/java/_**_org/wiztools/restclient/http/**
>> __EntityEnclosingDelete.java<https://code.google.com/p/__rest-client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>
>>
>> <https://code.google.com/p/**rest-client/source/browse/**
>> restclient-lib/src/main/java/**org/wiztools/restclient/http/**
>> EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>> >>>
>>
>>
>>
>>
>> This is the code based on the advice from
>> HttpClient
>> forums.
>>
>> I guess we should check if CXF Async
>> Conduit can be
>> updated respectively
>>
>> By the way, I'm assuming you have to do
>> DELETE with
>> a body because you
>> have some existing/legacy service expecting
>> it this
>> way ? Now and then
>> users ask about it, and I don't mind to get
>> the
>> Async HTTP conduit
>> updated
>> a bit anyway, but if you have say a CXF
>> server
>> listening, then I'm sure
>> there could be an easier way :-)
>>
>> Cheers, Sergey
>>
>>
>> On 16/10/13 15:11, Julio Carlos Barrera
>> Juez wrote:
>>
>> Looking for logs, I've realized that the
>> property
>> is producing changes.
>>
>> I
>> mean the Async HTTP client is being used.
>> However my DELETE request has
>> no
>> body. My client interface is JAX-RS
>> annotated,
>> my Resource class is JaxB
>> annotated:
>>
>> @Path("/server/path")
>> @DELETE
>>
>> @Consumes(MediaType.****____**APPLICATION_JSON)
>>
>>
>>
>>
>> public void
>> deleteResource(Resource resource);
>>
>> I have a create method working with de
>> same
>> configuration and it works:
>>
>> @Path("/server/path")
>> @POST
>>
>> @Consumes(MediaType.****____**APPLICATION_JSON)
>>
>>
>>
>>
>> public void
>> createResource(Resource resource);
>>
>> I'm using Jackson as JSON serializer,
>> but I
>> guess it has no relation
>> with
>> this problem.
>>
>> These log lines show that the DELETE
>> request has
>> content-lenght 0 and
>> the Async HTTP client is being used
>>
>> [I/O dispatcher 2] DEBUG
>>
>> org.apache.cxf.transport.http.**____****asyncclient.****____**
>> AsyncHTTPConduitFactory$2
>>
>>
>>
>> -
>>
>> Connection leased: [id: 2][route:
>> {}->http://my_server][total kept
>> alive:
>> 0; route allocated: 1 of 1000; total
>> allocated:
>> 0 of 5000]
>> [I/O dispatcher 2] DEBUG
>>
>> org.apache.cxf.transport.http.**____****asyncclient.****____**
>> AsyncHTTPConduitFactory$3
>>
>>
>>
>> -
>> [exchange: 3] Connection allocated:
>>
>> [id:2][route:{}->http:/my_******____server][state:null]
>>
>>
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152>
>>
>> <http://192.168.254.86:35152><**__->server___****ip[ACTIVE][r:**
>> ]:
>>
>>
>> Set
>> attribute
>> http.nio.exchange-handler
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152>
>>
>> <http://192.168.254.86:35152><**__->server___****ip[ACTIVE][**
>> rw:]__:
>>
>>
>> Event
>> set [w]
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152>
>>
>> <http://192.168.254.86:35152><**__->server___****ip[ACTIVE][**
>> rw:]__:
>>
>>
>> Set
>>
>>
>> attribute http.nio.http-exchange-state
>> [I/O dispatcher 2] DEBUG
>>
>> org.apache.cxf.transport.http.**____****asyncclient.****____**
>> AsyncHTTPConduitFactory$3
>>
>>
>>
>> -
>>
>> [exchange: 3] Attempt 1 to execute
>> request
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152>
>>
>> <http://192.168.254.86:35152><**__->server___****ip[ACTIVE][**
>> rw:]__:
>>
>>
>> Set
>> timeout
>> 60000
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.client.****
>>
>> protocol.RequestAuthCache
>>
>> -
>> Auth cache not set in the context
>> [I/O dispatcher 2] DEBUG
>>
>> org.apache.http.client.****___**_protocol.****____**
>> RequestTargetAuthentication
>>
>>
>> -
>>
>> Target
>>
>> auth
>> state: UNCHALLENGED
>> [I/O dispatcher 2] DEBUG
>>
>> org.apache.http.client.****___**_protocol.****____**
>> RequestProxyAuthentication
>>
>>
>> -
>>
>> Proxy
>>
>> auth
>> state: UNCHALLENGED
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.headers
>> - http-outgoing-2 >> *
>> DELETE* /server/path HTTP/1.1
>>
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.headers
>> - http-outgoing-2 >>
>> Accept: text/plain
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.headers
>> - http-outgoing-2 >>
>> User-Agent: Apache CXF 2.7.4
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.headers
>> - http-outgoing-2 >>
>> *Content-Length:
>> 0*
>>
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.headers
>> - http-outgoing-2 >>
>> Host:
>> my_server
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.headers
>> - http-outgoing-2 >>
>> Connection: Keep-Alive
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>> <tel:%2B34%2093%20357%2099%__**2027>
>>
>>
>> Distributed Applications and Networks
>> Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 15:17, Julio Carlos
>> Barrera
>> Juez <
>> juliocarlos.barrera@i2cat.net <mailto:juliocarlos.barrera@**
>> i2cat.net <ju...@i2cat.net>>
>> <mailto:juliocarlos.barrera@__**
>> i2cat.net <http://i2cat.net>
>>
>> <ma...@i2cat.net>>>>
>> wrote:
>>
>> I don't know how to install CXF
>> Async HTTP
>> transport. I have the maven
>>
>> artifact in my project
>> dependencies, but
>> nothing else.
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>> <tel:%2B34%2093%20357%2099%__**2027>
>>
>>
>> Distributed Applications and
>> Networks Area
>> (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 13:14, Sergey
>> Beryozkin
>> <sberyozkin@gmail.com
>> <ma...@gmail.com>
>> <mailto:sberyozkin@gmail.com
>>
>> <ma...@gmail.com>>**>
>>
>> wrote:
>>
>> I guess you don't have CXF
>> Async HTTP
>> transport installed ?
>>
>> Other than that I've no idea, if
>> it
>> won;t work with the Async module
>> then
>> I guess it is possible to do
>> Sergey
>>
>> On 16/10/13 11:49, Julio Carlos
>> Barrera
>> Juez wrote:
>>
>> I tried to use this
>> information
>> before, but I don't know how to
>> solve
>>
>> my
>> problem.
>>
>> I have something like this:
>>
>> ProxyClassLoader
>> classLoader = new
>> ProxyClassLoader();
>>
>>
>> classLoader.addLoader(******__**__IServiceInterface.class.****
>> getClassLoader());
>>
>> classLoader.addLoader(******__**__JAXRSClientFactoryBean.**
>> class.*____*****
>>
>>
>>
>>
>>
>> getClassLoader());
>>
>> JAXRSClientFactoryBean bean
>> = new
>> JAXRSClientFactoryBean();
>> bean.setAddress(uri);
>>
>> bean.setResourceClass(******__**__IServiceInterface.class);
>>
>>
>> bean.setClassLoader(******____**classLoader);
>>
>>
>>
>>
>>
>>
>> client (IServiceInterface)
>> bean.create();
>>
>> Then I can use the client
>> object as
>> usual. But if fails sending
>> DELETE
>> requests with body.
>>
>> I tried doing this:
>>
>> ProxyClassLoader
>> classLoader = new
>> ProxyClassLoader();
>>
>>
>> classLoader.addLoader(******__**__IServiceInterface.class.****
>> getClassLoader());
>>
>> classLoader.addLoader(******__**__JAXRSClientFactoryBean.**
>> class.*____*****
>>
>>
>>
>>
>>
>> getClassLoader());
>>
>> JAXRSClientFactoryBean bean
>> = new
>> JAXRSClientFactoryBean();
>> bean.setAddress(uri);
>>
>> bean.setResourceClass(******__**__IServiceInterface.class);
>>
>>
>> bean.setClassLoader(******____**classLoader);
>>
>>
>>
>>
>>
>>
>> // allow body in DELETE
>> requests
>> Client client =
>> bean.create();
>>
>>
>> WebClient.getConfig(client).****____****getRequestContext().**
>> put(__"*__*
>>
>>
>> use.****
>> async.http.conduit",
>> true);
>>
>> (IServiceInterface)
>>
>> client.******____**whateverMethodThatSendsDelete(**____**
>>
>>
>>
>> ****);
>>
>>
>>
>> But it didn't work.
>>
>> What am I missing?
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99
>> 27 <tel:%2B34%2093%20357%2099%**2027>
>>
>> <tel:%2B34%2093%20357%2099%__**2027>
>>
>>
>> Distributed Applications and
>> Networks Area (DANA)
>> i2CAT Foundation,
>> Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 12:00,
>> Sergey
>> Beryozkin
>> <sberyozkin@gmail.com <ma...@gmail.com>
>>
>> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>**>
>>
>>
>> wrote:
>>
>> Hi
>>
>>
>> On 16/10/13 09:18,
>> Julio Carlos
>> Barrera Juez wrote:
>>
>> Hi.
>>
>>
>> I'm creating a REST
>> client
>> using
>> JAXRSClientFactoryBean and
>> ProxyClassLoader
>> based on a
>> JAXRS annotated
>> Java interface.
>>
>> I want to send a
>> DELETE with
>> body, which is not
>> recommended by
>> RESTful
>> philosophy, but it is
>> allowed by HTTP 1.1
>> RFC.
>>
>> The body is not
>> sent by the
>> client and I have
>> read a lot of
>> problems
>> to
>> allow it.
>>
>> Is it possible send
>> a body
>> in my DELETE
>> requests with this
>> configuration?
>>
>> Please check
>> this thread
>>
>>
>> http://cxf.547215.n5.nabble.****____******com/JaxRS-Client-**
>> with-__**
>>
>> Deletes-****
>>
>> td5731444.html<http://cxf.******____54**7215.n5.nabble.com/__**
>> JaxRS-*__*** <http://7215.n5.nabble.com/__JaxRS-*__***>
>> <http://7215.n5.nabble.com/**JaxRS-*__***<http://7215.n5.nabble.com/JaxRS-*__***>
>> >
>>
>> <http://7215.n5.nabble.com/__**JaxRS-****<http://7215.n5.nabble.com/__JaxRS-****>
>> <http://7215.n5.nabble.com/**JaxRS-****<http://7215.n5.nabble.com/JaxRS-****>
>> >><http://7215.n5.__**nabble.com/__JaxRS-**<http://nabble.com/__JaxRS-**>
>> <http://7215.n5.nabble.com/__**JaxRS-**<http://7215.n5.nabble.com/__JaxRS-**>
>> >
>>
>> <http://7215.n5.nabble.com/__**JaxRS-**<http://7215.n5.nabble.com/__JaxRS-**>
>> <http://7215.n5.nabble.com/**JaxRS-**<http://7215.n5.nabble.com/JaxRS-**>
>> >>>
>>
>> <http://547215.n5.nabble.com/***____*JaxRS-**<http://547215.n5.nabble.com/*____*JaxRS-**>
>> <http://547215.n5.nabble.com/***__*JaxRS-**<http://547215.n5.nabble.com/*__*JaxRS-**>
>> >
>>
>> <http://547215.n5.nabble.com/***__*JaxRS-**<http://547215.n5.nabble.com/*__*JaxRS-**>
>> <http://547215.n5.nabble.com/****JaxRS-**<http://547215.n5.nabble.com/**JaxRS-**>
>> >><http://547215.n5._**___nabble.com/JaxRS-**
>> <http://nabble.com/JaxRS-**>
>>
>> <http://547215.n5.nabble.com/_**_JaxRS-**<http://547215.n5.nabble.com/__JaxRS-**>
>> <http://547215.n5.nabble.com/**JaxRS-**<http://547215.n5.nabble.com/JaxRS-**>
>> >>>
>>
>>
>>
>> Client-with-Deletes-td5731444.**____******html<http://cxf.__**547215.
>> <http://cxf.547215.>__n5.
>> <http://cxf.547215.n5
>> .>****
>> nabble.com/JaxRS-Client-with-***____***Deletes-td5731444.html<http://nabble.com/JaxRS-Client-with-*____***Deletes-td5731444.html>
>> <http://nabble.com/JaxRS-**Client-with-*__***Deletes-**
>> td5731444.html<http://nabble.com/JaxRS-Client-with-*__***Deletes-td5731444.html>
>> >
>>
>> <http://nabble.com/JaxRS-__**Client-with-****Deletes-__**
>> td5731444.html<http://nabble.com/JaxRS-__Client-with-****Deletes-__td5731444.html>
>> <http://nabble.com/JaxRS-**Client-with-****Deletes-**
>> td5731444.html<http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html>
>> >><http__://nabb**l__e.com/JaxRS-Client-__with-***
>> *__Deletes-td5731444.html<http://nabbl__e.com/JaxRS-Client-__with-**__Deletes-td5731444.html>
>> <http://nabble.com/JaxRS-**Client-__with-**Deletes-**
>> td5731444.html<http://nabble.com/JaxRS-Client-__with-**Deletes-td5731444.html>
>> >
>>
>> <http://nabble.com/JaxRS-__**Client-with-**Deletes-__**
>> td5731444.html<http://nabble.com/JaxRS-__Client-with-**Deletes-__td5731444.html><
>> http://nabble.com/JaxRS-**Client-with-**Deletes-**td5731444.html<http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>
>> >>>
>>
>> <http:/**/cxf.547215.n5.__nabb**__le.com/**JaxRS-Client-__**
>> with-__Deletes-**<http://nabb__le.com/**JaxRS-Client-__with-__Deletes-**>
>> <http://nabble.com/**JaxRS-**Client-__with-Deletes-**<http://nabble.com/**JaxRS-Client-__with-Deletes-**>
>> >
>>
>> <http://cxf.547215.n5.nabble._**_com/**JaxRS-Client-with-__**
>> Deletes-**
>> <http://cxf.547215.n5.nabble.**com/**JaxRS-Client-with-**
>> Deletes-**<http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>
>> >>
>>
>>
>> td5731444.html<http://cxf.__54**__7215.n5.nabble.com/JaxRS-___**
>> _Client-with-Deletes-**td5731444.____html<http://54__7215.n5.nabble.com/JaxRS-____Client-with-Deletes-td5731444.____html>
>> <http://547215.n5.nabble.com/**JaxRS-__Client-with-Deletes-**
>> td5731444.__html<http://547215.n5.nabble.com/JaxRS-__Client-with-Deletes-td5731444.__html>
>> >
>>
>>
>> <http://cxf.547215.n5.nabble._**_com/JaxRS-Client-with-**
>> Deletes-__td5731444.html
>>
>> <http://cxf.547215.n5.nabble.**com/JaxRS-Client-with-Deletes-**
>> td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>> >>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Cheers, Sergey
>>
>>
>>
>>
>> Thank you!
>>
>>
>> Regards, Julio
>>
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34
>> 93 357 99
>> 27
>>
>> <tel:%2B34%2093%20357%2099%__**2027>
>>
>>
>> Distributed
>> Applications and
>> Networks Area (DANA)
>> i2CAT Foundation,
>> Barcelona,
>> Spain
>> http://dana.i2cat.net
>>
>>
>>
>>
>>
>>
>> --
>>
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog:
>> http://sberyozkin.blogspot.com
>>
>>
>>
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>>
>>
>>
>>
>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 17/10/13 14:49, Julio Carlos Barrera Juez wrote:
> Bad news then.
I'm not sure why did you expect DELETE with body to work, we discussed
it yesterday and confirmed it was not yet possible, please make sure you
watch that JIRA I linked to to try it once it gets fixed (though I don't
know yet how feasible it is)
> Anyway the filter does not work, because the
> calls requestContext.setUri(...) did not change the real URI used at the
> end. But the method requestContext.setMEthod(...) worked...
>
Right, setUri does not work from client filters, thanks for catching it.
I've been certain a test is there, but it is only pre-matching container
request filters which are tested on setRequestUri, so it needs to be fixed
Cheers, Sergey
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
> On 17 October 2013 13:45, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>> wrote:
>
> Hi
>
> The method is definitely returned in CXF 2.7.7, I've just added a
> test confirming that. A lot of fixes went into the client-side 2.0
> code, some of it is still on the trunk only as they deal more with
> various very edgy TCK issues, I'm not sure yet if they should make
> to CXF 2.7.8 or not, but a method getter works in 2.7.7
>
> Re the actual exception, I guess this is because we don't have
> DELETE with body supported yet
>
> Sergey
>
> On 17/10/13 11:51, Julio Carlos Barrera Juez wrote:
>
> Hi Sergey.
>
> First of all, excuse me by the duplicate message.
>
> I have just written a Filter like this:
>
> public class PostToDeleteWithBodyFilter implements
> ClientRequestFilter {
>
> public final static StringEXTRA_PATH= "/mutatePOSTtoDELETE";
>
>
> @Override
> public void filter(ClientRequestContext requestContext) throws
> IOException {
> String method = requestContext.getMethod();
> String path = requestContext.getUri().__getPath();
>
> if (path != null && path.endsWith(EXTRA_PATH)) {
> // remove EXTRA_PATH
> requestContext.setUri(URI.__create(path.substring(0, path.length() -
> EXTRA_PATH.length())));
> // transform POST into DELETE
> requestContext.setMethod("__DELETE");
> }
> }
> }
>
> I have some issues again. The method var is null. And the most
> important, an exception is thrown when I use this filter:
>
> Caused by: java.io.IOException: IOException invoking
> http://<my_server>/real_path/__mutatePOSTtoDELETE: insufficient
> data written
> at
> sun.reflect.__NativeConstructorAccessorImpl.__newInstance0(Native Method)
> at
> sun.reflect.__NativeConstructorAccessorImpl.__newInstance(__NativeConstructorAccessorImpl.__java:39)
> at
> sun.reflect.__DelegatingConstructorAccessorI__mpl.newInstance(__DelegatingConstructorAccessorI__mpl.java:27)
> at
> java.lang.reflect.Constructor.__newInstance(Constructor.java:__513)
> at
> org.apache.cxf.transport.http.__HTTPConduit$__WrappedOutputStream.__mapException(HTTPConduit.java:__1338)
> at
> org.apache.cxf.transport.http.__HTTPConduit$__WrappedOutputStream.close(__HTTPConduit.java:1322)
> at
> org.apache.cxf.transport.__AbstractConduit.close(__AbstractConduit.java:56)
> at
> org.apache.cxf.transport.http.__HTTPConduit.close(HTTPConduit.__java:622)
> at
> org.apache.cxf.interceptor.__MessageSenderInterceptor$__MessageSenderEndingInterceptor__.handleMessage(__MessageSenderInterceptor.java:__62)
> ... 31 more
> Caused by: java.io.IOException: insufficient data written
> at
> sun.net.www.protocol.http.__HttpURLConnection$__StreamingOutputStream.close(__HttpURLConnection.java:2861)
> at
> sun.net.www.protocol.http.__HttpURLConnection.__getInputStream(__HttpURLConnection.java:1175)
> at
> java.net.HttpURLConnection.__getResponseCode(__HttpURLConnection.java:379)
> at
> org.apache.cxf.transport.http.__URLConnectionHTTPConduit$__URLConnectionWrappedOutputStre__am.getResponseCode(__URLConnectionHTTPConduit.java:__260)
> at
> org.apache.cxf.transport.http.__HTTPConduit$__WrappedOutputStream.__handleResponseInternal(__HTTPConduit.java:1517)
> at
> org.apache.cxf.transport.http.__HTTPConduit$__WrappedOutputStream.__handleResponse(HTTPConduit.__java:1490)
> at
> org.apache.cxf.transport.http.__HTTPConduit$__WrappedOutputStream.close(__HTTPConduit.java:1309)
> ... 34 more
>
> I tried to detect the special message to be mutated using an
> extra path
> string appended to the real path. It worked, it was detected, but
> something went wrong...
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
>
> On 17 October 2013 12:17, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>> wrote:
>
> Hi
>
> Can you register an instance of JAX-RS 2.0
> ClientRequestFilter (as a
> provider) and set your method & request URI if needed there ?
> That should make it simpler for you.
>
> Re using a custom CXF interceptor, it really should have the
> properties which you check already set on the message passed to
> handleMessage(), that message is an out message, so you
> should have
> "message == message.getExchange().____getOutMessage()" hold
> true.
>
>
> Cheers, Sergey
>
>
> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>
> I'm trying to workaround this problem with an output CXF
> interceptor. I
> have modified the DELETE request to be a POST request
> allowing a
> body. I
> want that my interceptor will detect the POST request
> and will
> change it to
> a DELETE. I'm having some problems to achieve it. How
> can the
> interceptor
> modify the message object to achieve my goal?
>
> I have written something like this:
>
> public class PostToDeleteWithBodyIntercepto____r extends
> AbstractPhaseInterceptor<____Message> {
>
>
> public final static String EXTRA_PATH =
> "/mutatePOSTtoDELETE";
>
> public PostToDeleteWithBodyIntercepto____r() {
>
> super(Phase.PRE_PROTOCOL);
> }
>
> public void handleMessage(Message message) {
> String path = (String)
>
> message.getExchange().____getOutMessage().get(Message.____REQUEST_URI);
> String method = (String)
>
> message.getExchange().____getOutMessage().get(Message.____HTTP_REQUEST_METHOD);
>
> if (method != null && method.equals("POST") && path
> != null &&
> path.endsWith(EXTRA_PATH)) {
> // TODO remove EXTRA_PATH
> // TODO transform POST into DELETE
> }
> }
> }
>
> I have a few doubts:
>
> - I don't know how to modify the path and the
> method of the
> request. I
>
> have tried modifying the content of the
> - I don't know what is the exact phase where apply it.
> - Why do I need to look for exchange, out message
> to see
> current path
>
> and method? It should be in the message, but the
> values are
> null.
>
> Thank you!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027> <tel:%2B34%2093%20357%2099%__2027>
>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:54, Sergey Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>> wrote:
>
> Hi,
>
> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>
> Yes, the server is not under my control. I want to
> develop a client
> because
> I like how CXF works and it is a dependency for
> other
> issues in my
> project.
> Obviously I would never develop a service with
> body in
> DELETE requests.
>
> The, taking into account that I'm using CXF
> 2.7.x, is it
> possible to
> workaround my problem using CXF?
>
> Probably not at the moment,
>
> I've opened
> https://issues.apache.org/**____jira/browse/CXF-5337
> <https://issues.apache.org/**__jira/browse/CXF-5337>
> <https://issues.apache.org/**__jira/browse/CXF-5337
> <https://issues.apache.org/**jira/browse/CXF-5337>><https://____issues.apache.org/jira/__browse/__CXF-5337
> <http://issues.apache.org/jira/browse/__CXF-5337>
>
> <https://issues.apache.org/__jira/browse/CXF-5337
> <https://issues.apache.org/jira/browse/CXF-5337>>>
>
>
> Please watch it.
>
> In meantime, may be it is possible to 'tunnel' it,
> example,
> use POST but
> set some header with the real/intended HTTP verb
> such as
> DELETE, the target
> server would need to replace POST with DELETE, the
> easy way
> is to say
> create Servlet filter which will use HTTPServletRequest
> wrapper to return
> DELETE, some work is needed there but no changes to the
> server code itself
> will be required.
>
> Otherwise - try snapshots once CXF-5337 gets resolved
>
> Thanks, Sergey
>
> Thank you Sergey!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:23, Sergey Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>> wrote:
>
> Right, looks like the following has to be
> done with
> HTTPClient:
>
>
> https://code.google.com/p/****____rest-client/source/browse/**
> <https://code.google.com/p/****__rest-client/source/browse/**>
>
> <https://code.google.com/p/***__*rest-client/source/browse/**
> <https://code.google.com/p/****rest-client/source/browse/**>>__<h__ttps://code.google.com/p/*__*__rest-client/source/browse/*__*
> <http://code.google.com/p/**__rest-client/source/browse/**>
>
> <https://code.google.com/p/**__rest-client/source/browse/**
> <https://code.google.com/p/**rest-client/source/browse/**>>>
>
> restclient-lib/src/main/java/*____***org/wiztools/restclient/____http/****
>
> EntityEnclosingDelete.java<____htt**ps://code.google.com/p/____rest-**
> <http://code.google.com/p/__rest-**>
> <http://code.google.com/p/__rest-**
> <http://code.google.com/p/rest-**>>
>
> client/source/browse/**____restclient-lib/src/main/java/*____*
>
> org/wiztools/restclient/http/*____*EntityEnclosingDelete.java<__ht__tps://code.google.com/p/__rest-__client/source/browse/____restclient-lib/src/main/java/____org/wiztools/restclient/http/____EntityEnclosingDelete.java
> <http://code.google.com/p/rest-__client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>
>
>
> <https://code.google.com/p/__rest-client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java
> <https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>>>
>
>
>
>
> This is the code based on the advice from
> HttpClient
> forums.
>
> I guess we should check if CXF Async
> Conduit can be
> updated respectively
>
> By the way, I'm assuming you have to do
> DELETE with
> a body because you
> have some existing/legacy service expecting
> it this
> way ? Now and then
> users ask about it, and I don't mind to get the
> Async HTTP conduit
> updated
> a bit anyway, but if you have say a CXF server
> listening, then I'm sure
> there could be an easier way :-)
>
> Cheers, Sergey
>
>
> On 16/10/13 15:11, Julio Carlos Barrera
> Juez wrote:
>
> Looking for logs, I've realized that the
> property
> is producing changes.
>
> I
> mean the Async HTTP client is being used.
> However my DELETE request has
> no
> body. My client interface is JAX-RS
> annotated,
> my Resource class is JaxB
> annotated:
>
> @Path("/server/path")
> @DELETE
>
> @Consumes(MediaType.****____APPLICATION_JSON)
>
>
>
> public void
> deleteResource(Resource resource);
>
> I have a create method working with de same
> configuration and it works:
>
> @Path("/server/path")
> @POST
>
> @Consumes(MediaType.****____APPLICATION_JSON)
>
>
>
> public void
> createResource(Resource resource);
>
> I'm using Jackson as JSON serializer, but I
> guess it has no relation
> with
> this problem.
>
> These log lines show that the DELETE
> request has
> content-lenght 0 and
> the Async HTTP client is being used
>
> [I/O dispatcher 2] DEBUG
>
> org.apache.cxf.transport.http.____****asyncclient.****____AsyncHTTPConduitFactory$2
>
>
> -
>
> Connection leased: [id: 2][route:
> {}->http://my_server][total kept
> alive:
> 0; route allocated: 1 of 1000; total
> allocated:
> 0 of 5000]
> [I/O dispatcher 2] DEBUG
>
> org.apache.cxf.transport.http.____****asyncclient.****____AsyncHTTPConduitFactory$3
>
>
> -
> [exchange: 3] Connection allocated:
>
> [id:2][route:{}->http:/my_****____server][state:null]
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152>
>
> <http://192.168.254.86:35152><__->server___****ip[ACTIVE][r:]:
>
> Set
> attribute
> http.nio.exchange-handler
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152>
>
> <http://192.168.254.86:35152><__->server___****ip[ACTIVE][rw:]__:
>
> Event
> set [w]
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152>
>
> <http://192.168.254.86:35152><__->server___****ip[ACTIVE][rw:]__:
>
> Set
>
>
> attribute http.nio.http-exchange-state
> [I/O dispatcher 2] DEBUG
>
> org.apache.cxf.transport.http.____****asyncclient.****____AsyncHTTPConduitFactory$3
>
>
> -
>
> [exchange: 3] Attempt 1 to execute request
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152>
>
> <http://192.168.254.86:35152><__->server___****ip[ACTIVE][rw:]__:
>
> Set
> timeout
> 60000
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.****
>
> protocol.RequestAuthCache
>
> -
> Auth cache not set in the context
> [I/O dispatcher 2] DEBUG
>
> org.apache.http.client.****____protocol.****____RequestTargetAuthentication
>
> -
>
> Target
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
>
> org.apache.http.client.****____protocol.****____RequestProxyAuthentication
>
> -
>
> Proxy
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >> *
> DELETE* /server/path HTTP/1.1
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Accept: text/plain
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> User-Agent: Apache CXF 2.7.4
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> *Content-Length:
> 0*
>
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Host:
> my_server
> [I/O dispatcher 2] DEBUG
> org.apache.http.headers
> - http-outgoing-2 >>
> Connection: Keep-Alive
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> Distributed Applications and Networks
> Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 15:17, Julio Carlos
> Barrera
> Juez <
> juliocarlos.barrera@i2cat.net <ma...@i2cat.net>
> <mailto:juliocarlos.barrera@__i2cat.net
> <ma...@i2cat.net>>> wrote:
>
> I don't know how to install CXF
> Async HTTP
> transport. I have the maven
>
> artifact in my project
> dependencies, but
> nothing else.
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> <tel:%2B34%2093%20357%2099%__2027>
>
> Distributed Applications and
> Networks Area
> (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 13:14, Sergey
> Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com>
> <mailto:sberyozkin@gmail.com
> <ma...@gmail.com>>>
>
> wrote:
>
> I guess you don't have CXF
> Async HTTP
> transport installed ?
>
> Other than that I've no idea, if it
> won;t work with the Async module
> then
> I guess it is possible to do
> Sergey
>
> On 16/10/13 11:49, Julio Carlos
> Barrera
> Juez wrote:
>
> I tried to use this information
> before, but I don't know how to
> solve
>
> my
> problem.
>
> I have something like this:
>
> ProxyClassLoader
> classLoader = new
> ProxyClassLoader();
>
>
> classLoader.addLoader(******____IServiceInterface.class.****
> getClassLoader());
>
> classLoader.addLoader(******____JAXRSClientFactoryBean.class.*____*****
>
>
>
>
> getClassLoader());
>
> JAXRSClientFactoryBean bean
> = new
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
>
> bean.setResourceClass(******____IServiceInterface.class);
>
>
> bean.setClassLoader(******____classLoader);
>
>
>
>
>
> client (IServiceInterface)
> bean.create();
>
> Then I can use the client
> object as
> usual. But if fails sending
> DELETE
> requests with body.
>
> I tried doing this:
>
> ProxyClassLoader
> classLoader = new
> ProxyClassLoader();
>
>
> classLoader.addLoader(******____IServiceInterface.class.****
> getClassLoader());
>
> classLoader.addLoader(******____JAXRSClientFactoryBean.class.*____*****
>
>
>
>
> getClassLoader());
>
> JAXRSClientFactoryBean bean
> = new
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
>
> bean.setResourceClass(******____IServiceInterface.class);
>
>
> bean.setClassLoader(******____classLoader);
>
>
>
>
>
> // allow body in DELETE
> requests
> Client client = bean.create();
>
>
> WebClient.getConfig(client).**____****getRequestContext().put(__"*__*
>
> use.****
> async.http.conduit",
> true);
>
> (IServiceInterface)
>
> client.******____whateverMethodThatSendsDelete(____**
>
>
> ****);
>
>
>
> But it didn't work.
>
> What am I missing?
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99
> 27 <tel:%2B34%2093%20357%2099%2027>
>
> <tel:%2B34%2093%20357%2099%__2027>
>
> Distributed Applications and
> Networks Area (DANA)
> i2CAT Foundation,
> Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 12:00,
> Sergey
> Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>
>
> <mailto:sberyozkin@gmail.com <ma...@gmail.com>>>
>
> wrote:
>
> Hi
>
>
> On 16/10/13 09:18,
> Julio Carlos
> Barrera Juez wrote:
>
> Hi.
>
>
> I'm creating a REST
> client
> using
> JAXRSClientFactoryBean and
> ProxyClassLoader
> based on a
> JAXRS annotated
> Java interface.
>
> I want to send a
> DELETE with
> body, which is not
> recommended by
> RESTful
> philosophy, but it is
> allowed by HTTP 1.1
> RFC.
>
> The body is not
> sent by the
> client and I have
> read a lot of
> problems
> to
> allow it.
>
> Is it possible send
> a body
> in my DELETE
> requests with this
> configuration?
>
> Please check
> this thread
>
>
> http://cxf.547215.n5.nabble.**____******com/JaxRS-Client-with-__**
>
> Deletes-****
>
> td5731444.html<http://cxf.****____54**7215.n5.nabble.com/__JaxRS-*__***
> <http://7215.n5.nabble.com/JaxRS-*__***>
>
> <http://7215.n5.nabble.com/__JaxRS-****
> <http://7215.n5.nabble.com/JaxRS-****>><http://7215.n5.__nabble.com/__JaxRS-**
> <http://7215.n5.nabble.com/__JaxRS-**>
>
> <http://7215.n5.nabble.com/__JaxRS-**
> <http://7215.n5.nabble.com/JaxRS-**>>>
>
> <http://547215.n5.nabble.com/*____*JaxRS-**
> <http://547215.n5.nabble.com/*__*JaxRS-**>
>
> <http://547215.n5.nabble.com/*__*JaxRS-**
> <http://547215.n5.nabble.com/**JaxRS-**>><http://547215.n5.____nabble.com/JaxRS-**
> <http://nabble.com/JaxRS-**>
>
> <http://547215.n5.nabble.com/__JaxRS-**
> <http://547215.n5.nabble.com/JaxRS-**>>>
>
>
>
> Client-with-Deletes-td5731444.____******html<http://cxf.__547215. <http://cxf.547215.>__n5.
> <http://cxf.547215.n5.>****
> nabble.com/JaxRS-Client-with-*____***Deletes-td5731444.html
> <http://nabble.com/JaxRS-Client-with-*__***Deletes-td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-with-****Deletes-__td5731444.html
> <http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html>><http__://nabbl__e.com/JaxRS-Client-__with-**__Deletes-td5731444.html
> <http://nabble.com/JaxRS-Client-__with-**Deletes-td5731444.html>
>
> <http://nabble.com/JaxRS-__Client-with-**Deletes-__td5731444.html <http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>>>
>
> <http:/**/cxf.547215.n5.__nabb__le.com/**JaxRS-Client-__with-__Deletes-**
> <http://nabble.com/**JaxRS-Client-__with-Deletes-**>
>
> <http://cxf.547215.n5.nabble.__com/**JaxRS-Client-with-__Deletes-**
> <http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>>
>
>
> td5731444.html<http://cxf.__54__7215.n5.nabble.com/JaxRS-____Client-with-Deletes-td5731444.____html
> <http://547215.n5.nabble.com/JaxRS-__Client-with-Deletes-td5731444.__html>
>
>
> <http://cxf.547215.n5.nabble.__com/JaxRS-Client-with-Deletes-__td5731444.html
> <http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>>>
>
>
>
>
>
>
>
>
> Cheers, Sergey
>
>
>
>
> Thank you!
>
>
> Regards, Julio
>
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34
> 93 357 99
> 27
>
> <tel:%2B34%2093%20357%2099%__2027>
>
> Distributed
> Applications and
> Networks Area (DANA)
> i2CAT Foundation,
> Barcelona,
> Spain
> http://dana.i2cat.net
>
>
>
>
>
>
> --
>
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog:
> http://sberyozkin.blogspot.com
>
>
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
Bad news then. Anyway the filter does not work, because the
calls requestContext.setUri(...) did not change the real URI used at the
end. But the method requestContext.setMEthod(...) worked...
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 17 October 2013 13:45, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> The method is definitely returned in CXF 2.7.7, I've just added a test
> confirming that. A lot of fixes went into the client-side 2.0 code, some of
> it is still on the trunk only as they deal more with various very edgy TCK
> issues, I'm not sure yet if they should make to CXF 2.7.8 or not, but a
> method getter works in 2.7.7
>
> Re the actual exception, I guess this is because we don't have DELETE with
> body supported yet
>
> Sergey
>
> On 17/10/13 11:51, Julio Carlos Barrera Juez wrote:
>
>> Hi Sergey.
>>
>> First of all, excuse me by the duplicate message.
>>
>> I have just written a Filter like this:
>>
>> public class PostToDeleteWithBodyFilter implements ClientRequestFilter {
>>
>> public final static StringEXTRA_PATH= "/mutatePOSTtoDELETE";
>>
>>
>> @Override
>> public void filter(ClientRequestContext requestContext) throws
>> IOException {
>> String method = requestContext.getMethod();
>> String path = requestContext.getUri().**getPath();
>>
>> if (path != null && path.endsWith(EXTRA_PATH)) {
>> // remove EXTRA_PATH
>> requestContext.setUri(URI.**create(path.substring(0, path.length() -
>> EXTRA_PATH.length())));
>> // transform POST into DELETE
>> requestContext.setMethod("**DELETE");
>> }
>> }
>> }
>>
>> I have some issues again. The method var is null. And the most
>> important, an exception is thrown when I use this filter:
>>
>> Caused by: java.io.IOException: IOException invoking
>> http://<my_server>/real_path/**mutatePOSTtoDELETE: insufficient data
>> written
>> at sun.reflect.**NativeConstructorAccessorImpl.**newInstance0(Native
>> Method)
>> at
>> sun.reflect.**NativeConstructorAccessorImpl.**newInstance(**
>> NativeConstructorAccessorImpl.**java:39)
>> at
>> sun.reflect.**DelegatingConstructorAccessorI**mpl.newInstance(**
>> DelegatingConstructorAccessorI**mpl.java:27)
>> at java.lang.reflect.Constructor.**newInstance(Constructor.java:**513)
>> at
>> org.apache.cxf.transport.http.**HTTPConduit$**WrappedOutputStream.**
>> mapException(HTTPConduit.java:**1338)
>> at
>> org.apache.cxf.transport.http.**HTTPConduit$**WrappedOutputStream.close(*
>> *HTTPConduit.java:1322)
>> at org.apache.cxf.transport.**AbstractConduit.close(**
>> AbstractConduit.java:56)
>> at org.apache.cxf.transport.http.**HTTPConduit.close(HTTPConduit.**
>> java:622)
>> at
>> org.apache.cxf.interceptor.**MessageSenderInterceptor$**
>> MessageSenderEndingInterceptor**.handleMessage(**
>> MessageSenderInterceptor.java:**62)
>> ... 31 more
>> Caused by: java.io.IOException: insufficient data written
>> at
>> sun.net.www.protocol.http.**HttpURLConnection$**
>> StreamingOutputStream.close(**HttpURLConnection.java:2861)
>> at
>> sun.net.www.protocol.http.**HttpURLConnection.**getInputStream(**
>> HttpURLConnection.java:1175)
>> at java.net.HttpURLConnection.**getResponseCode(**
>> HttpURLConnection.java:379)
>> at
>> org.apache.cxf.transport.http.**URLConnectionHTTPConduit$**
>> URLConnectionWrappedOutputStre**am.getResponseCode(**
>> URLConnectionHTTPConduit.java:**260)
>> at
>> org.apache.cxf.transport.http.**HTTPConduit$**WrappedOutputStream.**
>> handleResponseInternal(**HTTPConduit.java:1517)
>> at
>> org.apache.cxf.transport.http.**HTTPConduit$**WrappedOutputStream.**
>> handleResponse(HTTPConduit.**java:1490)
>> at
>> org.apache.cxf.transport.http.**HTTPConduit$**WrappedOutputStream.close(*
>> *HTTPConduit.java:1309)
>> ... 34 more
>>
>> I tried to detect the special message to be mutated using an extra path
>> string appended to the real path. It worked, it was detected, but
>> something went wrong...
>>
>> i2cat
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net <http://dana.i2cat.net/>
>>
>>
>>
>> On 17 October 2013 12:17, Sergey Beryozkin <sberyozkin@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>> Hi
>>
>> Can you register an instance of JAX-RS 2.0 ClientRequestFilter (as a
>> provider) and set your method & request URI if needed there ?
>> That should make it simpler for you.
>>
>> Re using a custom CXF interceptor, it really should have the
>> properties which you check already set on the message passed to
>> handleMessage(), that message is an out message, so you should have
>> "message == message.getExchange().__**getOutMessage()" hold true.
>>
>>
>> Cheers, Sergey
>>
>>
>> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>>
>> I'm trying to workaround this problem with an output CXF
>> interceptor. I
>> have modified the DELETE request to be a POST request allowing a
>> body. I
>> want that my interceptor will detect the POST request and will
>> change it to
>> a DELETE. I'm having some problems to achieve it. How can the
>> interceptor
>> modify the message object to achieve my goal?
>>
>> I have written something like this:
>>
>> public class PostToDeleteWithBodyIntercepto**__r extends
>> AbstractPhaseInterceptor<__**Message> {
>>
>>
>> public final static String EXTRA_PATH = "/mutatePOSTtoDELETE";
>>
>> public PostToDeleteWithBodyIntercepto**__r() {
>>
>> super(Phase.PRE_PROTOCOL);
>> }
>>
>> public void handleMessage(Message message) {
>> String path = (String)
>> message.getExchange().__**getOutMessage().get(Message.__**
>> REQUEST_URI);
>> String method = (String)
>> message.getExchange().__**getOutMessage().get(Message.__**
>> HTTP_REQUEST_METHOD);
>>
>> if (method != null && method.equals("POST") && path != null &&
>> path.endsWith(EXTRA_PATH)) {
>> // TODO remove EXTRA_PATH
>> // TODO transform POST into DELETE
>> }
>> }
>> }
>>
>> I have a few doubts:
>>
>> - I don't know how to modify the path and the method of the
>> request. I
>>
>> have tried modifying the content of the
>> - I don't know what is the exact phase where apply it.
>> - Why do I need to look for exchange, out message to see
>> current path
>>
>> and method? It should be in the message, but the values are
>> null.
>>
>> Thank you!
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%**2027>
>>
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 16:54, Sergey Beryozkin <sberyozkin@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>> Hi,
>>
>> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>>
>> Yes, the server is not under my control. I want to
>> develop a client
>> because
>> I like how CXF works and it is a dependency for other
>> issues in my
>> project.
>> Obviously I would never develop a service with body in
>> DELETE requests.
>>
>> The, taking into account that I'm using CXF 2.7.x, is it
>> possible to
>> workaround my problem using CXF?
>>
>> Probably not at the moment,
>>
>> I've opened
>> https://issues.apache.org/**__**jira/browse/CXF-5337<https://issues.apache.org/**__jira/browse/CXF-5337>
>> <https://issues.apache.org/****jira/browse/CXF-5337<https://issues.apache.org/**jira/browse/CXF-5337>
>> ><https://**__issues.apache.org/jira/**browse/__CXF-5337<http://issues.apache.org/jira/browse/__CXF-5337>
>>
>> <https://issues.apache.org/**jira/browse/CXF-5337<https://issues.apache.org/jira/browse/CXF-5337>
>> >>
>>
>>
>> Please watch it.
>>
>> In meantime, may be it is possible to 'tunnel' it, example,
>> use POST but
>> set some header with the real/intended HTTP verb such as
>> DELETE, the target
>> server would need to replace POST with DELETE, the easy way
>> is to say
>> create Servlet filter which will use HTTPServletRequest
>> wrapper to return
>> DELETE, some work is needed there but no changes to the
>> server code itself
>> will be required.
>>
>> Otherwise - try snapshots once CXF-5337 gets resolved
>>
>> Thanks, Sergey
>>
>> Thank you Sergey!
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>>
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 16:23, Sergey Beryozkin
>> <sberyozkin@gmail.com <ma...@gmail.com>>
>> wrote:
>>
>> Right, looks like the following has to be done with
>> HTTPClient:
>>
>>
>> https://code.google.com/p/******
>> __rest-client/source/browse/**<https://code.google.com/p/****__rest-client/source/browse/**>
>> <https://code.google.com/p/*****
>> *rest-client/source/browse/**<https://code.google.com/p/****rest-client/source/browse/**>
>> >**<h__ttps://code.google.com/p/****__rest-client/source/browse/****<http://code.google.com/p/**__rest-client/source/browse/**>
>> <https://code.google.com/p/****
>> rest-client/source/browse/**<https://code.google.com/p/**rest-client/source/browse/**>
>> >>
>> restclient-lib/src/main/java/***
>> __***org/wiztools/restclient/_**_http/****
>> EntityEnclosingDelete.java<__**htt**ps://
>> code.google.com/p/__**rest-** <http://code.google.com/p/__rest-**>
>> <http://code.google.com/p/**rest-**<http://code.google.com/p/rest-**>
>> >
>> client/source/browse/**__**
>> restclient-lib/src/main/java/***__*
>> org/wiztools/restclient/http/***
>> __*EntityEnclosingDelete.java<**ht__tps://code.google.com/p/**
>> rest-__client/source/browse/__**restclient-lib/src/main/java/_**
>> _org/wiztools/restclient/http/**__EntityEnclosingDelete.java<http://code.google.com/p/rest-__client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java>
>>
>> <https://code.google.com/p/**
>> rest-client/source/browse/**restclient-lib/src/main/java/**
>> org/wiztools/restclient/http/**EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>> >>
>>
>>
>>
>>
>> This is the code based on the advice from HttpClient
>> forums.
>>
>> I guess we should check if CXF Async Conduit can be
>> updated respectively
>>
>> By the way, I'm assuming you have to do DELETE with
>> a body because you
>> have some existing/legacy service expecting it this
>> way ? Now and then
>> users ask about it, and I don't mind to get the
>> Async HTTP conduit
>> updated
>> a bit anyway, but if you have say a CXF server
>> listening, then I'm sure
>> there could be an easier way :-)
>>
>> Cheers, Sergey
>>
>>
>> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>>
>> Looking for logs, I've realized that the property
>> is producing changes.
>>
>> I
>> mean the Async HTTP client is being used.
>> However my DELETE request has
>> no
>> body. My client interface is JAX-RS annotated,
>> my Resource class is JaxB
>> annotated:
>>
>> @Path("/server/path")
>> @DELETE
>> @Consumes(MediaType.****__**APPLICATION_JSON)
>>
>>
>>
>> public void deleteResource(Resource
>> resource);
>>
>> I have a create method working with de same
>> configuration and it works:
>>
>> @Path("/server/path")
>> @POST
>> @Consumes(MediaType.****__**APPLICATION_JSON)
>>
>>
>>
>> public void createResource(Resource
>> resource);
>>
>> I'm using Jackson as JSON serializer, but I
>> guess it has no relation
>> with
>> this problem.
>>
>> These log lines show that the DELETE request has
>> content-lenght 0 and
>> the Async HTTP client is being used
>>
>> [I/O dispatcher 2] DEBUG
>> org.apache.cxf.transport.http.**
>> __****asyncclient.****__**AsyncHTTPConduitFactory$2
>>
>>
>> -
>>
>> Connection leased: [id: 2][route:
>> {}->http://my_server][total kept
>> alive:
>> 0; route allocated: 1 of 1000; total allocated:
>> 0 of 5000]
>> [I/O dispatcher 2] DEBUG
>> org.apache.cxf.transport.http.**
>> __****asyncclient.****__**AsyncHTTPConduitFactory$3
>>
>>
>> -
>> [exchange: 3] Connection allocated:
>> [id:2][route:{}->http:/my_******
>> __server][state:null]
>>
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152><**
>> ->server___****ip[ACTIVE][r:]:
>>
>> Set
>> attribute
>> http.nio.exchange-handler
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152><**
>> ->server___****ip[ACTIVE][rw:]**:
>>
>> Event
>> set [w]
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152><**
>> ->server___****ip[ACTIVE][rw:]**:
>>
>> Set
>>
>>
>> attribute http.nio.http-exchange-state
>> [I/O dispatcher 2] DEBUG
>> org.apache.cxf.transport.http.**
>> __****asyncclient.****__**AsyncHTTPConduitFactory$3
>>
>>
>> -
>>
>> [exchange: 3] Attempt 1 to execute request
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.impl.nio.****
>> reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152
>> <http://192.168.254.86:35152><**
>> ->server___****ip[ACTIVE][rw:]**:
>>
>> Set
>> timeout
>> 60000
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.client.****
>>
>> protocol.RequestAuthCache
>>
>> -
>> Auth cache not set in the context
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.client.****__**protocol.****__**
>> RequestTargetAuthentication
>>
>> -
>>
>> Target
>>
>> auth
>> state: UNCHALLENGED
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.client.****__**protocol.****__**
>> RequestProxyAuthentication
>>
>> -
>>
>> Proxy
>>
>> auth
>> state: UNCHALLENGED
>> [I/O dispatcher 2] DEBUG org.apache.http.headers
>> - http-outgoing-2 >> *
>> DELETE* /server/path HTTP/1.1
>>
>> [I/O dispatcher 2] DEBUG org.apache.http.headers
>> - http-outgoing-2 >>
>> Accept: text/plain
>> [I/O dispatcher 2] DEBUG org.apache.http.headers
>> - http-outgoing-2 >>
>> User-Agent: Apache CXF 2.7.4
>> [I/O dispatcher 2] DEBUG org.apache.http.headers
>> - http-outgoing-2 >>
>> *Content-Length:
>> 0*
>>
>> [I/O dispatcher 2] DEBUG org.apache.http.headers
>> - http-outgoing-2 >>
>> Host:
>> my_server
>> [I/O dispatcher 2] DEBUG org.apache.http.headers
>> - http-outgoing-2 >>
>> Connection: Keep-Alive
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>>
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 15:17, Julio Carlos Barrera
>> Juez <
>> juliocarlos.barrera@i2cat.net
>> <ma...@i2cat.net>>>
>> wrote:
>>
>> I don't know how to install CXF Async HTTP
>> transport. I have the maven
>>
>> artifact in my project dependencies, but
>> nothing else.
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>>
>> Distributed Applications and Networks Area
>> (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 13:14, Sergey Beryozkin
>> <sberyozkin@gmail.com
>> <ma...@gmail.com>>
>>
>> wrote:
>>
>> I guess you don't have CXF Async HTTP
>> transport installed ?
>>
>> Other than that I've no idea, if it
>> won;t work with the Async module
>> then
>> I guess it is possible to do
>> Sergey
>>
>> On 16/10/13 11:49, Julio Carlos Barrera
>> Juez wrote:
>>
>> I tried to use this information
>> before, but I don't know how to
>> solve
>>
>> my
>> problem.
>>
>> I have something like this:
>>
>> ProxyClassLoader classLoader = new
>> ProxyClassLoader();
>>
>> classLoader.addLoader(******__**
>> IServiceInterface.class.****
>> getClassLoader());
>> classLoader.addLoader(******__**
>> JAXRSClientFactoryBean.class.***__*****
>>
>>
>>
>>
>> getClassLoader());
>>
>> JAXRSClientFactoryBean bean = new
>> JAXRSClientFactoryBean();
>> bean.setAddress(uri);
>> bean.setResourceClass(******__**
>> IServiceInterface.class);
>>
>> bean.setClassLoader(******__**
>> classLoader);
>>
>>
>>
>>
>>
>> client (IServiceInterface)
>> bean.create();
>>
>> Then I can use the client object as
>> usual. But if fails sending
>> DELETE
>> requests with body.
>>
>> I tried doing this:
>>
>> ProxyClassLoader classLoader = new
>> ProxyClassLoader();
>>
>> classLoader.addLoader(******__**
>> IServiceInterface.class.****
>> getClassLoader());
>> classLoader.addLoader(******__**
>> JAXRSClientFactoryBean.class.***__*****
>>
>>
>>
>>
>> getClassLoader());
>>
>> JAXRSClientFactoryBean bean = new
>> JAXRSClientFactoryBean();
>> bean.setAddress(uri);
>> bean.setResourceClass(******__**
>> IServiceInterface.class);
>>
>> bean.setClassLoader(******__**
>> classLoader);
>>
>>
>>
>>
>>
>> // allow body in DELETE requests
>> Client client = bean.create();
>>
>> WebClient.getConfig(client).****
>> __****getRequestContext().put(**"*__*
>>
>> use.****
>> async.http.conduit",
>> true);
>>
>> (IServiceInterface)
>> client.******__**
>> whateverMethodThatSendsDelete(**__**
>>
>>
>> ****);
>>
>>
>>
>> But it didn't work.
>>
>> What am I missing?
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> <tel:%2B34%2093%20357%2099%**2027>
>>
>> Distributed Applications and
>> Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 12:00, Sergey
>> Beryozkin <sberyozkin@gmail.com
>> <ma...@gmail.com>>
>>
>> wrote:
>>
>> Hi
>>
>>
>> On 16/10/13 09:18, Julio Carlos
>> Barrera Juez wrote:
>>
>> Hi.
>>
>>
>> I'm creating a REST client
>> using JAXRSClientFactoryBean
>> and
>> ProxyClassLoader based on a
>> JAXRS annotated Java
>> interface.
>>
>> I want to send a DELETE with
>> body, which is not
>> recommended by
>> RESTful
>> philosophy, but it is
>> allowed by HTTP 1.1 RFC.
>>
>> The body is not sent by the
>> client and I have read a lot
>> of
>> problems
>> to
>> allow it.
>>
>> Is it possible send a body
>> in my DELETE requests with
>> this
>> configuration?
>>
>> Please check this thread
>>
>>
>> http://cxf.547215.n5.nabble.
>> ****__******com/JaxRS-Client-with-****
>>
>> Deletes-****
>> td5731444.html<http://cxf.******
>> __54**7215.n5.nabble.com/**JaxRS-*__***<http://7215.n5.nabble.com/JaxRS-*__***>
>> <http://7215.n5.nabble.com/**
>> JaxRS-**** <http://7215.n5.nabble.com/JaxRS-****>><http://7215.n5.**
>> nabble.com/__JaxRS-** <http://7215.n5.nabble.com/__JaxRS-**>
>> <http://7215.n5.nabble.com/**
>> JaxRS-** <http://7215.n5.nabble.com/JaxRS-**>>>
>> <http://547215.n5.nabble.com/***
>> __*JaxRS-** <http://547215.n5.nabble.com/*__*JaxRS-**>
>> <http://547215.n5.nabble.com/***
>> *JaxRS-** <http://547215.n5.nabble.com/**JaxRS-**>><http://547215.n5.__**
>> nabble.com/JaxRS-** <http://nabble.com/JaxRS-**>
>> <http://547215.n5.nabble.com/**
>> JaxRS-** <http://547215.n5.nabble.com/JaxRS-**>>>
>>
>>
>> Client-with-Deletes-td5731444.**
>> __******html<http://cxf.**547215. <http://cxf.547215.>__n5.
>> <http://cxf.547215.n5.>****
>> nabble.com/JaxRS-Client-with-***
>> __***Deletes-td5731444.html<http://nabble.com/JaxRS-Client-with-*__***Deletes-td5731444.html>
>> <http://nabble.com/JaxRS-**
>> Client-with-****Deletes-**td5731444.html<http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html>
>> ><http__://nabbl**e.com/JaxRS-Client-__with-****Deletes-td5731444.html<http://nabble.com/JaxRS-Client-__with-**Deletes-td5731444.html>
>> <http://nabble.com/JaxRS-**
>> Client-with-**Deletes-**td5731444.html<http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>
>> >>
>> <http:/**/cxf.547215.n5.__nabb**
>> le.com/**JaxRS-Client-__with-**Deletes-**<http://nabble.com/**JaxRS-Client-__with-Deletes-**>
>> <http://cxf.547215.n5.nabble.**
>> com/**JaxRS-Client-with-**Deletes-**<http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>
>> >
>>
>> td5731444.html<http://cxf.__54**
>> 7215.n5.nabble.com/JaxRS-__**Client-with-Deletes-td5731444.**__html<http://547215.n5.nabble.com/JaxRS-__Client-with-Deletes-td5731444.__html>
>>
>> <http://cxf.547215.n5.nabble.**
>> com/JaxRS-Client-with-Deletes-**td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>> >>
>>
>>
>>
>>
>>
>>
>>
>>
>> Cheers, Sergey
>>
>>
>>
>>
>> Thank you!
>>
>>
>> Regards, Julio
>>
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99
>> 27
>> <tel:%2B34%2093%20357%2099%**
>> 2027>
>>
>> Distributed Applications and
>> Networks Area (DANA)
>> i2CAT Foundation, Barcelona,
>> Spain
>> http://dana.i2cat.net
>>
>>
>>
>>
>>
>>
>> --
>>
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>>
>>
>>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
The method is definitely returned in CXF 2.7.7, I've just added a test
confirming that. A lot of fixes went into the client-side 2.0 code, some
of it is still on the trunk only as they deal more with various very
edgy TCK issues, I'm not sure yet if they should make to CXF 2.7.8 or
not, but a method getter works in 2.7.7
Re the actual exception, I guess this is because we don't have DELETE
with body supported yet
Sergey
On 17/10/13 11:51, Julio Carlos Barrera Juez wrote:
> Hi Sergey.
>
> First of all, excuse me by the duplicate message.
>
> I have just written a Filter like this:
>
> public class PostToDeleteWithBodyFilter implements ClientRequestFilter {
>
> public final static StringEXTRA_PATH= "/mutatePOSTtoDELETE";
>
> @Override
> public void filter(ClientRequestContext requestContext) throws IOException {
> String method = requestContext.getMethod();
> String path = requestContext.getUri().getPath();
>
> if (path != null && path.endsWith(EXTRA_PATH)) {
> // remove EXTRA_PATH
> requestContext.setUri(URI.create(path.substring(0, path.length() -
> EXTRA_PATH.length())));
> // transform POST into DELETE
> requestContext.setMethod("DELETE");
> }
> }
> }
>
> I have some issues again. The method var is null. And the most
> important, an exception is thrown when I use this filter:
>
> Caused by: java.io.IOException: IOException invoking
> http://<my_server>/real_path/mutatePOSTtoDELETE: insufficient data written
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1338)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1322)
> at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
> at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
> at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> ... 31 more
> Caused by: java.io.IOException: insufficient data written
> at
> sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.close(HttpURLConnection.java:2861)
> at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1175)
> at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
> at
> org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:260)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1517)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
> ... 34 more
>
> I tried to detect the special message to be mutated using an extra path
> string appended to the real path. It worked, it was detected, but
> something went wrong...
>
> i2cat
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net <http://dana.i2cat.net/>
>
>
> On 17 October 2013 12:17, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>> wrote:
>
> Hi
>
> Can you register an instance of JAX-RS 2.0 ClientRequestFilter (as a
> provider) and set your method & request URI if needed there ?
> That should make it simpler for you.
>
> Re using a custom CXF interceptor, it really should have the
> properties which you check already set on the message passed to
> handleMessage(), that message is an out message, so you should have
> "message == message.getExchange().__getOutMessage()" hold true.
>
> Cheers, Sergey
>
>
> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>
> I'm trying to workaround this problem with an output CXF
> interceptor. I
> have modified the DELETE request to be a POST request allowing a
> body. I
> want that my interceptor will detect the POST request and will
> change it to
> a DELETE. I'm having some problems to achieve it. How can the
> interceptor
> modify the message object to achieve my goal?
>
> I have written something like this:
>
> public class PostToDeleteWithBodyIntercepto__r extends
> AbstractPhaseInterceptor<__Message> {
>
> public final static String EXTRA_PATH = "/mutatePOSTtoDELETE";
>
> public PostToDeleteWithBodyIntercepto__r() {
> super(Phase.PRE_PROTOCOL);
> }
>
> public void handleMessage(Message message) {
> String path = (String)
> message.getExchange().__getOutMessage().get(Message.__REQUEST_URI);
> String method = (String)
> message.getExchange().__getOutMessage().get(Message.__HTTP_REQUEST_METHOD);
> if (method != null && method.equals("POST") && path != null &&
> path.endsWith(EXTRA_PATH)) {
> // TODO remove EXTRA_PATH
> // TODO transform POST into DELETE
> }
> }
> }
>
> I have a few doubts:
>
> - I don't know how to modify the path and the method of the
> request. I
>
> have tried modifying the content of the
> - I don't know what is the exact phase where apply it.
> - Why do I need to look for exchange, out message to see
> current path
>
> and method? It should be in the message, but the values are
> null.
>
> Thank you!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27 <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:54, Sergey Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>> wrote:
>
> Hi,
>
> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>
> Yes, the server is not under my control. I want to
> develop a client
> because
> I like how CXF works and it is a dependency for other
> issues in my
> project.
> Obviously I would never develop a service with body in
> DELETE requests.
>
> The, taking into account that I'm using CXF 2.7.x, is it
> possible to
> workaround my problem using CXF?
>
> Probably not at the moment,
>
> I've opened
> https://issues.apache.org/**__jira/browse/CXF-5337
> <https://issues.apache.org/**jira/browse/CXF-5337><https://__issues.apache.org/jira/browse/__CXF-5337
> <https://issues.apache.org/jira/browse/CXF-5337>>
>
>
> Please watch it.
>
> In meantime, may be it is possible to 'tunnel' it, example,
> use POST but
> set some header with the real/intended HTTP verb such as
> DELETE, the target
> server would need to replace POST with DELETE, the easy way
> is to say
> create Servlet filter which will use HTTPServletRequest
> wrapper to return
> DELETE, some work is needed there but no changes to the
> server code itself
> will be required.
>
> Otherwise - try snapshots once CXF-5337 gets resolved
>
> Thanks, Sergey
>
> Thank you Sergey!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:23, Sergey Beryozkin
> <sberyozkin@gmail.com <ma...@gmail.com>> wrote:
>
> Right, looks like the following has to be done with
> HTTPClient:
>
>
> https://code.google.com/p/****__rest-client/source/browse/**
> <https://code.google.com/p/****rest-client/source/browse/**><h__ttps://code.google.com/p/**__rest-client/source/browse/**
> <https://code.google.com/p/**rest-client/source/browse/**>>
> restclient-lib/src/main/java/*__***org/wiztools/restclient/__http/****
> EntityEnclosingDelete.java<__htt**ps://code.google.com/p/__rest-**
> <http://code.google.com/p/rest-**>
> client/source/browse/**__restclient-lib/src/main/java/*__*
> org/wiztools/restclient/http/*__*EntityEnclosingDelete.java<ht__tps://code.google.com/p/rest-__client/source/browse/__restclient-lib/src/main/java/__org/wiztools/restclient/http/__EntityEnclosingDelete.java
> <https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>>
>
>
>
>
> This is the code based on the advice from HttpClient
> forums.
>
> I guess we should check if CXF Async Conduit can be
> updated respectively
>
> By the way, I'm assuming you have to do DELETE with
> a body because you
> have some existing/legacy service expecting it this
> way ? Now and then
> users ask about it, and I don't mind to get the
> Async HTTP conduit
> updated
> a bit anyway, but if you have say a CXF server
> listening, then I'm sure
> there could be an easier way :-)
>
> Cheers, Sergey
>
>
> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>
> Looking for logs, I've realized that the property
> is producing changes.
>
> I
> mean the Async HTTP client is being used.
> However my DELETE request has
> no
> body. My client interface is JAX-RS annotated,
> my Resource class is JaxB
> annotated:
>
> @Path("/server/path")
> @DELETE
> @Consumes(MediaType.****__APPLICATION_JSON)
>
>
> public void deleteResource(Resource resource);
>
> I have a create method working with de same
> configuration and it works:
>
> @Path("/server/path")
> @POST
> @Consumes(MediaType.****__APPLICATION_JSON)
>
>
> public void createResource(Resource resource);
>
> I'm using Jackson as JSON serializer, but I
> guess it has no relation
> with
> this problem.
>
> These log lines show that the DELETE request has
> content-lenght 0 and
> the Async HTTP client is being used
>
> [I/O dispatcher 2] DEBUG
> org.apache.cxf.transport.http.__****asyncclient.****__AsyncHTTPConduitFactory$2
>
> -
>
> Connection leased: [id: 2][route:
> {}->http://my_server][total kept
> alive:
> 0; route allocated: 1 of 1000; total allocated:
> 0 of 5000]
> [I/O dispatcher 2] DEBUG
> org.apache.cxf.transport.http.__****asyncclient.****__AsyncHTTPConduitFactory$3
>
> -
> [exchange: 3] Connection allocated:
> [id:2][route:{}->http:/my_****__server][state:null]
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152><->server___****ip[ACTIVE][r:]:
> Set
> attribute
> http.nio.exchange-handler
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152><->server___****ip[ACTIVE][rw:]:
> Event
> set [w]
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152><->server___****ip[ACTIVE][rw:]:
> Set
>
>
> attribute http.nio.http-exchange-state
> [I/O dispatcher 2] DEBUG
> org.apache.cxf.transport.http.__****asyncclient.****__AsyncHTTPConduitFactory$3
>
> -
>
> [exchange: 3] Attempt 1 to execute request
> [I/O dispatcher 2] DEBUG
> org.apache.http.impl.nio.****
> reactor.IOSessionImpl
> -
> http-outgoing-2 192.168.254.86:35152
> <http://192.168.254.86:35152><->server___****ip[ACTIVE][rw:]:
> Set
> timeout
> 60000
> [I/O dispatcher 2] DEBUG org.apache.http.client.****
>
> protocol.RequestAuthCache
>
> -
> Auth cache not set in the context
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.****__protocol.****__RequestTargetAuthentication
> -
>
> Target
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.****__protocol.****__RequestProxyAuthentication
> -
>
> Proxy
>
> auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG org.apache.http.headers
> - http-outgoing-2 >> *
> DELETE* /server/path HTTP/1.1
>
> [I/O dispatcher 2] DEBUG org.apache.http.headers
> - http-outgoing-2 >>
> Accept: text/plain
> [I/O dispatcher 2] DEBUG org.apache.http.headers
> - http-outgoing-2 >>
> User-Agent: Apache CXF 2.7.4
> [I/O dispatcher 2] DEBUG org.apache.http.headers
> - http-outgoing-2 >>
> *Content-Length:
> 0*
>
> [I/O dispatcher 2] DEBUG org.apache.http.headers
> - http-outgoing-2 >>
> Host:
> my_server
> [I/O dispatcher 2] DEBUG org.apache.http.headers
> - http-outgoing-2 >>
> Connection: Keep-Alive
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 15:17, Julio Carlos Barrera
> Juez <
> juliocarlos.barrera@i2cat.net
> <ma...@i2cat.net>> wrote:
>
> I don't know how to install CXF Async HTTP
> transport. I have the maven
>
> artifact in my project dependencies, but
> nothing else.
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and Networks Area
> (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 13:14, Sergey Beryozkin
> <sberyozkin@gmail.com
> <ma...@gmail.com>>
> wrote:
>
> I guess you don't have CXF Async HTTP
> transport installed ?
>
> Other than that I've no idea, if it
> won;t work with the Async module
> then
> I guess it is possible to do
> Sergey
>
> On 16/10/13 11:49, Julio Carlos Barrera
> Juez wrote:
>
> I tried to use this information
> before, but I don't know how to
> solve
>
> my
> problem.
>
> I have something like this:
>
> ProxyClassLoader classLoader = new
> ProxyClassLoader();
>
> classLoader.addLoader(******__IServiceInterface.class.****
> getClassLoader());
> classLoader.addLoader(******__JAXRSClientFactoryBean.class.*__*****
>
>
>
> getClassLoader());
>
> JAXRSClientFactoryBean bean = new
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
> bean.setResourceClass(******__IServiceInterface.class);
>
> bean.setClassLoader(******__classLoader);
>
>
>
>
> client (IServiceInterface)
> bean.create();
>
> Then I can use the client object as
> usual. But if fails sending
> DELETE
> requests with body.
>
> I tried doing this:
>
> ProxyClassLoader classLoader = new
> ProxyClassLoader();
>
> classLoader.addLoader(******__IServiceInterface.class.****
> getClassLoader());
> classLoader.addLoader(******__JAXRSClientFactoryBean.class.*__*****
>
>
>
> getClassLoader());
>
> JAXRSClientFactoryBean bean = new
> JAXRSClientFactoryBean();
> bean.setAddress(uri);
> bean.setResourceClass(******__IServiceInterface.class);
>
> bean.setClassLoader(******__classLoader);
>
>
>
>
> // allow body in DELETE requests
> Client client = bean.create();
>
> WebClient.getConfig(client).**__****getRequestContext().put("*__*
> use.****
> async.http.conduit",
> true);
>
> (IServiceInterface)
> client.******__whateverMethodThatSendsDelete(__**
>
> ****);
>
>
>
> But it didn't work.
>
> What am I missing?
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and
> Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 12:00, Sergey
> Beryozkin <sberyozkin@gmail.com
> <ma...@gmail.com>>
> wrote:
>
> Hi
>
>
> On 16/10/13 09:18, Julio Carlos
> Barrera Juez wrote:
>
> Hi.
>
>
> I'm creating a REST client
> using JAXRSClientFactoryBean and
> ProxyClassLoader based on a
> JAXRS annotated Java interface.
>
> I want to send a DELETE with
> body, which is not
> recommended by
> RESTful
> philosophy, but it is
> allowed by HTTP 1.1 RFC.
>
> The body is not sent by the
> client and I have read a lot of
> problems
> to
> allow it.
>
> Is it possible send a body
> in my DELETE requests with this
> configuration?
>
> Please check this thread
>
>
> http://cxf.547215.n5.nabble.**__******com/JaxRS-Client-with-**
>
> Deletes-****
> td5731444.html<http://cxf.****__54**7215.n5.nabble.com/JaxRS-*__***
> <http://7215.n5.nabble.com/JaxRS-****><http://7215.n5.nabble.com/__JaxRS-**
> <http://7215.n5.nabble.com/JaxRS-**>>
> <http://547215.n5.nabble.com/*__*JaxRS-**
> <http://547215.n5.nabble.com/**JaxRS-**><http://547215.n5.__nabble.com/JaxRS-**
> <http://547215.n5.nabble.com/JaxRS-**>>
>
>
> Client-with-Deletes-td5731444.__******html<http://cxf.547215.__n5.
> <http://cxf.547215.n5.>****
> nabble.com/JaxRS-Client-with-*__***Deletes-td5731444.html
> <http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html><http__://nabble.com/JaxRS-Client-__with-**Deletes-td5731444.html
> <http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>>
> <http:/**/cxf.547215.n5.__nabble.com/**JaxRS-Client-__with-Deletes-**
> <http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>
>
> td5731444.html<http://cxf.__547215.n5.nabble.com/JaxRS-__Client-with-Deletes-td5731444.__html
> <http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>>
>
>
>
>
>
>
>
>
> Cheers, Sergey
>
>
>
>
> Thank you!
>
>
> Regards, Julio
>
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99
> 27
> <tel:%2B34%2093%20357%2099%2027>
> Distributed Applications and
> Networks Area (DANA)
> i2CAT Foundation, Barcelona,
> Spain
> http://dana.i2cat.net
>
>
>
>
>
>
> --
>
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
>
>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
Hi Sergey.
First of all, excuse me by the duplicate message.
I have just written a Filter like this:
public class PostToDeleteWithBodyFilter implements ClientRequestFilter {
public final static String EXTRA_PATH = "/mutatePOSTtoDELETE";
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
String method = requestContext.getMethod();
String path = requestContext.getUri().getPath();
if (path != null && path.endsWith(EXTRA_PATH)) {
// remove EXTRA_PATH
requestContext.setUri(URI.create(path.substring(0, path.length() -
EXTRA_PATH.length())));
// transform POST into DELETE
requestContext.setMethod("DELETE");
}
}
}
I have some issues again. The method var is null. And the most important,
an exception is thrown when I use this filter:
Caused by: java.io.IOException: IOException invoking
http://<my_server>/real_path/mutatePOSTtoDELETE:
insufficient data written
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1338)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1322)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 31 more
Caused by: java.io.IOException: insufficient data written
at
sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.close(HttpURLConnection.java:2861)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1175)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at
org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:260)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1517)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
... 34 more
I tried to detect the special message to be mutated using an extra path
string appended to the real path. It worked, it was detected, but something
went wrong...
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 17 October 2013 12:17, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> Can you register an instance of JAX-RS 2.0 ClientRequestFilter (as a
> provider) and set your method & request URI if needed there ?
> That should make it simpler for you.
>
> Re using a custom CXF interceptor, it really should have the properties
> which you check already set on the message passed to handleMessage(), that
> message is an out message, so you should have "message ==
> message.getExchange().**getOutMessage()" hold true.
>
> Cheers, Sergey
>
>
> On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
>
>> I'm trying to workaround this problem with an output CXF interceptor. I
>> have modified the DELETE request to be a POST request allowing a body. I
>> want that my interceptor will detect the POST request and will change it
>> to
>> a DELETE. I'm having some problems to achieve it. How can the interceptor
>> modify the message object to achieve my goal?
>>
>> I have written something like this:
>>
>> public class PostToDeleteWithBodyIntercepto**r extends
>> AbstractPhaseInterceptor<**Message> {
>>
>> public final static String EXTRA_PATH = "/mutatePOSTtoDELETE";
>>
>> public PostToDeleteWithBodyIntercepto**r() {
>> super(Phase.PRE_PROTOCOL);
>> }
>>
>> public void handleMessage(Message message) {
>> String path = (String)
>> message.getExchange().**getOutMessage().get(Message.**REQUEST_URI);
>> String method = (String)
>> message.getExchange().**getOutMessage().get(Message.**
>> HTTP_REQUEST_METHOD);
>> if (method != null && method.equals("POST") && path != null &&
>> path.endsWith(EXTRA_PATH)) {
>> // TODO remove EXTRA_PATH
>> // TODO transform POST into DELETE
>> }
>> }
>> }
>>
>> I have a few doubts:
>>
>> - I don't know how to modify the path and the method of the request. I
>>
>> have tried modifying the content of the
>> - I don't know what is the exact phase where apply it.
>> - Why do I need to look for exchange, out message to see current path
>>
>> and method? It should be in the message, but the values are null.
>>
>> Thank you!
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 16:54, Sergey Beryozkin <sb...@gmail.com> wrote:
>>
>> Hi,
>>>
>>> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>>>
>>> Yes, the server is not under my control. I want to develop a client
>>>> because
>>>> I like how CXF works and it is a dependency for other issues in my
>>>> project.
>>>> Obviously I would never develop a service with body in DELETE requests.
>>>>
>>>> The, taking into account that I'm using CXF 2.7.x, is it possible to
>>>> workaround my problem using CXF?
>>>>
>>>> Probably not at the moment,
>>>>
>>> I've opened
>>> https://issues.apache.org/****jira/browse/CXF-5337<https://issues.apache.org/**jira/browse/CXF-5337>
>>> <https://**issues.apache.org/jira/browse/**CXF-5337<https://issues.apache.org/jira/browse/CXF-5337>
>>> >
>>>
>>>
>>> Please watch it.
>>>
>>> In meantime, may be it is possible to 'tunnel' it, example, use POST but
>>> set some header with the real/intended HTTP verb such as DELETE, the
>>> target
>>> server would need to replace POST with DELETE, the easy way is to say
>>> create Servlet filter which will use HTTPServletRequest wrapper to return
>>> DELETE, some work is needed there but no changes to the server code
>>> itself
>>> will be required.
>>>
>>> Otherwise - try snapshots once CXF-5337 gets resolved
>>>
>>> Thanks, Sergey
>>>
>>> Thank you Sergey!
>>>>
>>>> [image: i2cat]
>>>> Julio C. Barrera Juez
>>>> Office phone: +34 93 357 99 27
>>>> Distributed Applications and Networks Area (DANA)
>>>> i2CAT Foundation, Barcelona, Spain
>>>> http://dana.i2cat.net
>>>>
>>>>
>>>> On 16 October 2013 16:23, Sergey Beryozkin <sb...@gmail.com>
>>>> wrote:
>>>>
>>>> Right, looks like the following has to be done with HTTPClient:
>>>>
>>>>>
>>>>> https://code.google.com/p/******rest-client/source/browse/**<https://code.google.com/p/****rest-client/source/browse/**>
>>>>> <h**ttps://code.google.com/p/****rest-client/source/browse/**<https://code.google.com/p/**rest-client/source/browse/**>
>>>>> >
>>>>> restclient-lib/src/main/java/******org/wiztools/restclient/**http/****
>>>>> EntityEnclosingDelete.java<**htt**ps://code.google.com/p/**rest-**<http://code.google.com/p/rest-**>
>>>>> client/source/browse/****restclient-lib/src/main/java/****
>>>>> org/wiztools/restclient/http/****EntityEnclosingDelete.java<ht**
>>>>> tps://code.google.com/p/rest-**client/source/browse/**
>>>>> restclient-lib/src/main/java/**org/wiztools/restclient/http/**
>>>>> EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>>>>> >
>>>>>
>>>>>
>>>>>>
>>>>>
>>>>> This is the code based on the advice from HttpClient forums.
>>>>>
>>>>> I guess we should check if CXF Async Conduit can be updated
>>>>> respectively
>>>>>
>>>>> By the way, I'm assuming you have to do DELETE with a body because you
>>>>> have some existing/legacy service expecting it this way ? Now and then
>>>>> users ask about it, and I don't mind to get the Async HTTP conduit
>>>>> updated
>>>>> a bit anyway, but if you have say a CXF server listening, then I'm sure
>>>>> there could be an easier way :-)
>>>>>
>>>>> Cheers, Sergey
>>>>>
>>>>>
>>>>> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>>>>>
>>>>> Looking for logs, I've realized that the property is producing
>>>>> changes.
>>>>>
>>>>>> I
>>>>>> mean the Async HTTP client is being used. However my DELETE request
>>>>>> has
>>>>>> no
>>>>>> body. My client interface is JAX-RS annotated, my Resource class is
>>>>>> JaxB
>>>>>> annotated:
>>>>>>
>>>>>> @Path("/server/path")
>>>>>> @DELETE
>>>>>> @Consumes(MediaType.******APPLICATION_JSON)
>>>>>>
>>>>>>
>>>>>> public void deleteResource(Resource resource);
>>>>>>
>>>>>> I have a create method working with de same configuration and it
>>>>>> works:
>>>>>>
>>>>>> @Path("/server/path")
>>>>>> @POST
>>>>>> @Consumes(MediaType.******APPLICATION_JSON)
>>>>>>
>>>>>>
>>>>>> public void createResource(Resource resource);
>>>>>>
>>>>>> I'm using Jackson as JSON serializer, but I guess it has no relation
>>>>>> with
>>>>>> this problem.
>>>>>>
>>>>>> These log lines show that the DELETE request has content-lenght 0 and
>>>>>> the Async HTTP client is being used
>>>>>>
>>>>>> [I/O dispatcher 2] DEBUG
>>>>>> org.apache.cxf.transport.http.******asyncclient.******
>>>>>> AsyncHTTPConduitFactory$2
>>>>>>
>>>>>> -
>>>>>>
>>>>>> Connection leased: [id: 2][route: {}->http://my_server][total kept
>>>>>> alive:
>>>>>> 0; route allocated: 1 of 1000; total allocated: 0 of 5000]
>>>>>> [I/O dispatcher 2] DEBUG
>>>>>> org.apache.cxf.transport.http.******asyncclient.******
>>>>>> AsyncHTTPConduitFactory$3
>>>>>>
>>>>>> -
>>>>>> [exchange: 3] Connection allocated:
>>>>>> [id:2][route:{}->http:/my_******server][state:null]
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>>> reactor.IOSessionImpl
>>>>>> -
>>>>>> http-outgoing-2 192.168.254.86:35152<->server_******ip[ACTIVE][r:]:
>>>>>> Set
>>>>>> attribute
>>>>>> http.nio.exchange-handler
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>>> reactor.IOSessionImpl
>>>>>> -
>>>>>> http-outgoing-2 192.168.254.86:35152<->server_******ip[ACTIVE][rw:]:
>>>>>> Event
>>>>>> set [w]
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>>> reactor.IOSessionImpl
>>>>>> -
>>>>>> http-outgoing-2 192.168.254.86:35152<->server_******ip[ACTIVE][rw:]:
>>>>>> Set
>>>>>>
>>>>>>
>>>>>> attribute http.nio.http-exchange-state
>>>>>> [I/O dispatcher 2] DEBUG
>>>>>> org.apache.cxf.transport.http.******asyncclient.******
>>>>>> AsyncHTTPConduitFactory$3
>>>>>>
>>>>>> -
>>>>>>
>>>>>> [exchange: 3] Attempt 1 to execute request
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>>> reactor.IOSessionImpl
>>>>>> -
>>>>>> http-outgoing-2 192.168.254.86:35152<->server_******ip[ACTIVE][rw:]:
>>>>>> Set
>>>>>> timeout
>>>>>> 60000
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.client.****
>>>>>>
>>>>>> protocol.RequestAuthCache
>>>>>>
>>>>>> -
>>>>>> Auth cache not set in the context
>>>>>> [I/O dispatcher 2] DEBUG
>>>>>> org.apache.http.client.******protocol.******RequestTargetAuthentication
>>>>>> -
>>>>>>
>>>>>> Target
>>>>>>
>>>>>> auth
>>>>>> state: UNCHALLENGED
>>>>>> [I/O dispatcher 2] DEBUG
>>>>>> org.apache.http.client.******protocol.******RequestProxyAuthentication
>>>>>> -
>>>>>>
>>>>>> Proxy
>>>>>>
>>>>>> auth
>>>>>> state: UNCHALLENGED
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>>> *
>>>>>> DELETE* /server/path HTTP/1.1
>>>>>>
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>>> Accept: text/plain
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>>> User-Agent: Apache CXF 2.7.4
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>>> *Content-Length:
>>>>>> 0*
>>>>>>
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>>> Host:
>>>>>> my_server
>>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>>> Connection: Keep-Alive
>>>>>>
>>>>>> [image: i2cat]
>>>>>> Julio C. Barrera Juez
>>>>>> Office phone: +34 93 357 99 27
>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>> http://dana.i2cat.net
>>>>>>
>>>>>>
>>>>>> On 16 October 2013 15:17, Julio Carlos Barrera Juez <
>>>>>> juliocarlos.barrera@i2cat.net> wrote:
>>>>>>
>>>>>> I don't know how to install CXF Async HTTP transport. I have the
>>>>>> maven
>>>>>>
>>>>>> artifact in my project dependencies, but nothing else.
>>>>>>>
>>>>>>> [image: i2cat]
>>>>>>> Julio C. Barrera Juez
>>>>>>> Office phone: +34 93 357 99 27
>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>> http://dana.i2cat.net
>>>>>>>
>>>>>>>
>>>>>>> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> I guess you don't have CXF Async HTTP transport installed ?
>>>>>>>
>>>>>>> Other than that I've no idea, if it won;t work with the Async module
>>>>>>>> then
>>>>>>>> I guess it is possible to do
>>>>>>>> Sergey
>>>>>>>>
>>>>>>>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>>>>>>>
>>>>>>>> I tried to use this information before, but I don't know how to
>>>>>>>> solve
>>>>>>>>
>>>>>>>> my
>>>>>>>>> problem.
>>>>>>>>>
>>>>>>>>> I have something like this:
>>>>>>>>>
>>>>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>>>>> classLoader.addLoader(********IServiceInterface.class.****
>>>>>>>>> getClassLoader());
>>>>>>>>> classLoader.addLoader(********JAXRSClientFactoryBean.class.***
>>>>>>>>> *****
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> getClassLoader());
>>>>>>>>>
>>>>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>>>>> bean.setAddress(uri);
>>>>>>>>> bean.setResourceClass(********IServiceInterface.class);
>>>>>>>>> bean.setClassLoader(********classLoader);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> client (IServiceInterface) bean.create();
>>>>>>>>>
>>>>>>>>> Then I can use the client object as usual. But if fails sending
>>>>>>>>> DELETE
>>>>>>>>> requests with body.
>>>>>>>>>
>>>>>>>>> I tried doing this:
>>>>>>>>>
>>>>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>>>>> classLoader.addLoader(********IServiceInterface.class.****
>>>>>>>>> getClassLoader());
>>>>>>>>> classLoader.addLoader(********JAXRSClientFactoryBean.class.***
>>>>>>>>> *****
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> getClassLoader());
>>>>>>>>>
>>>>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>>>>> bean.setAddress(uri);
>>>>>>>>> bean.setResourceClass(********IServiceInterface.class);
>>>>>>>>> bean.setClassLoader(********classLoader);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> // allow body in DELETE requests
>>>>>>>>> Client client = bean.create();
>>>>>>>>> WebClient.getConfig(client).****
>>>>>>>>> ****getRequestContext().put("****
>>>>>>>>> use.****
>>>>>>>>> async.http.conduit",
>>>>>>>>> true);
>>>>>>>>>
>>>>>>>>> (IServiceInterface) client.********whateverMethodThatSendsDelete(*
>>>>>>>>> ***
>>>>>>>>>
>>>>>>>>> ****);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> But it didn't work.
>>>>>>>>>
>>>>>>>>> What am I missing?
>>>>>>>>>
>>>>>>>>> [image: i2cat]
>>>>>>>>> Julio C. Barrera Juez
>>>>>>>>> Office phone: +34 93 357 99 27
>>>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>>>> http://dana.i2cat.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>>>>>>>
>>>>>>>>>> Hi.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>>>>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>>>>>>>
>>>>>>>>>>> I want to send a DELETE with body, which is not recommended by
>>>>>>>>>>> RESTful
>>>>>>>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>>>>>>>
>>>>>>>>>>> The body is not sent by the client and I have read a lot of
>>>>>>>>>>> problems
>>>>>>>>>>> to
>>>>>>>>>>> allow it.
>>>>>>>>>>>
>>>>>>>>>>> Is it possible send a body in my DELETE requests with this
>>>>>>>>>>> configuration?
>>>>>>>>>>>
>>>>>>>>>>> Please check this thread
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> http://cxf.547215.n5.nabble.**********com/JaxRS-Client-with-**
>>>>>>>>>>>
>>>>>>>>>> Deletes-****
>>>>>>>>>> td5731444.html<http://cxf.******54**7215.n5.nabble.com/JaxRS-***
>>>>>>>>>> *** <http://7215.n5.nabble.com/JaxRS-****><
>>>>>>>>>> http://7215.n5.nabble.com/**JaxRS-**<http://7215.n5.nabble.com/JaxRS-**>
>>>>>>>>>> >
>>>>>>>>>> <http://547215.n5.nabble.com/****JaxRS-**<http://547215.n5.nabble.com/**JaxRS-**>
>>>>>>>>>> <http://547215.n5.**nabble.com/JaxRS-**<http://547215.n5.nabble.com/JaxRS-**>
>>>>>>>>>> >
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Client-with-Deletes-td5731444.********html<http://cxf.547215.**
>>>>>>>>>> n5. <http://cxf.547215.n5.>****
>>>>>>>>>> nabble.com/JaxRS-Client-with-******Deletes-td5731444.html<http://nabble.com/JaxRS-Client-with-****Deletes-td5731444.html>
>>>>>>>>>> <http**://nabble.com/JaxRS-Client-**with-**Deletes-td5731444.html<http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>
>>>>>>>>>> >
>>>>>>>>>> <http:/**/cxf.547215.n5.**nabble.com/**JaxRS-Client-**
>>>>>>>>>> with-Deletes-**<http://cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**>
>>>>>>>>>>
>>>>>>>>>> td5731444.html<http://cxf.**547215.n5.nabble.com/JaxRS-**
>>>>>>>>>> Client-with-Deletes-td5731444.**html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>>>>>>>> >
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Cheers, Sergey
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thank you!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Regards, Julio
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> [image: i2cat]
>>>>>>>>>>> Julio C. Barrera Juez
>>>>>>>>>>> Office phone: +34 93 357 99 27
>>>>>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>>>>>> http://dana.i2cat.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>
>>>>>>>> Sergey Beryozkin
>>>>>>>>
>>>>>>>> Talend Community Coders
>>>>>>>> http://coders.talend.com/
>>>>>>>>
>>>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>> Sergey Beryozkin
>>>>>
>>>>> Talend Community Coders
>>>>> http://coders.talend.com/
>>>>>
>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>
>>>>>
>>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>
>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
Can you register an instance of JAX-RS 2.0 ClientRequestFilter (as a
provider) and set your method & request URI if needed there ?
That should make it simpler for you.
Re using a custom CXF interceptor, it really should have the properties
which you check already set on the message passed to handleMessage(),
that message is an out message, so you should have "message ==
message.getExchange().getOutMessage()" hold true.
Cheers, Sergey
On 17/10/13 08:11, Julio Carlos Barrera Juez wrote:
> I'm trying to workaround this problem with an output CXF interceptor. I
> have modified the DELETE request to be a POST request allowing a body. I
> want that my interceptor will detect the POST request and will change it to
> a DELETE. I'm having some problems to achieve it. How can the interceptor
> modify the message object to achieve my goal?
>
> I have written something like this:
>
> public class PostToDeleteWithBodyInterceptor extends
> AbstractPhaseInterceptor<Message> {
>
> public final static String EXTRA_PATH = "/mutatePOSTtoDELETE";
>
> public PostToDeleteWithBodyInterceptor() {
> super(Phase.PRE_PROTOCOL);
> }
>
> public void handleMessage(Message message) {
> String path = (String)
> message.getExchange().getOutMessage().get(Message.REQUEST_URI);
> String method = (String)
> message.getExchange().getOutMessage().get(Message.HTTP_REQUEST_METHOD);
> if (method != null && method.equals("POST") && path != null &&
> path.endsWith(EXTRA_PATH)) {
> // TODO remove EXTRA_PATH
> // TODO transform POST into DELETE
> }
> }
> }
>
> I have a few doubts:
>
> - I don't know how to modify the path and the method of the request. I
> have tried modifying the content of the
> - I don't know what is the exact phase where apply it.
> - Why do I need to look for exchange, out message to see current path
> and method? It should be in the message, but the values are null.
>
> Thank you!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:54, Sergey Beryozkin <sb...@gmail.com> wrote:
>
>> Hi,
>>
>> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>>
>>> Yes, the server is not under my control. I want to develop a client
>>> because
>>> I like how CXF works and it is a dependency for other issues in my
>>> project.
>>> Obviously I would never develop a service with body in DELETE requests.
>>>
>>> The, taking into account that I'm using CXF 2.7.x, is it possible to
>>> workaround my problem using CXF?
>>>
>>> Probably not at the moment,
>> I've opened
>> https://issues.apache.org/**jira/browse/CXF-5337<https://issues.apache.org/jira/browse/CXF-5337>
>>
>> Please watch it.
>>
>> In meantime, may be it is possible to 'tunnel' it, example, use POST but
>> set some header with the real/intended HTTP verb such as DELETE, the target
>> server would need to replace POST with DELETE, the easy way is to say
>> create Servlet filter which will use HTTPServletRequest wrapper to return
>> DELETE, some work is needed there but no changes to the server code itself
>> will be required.
>>
>> Otherwise - try snapshots once CXF-5337 gets resolved
>>
>> Thanks, Sergey
>>
>>> Thank you Sergey!
>>>
>>> [image: i2cat]
>>> Julio C. Barrera Juez
>>> Office phone: +34 93 357 99 27
>>> Distributed Applications and Networks Area (DANA)
>>> i2CAT Foundation, Barcelona, Spain
>>> http://dana.i2cat.net
>>>
>>>
>>> On 16 October 2013 16:23, Sergey Beryozkin <sb...@gmail.com> wrote:
>>>
>>> Right, looks like the following has to be done with HTTPClient:
>>>>
>>>> https://code.google.com/p/****rest-client/source/browse/**<https://code.google.com/p/**rest-client/source/browse/**>
>>>> restclient-lib/src/main/java/****org/wiztools/restclient/http/****
>>>> EntityEnclosingDelete.java<htt**ps://code.google.com/p/rest-**
>>>> client/source/browse/**restclient-lib/src/main/java/**
>>>> org/wiztools/restclient/http/**EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>>>>>
>>>>
>>>>
>>>> This is the code based on the advice from HttpClient forums.
>>>>
>>>> I guess we should check if CXF Async Conduit can be updated respectively
>>>>
>>>> By the way, I'm assuming you have to do DELETE with a body because you
>>>> have some existing/legacy service expecting it this way ? Now and then
>>>> users ask about it, and I don't mind to get the Async HTTP conduit
>>>> updated
>>>> a bit anyway, but if you have say a CXF server listening, then I'm sure
>>>> there could be an easier way :-)
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>>>>
>>>> Looking for logs, I've realized that the property is producing changes.
>>>>> I
>>>>> mean the Async HTTP client is being used. However my DELETE request has
>>>>> no
>>>>> body. My client interface is JAX-RS annotated, my Resource class is JaxB
>>>>> annotated:
>>>>>
>>>>> @Path("/server/path")
>>>>> @DELETE
>>>>> @Consumes(MediaType.****APPLICATION_JSON)
>>>>>
>>>>> public void deleteResource(Resource resource);
>>>>>
>>>>> I have a create method working with de same configuration and it works:
>>>>>
>>>>> @Path("/server/path")
>>>>> @POST
>>>>> @Consumes(MediaType.****APPLICATION_JSON)
>>>>>
>>>>> public void createResource(Resource resource);
>>>>>
>>>>> I'm using Jackson as JSON serializer, but I guess it has no relation
>>>>> with
>>>>> this problem.
>>>>>
>>>>> These log lines show that the DELETE request has content-lenght 0 and
>>>>> the Async HTTP client is being used
>>>>>
>>>>> [I/O dispatcher 2] DEBUG
>>>>> org.apache.cxf.transport.http.****asyncclient.****AsyncHTTPConduitFactory$2
>>>>> -
>>>>>
>>>>> Connection leased: [id: 2][route: {}->http://my_server][total kept
>>>>> alive:
>>>>> 0; route allocated: 1 of 1000; total allocated: 0 of 5000]
>>>>> [I/O dispatcher 2] DEBUG
>>>>> org.apache.cxf.transport.http.****asyncclient.****AsyncHTTPConduitFactory$3
>>>>> -
>>>>> [exchange: 3] Connection allocated:
>>>>> [id:2][route:{}->http:/my_****server][state:null]
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>> reactor.IOSessionImpl
>>>>> -
>>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][r:]: Set
>>>>> attribute
>>>>> http.nio.exchange-handler
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>> reactor.IOSessionImpl
>>>>> -
>>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][rw:]:
>>>>> Event
>>>>> set [w]
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>> reactor.IOSessionImpl
>>>>> -
>>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][rw:]: Set
>>>>>
>>>>> attribute http.nio.http-exchange-state
>>>>> [I/O dispatcher 2] DEBUG
>>>>> org.apache.cxf.transport.http.****asyncclient.****AsyncHTTPConduitFactory$3
>>>>> -
>>>>>
>>>>> [exchange: 3] Attempt 1 to execute request
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>>> reactor.IOSessionImpl
>>>>> -
>>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][rw:]: Set
>>>>> timeout
>>>>> 60000
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.client.****
>>>>> protocol.RequestAuthCache
>>>>>
>>>>> -
>>>>> Auth cache not set in the context
>>>>> [I/O dispatcher 2] DEBUG
>>>>> org.apache.http.client.****protocol.****RequestTargetAuthentication -
>>>>> Target
>>>>>
>>>>> auth
>>>>> state: UNCHALLENGED
>>>>> [I/O dispatcher 2] DEBUG
>>>>> org.apache.http.client.****protocol.****RequestProxyAuthentication -
>>>>> Proxy
>>>>>
>>>>> auth
>>>>> state: UNCHALLENGED
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> *
>>>>> DELETE* /server/path HTTP/1.1
>>>>>
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>> Accept: text/plain
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>> User-Agent: Apache CXF 2.7.4
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>> *Content-Length:
>>>>> 0*
>>>>>
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>> Host:
>>>>> my_server
>>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>>> Connection: Keep-Alive
>>>>>
>>>>> [image: i2cat]
>>>>> Julio C. Barrera Juez
>>>>> Office phone: +34 93 357 99 27
>>>>> Distributed Applications and Networks Area (DANA)
>>>>> i2CAT Foundation, Barcelona, Spain
>>>>> http://dana.i2cat.net
>>>>>
>>>>>
>>>>> On 16 October 2013 15:17, Julio Carlos Barrera Juez <
>>>>> juliocarlos.barrera@i2cat.net> wrote:
>>>>>
>>>>> I don't know how to install CXF Async HTTP transport. I have the maven
>>>>>
>>>>>> artifact in my project dependencies, but nothing else.
>>>>>>
>>>>>> [image: i2cat]
>>>>>> Julio C. Barrera Juez
>>>>>> Office phone: +34 93 357 99 27
>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>> http://dana.i2cat.net
>>>>>>
>>>>>>
>>>>>> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> I guess you don't have CXF Async HTTP transport installed ?
>>>>>>
>>>>>>> Other than that I've no idea, if it won;t work with the Async module
>>>>>>> then
>>>>>>> I guess it is possible to do
>>>>>>> Sergey
>>>>>>>
>>>>>>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>>>>>>
>>>>>>> I tried to use this information before, but I don't know how to
>>>>>>> solve
>>>>>>>
>>>>>>>> my
>>>>>>>> problem.
>>>>>>>>
>>>>>>>> I have something like this:
>>>>>>>>
>>>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>>>> classLoader.addLoader(******IServiceInterface.class.****
>>>>>>>> getClassLoader());
>>>>>>>> classLoader.addLoader(******JAXRSClientFactoryBean.class.******
>>>>>>>>
>>>>>>>>
>>>>>>>> getClassLoader());
>>>>>>>>
>>>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>>>> bean.setAddress(uri);
>>>>>>>> bean.setResourceClass(******IServiceInterface.class);
>>>>>>>> bean.setClassLoader(******classLoader);
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> client (IServiceInterface) bean.create();
>>>>>>>>
>>>>>>>> Then I can use the client object as usual. But if fails sending
>>>>>>>> DELETE
>>>>>>>> requests with body.
>>>>>>>>
>>>>>>>> I tried doing this:
>>>>>>>>
>>>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>>>> classLoader.addLoader(******IServiceInterface.class.****
>>>>>>>> getClassLoader());
>>>>>>>> classLoader.addLoader(******JAXRSClientFactoryBean.class.******
>>>>>>>>
>>>>>>>>
>>>>>>>> getClassLoader());
>>>>>>>>
>>>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>>>> bean.setAddress(uri);
>>>>>>>> bean.setResourceClass(******IServiceInterface.class);
>>>>>>>> bean.setClassLoader(******classLoader);
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> // allow body in DELETE requests
>>>>>>>> Client client = bean.create();
>>>>>>>> WebClient.getConfig(client).******getRequestContext().put("**
>>>>>>>> use.****
>>>>>>>> async.http.conduit",
>>>>>>>> true);
>>>>>>>>
>>>>>>>> (IServiceInterface) client.******whateverMethodThatSendsDelete(**
>>>>>>>> ****);
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> But it didn't work.
>>>>>>>>
>>>>>>>> What am I missing?
>>>>>>>>
>>>>>>>> [image: i2cat]
>>>>>>>> Julio C. Barrera Juez
>>>>>>>> Office phone: +34 93 357 99 27
>>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>>> http://dana.i2cat.net
>>>>>>>>
>>>>>>>>
>>>>>>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>>
>>>>>>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>>>>>>
>>>>>>>>> Hi.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>>>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>>>>>>
>>>>>>>>>> I want to send a DELETE with body, which is not recommended by
>>>>>>>>>> RESTful
>>>>>>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>>>>>>
>>>>>>>>>> The body is not sent by the client and I have read a lot of
>>>>>>>>>> problems
>>>>>>>>>> to
>>>>>>>>>> allow it.
>>>>>>>>>>
>>>>>>>>>> Is it possible send a body in my DELETE requests with this
>>>>>>>>>> configuration?
>>>>>>>>>>
>>>>>>>>>> Please check this thread
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http://cxf.547215.n5.nabble.********com/JaxRS-Client-with-**
>>>>>>>>> Deletes-****
>>>>>>>>> td5731444.html<http://cxf.****54**7215.n5.nabble.com/JaxRS-****<http://7215.n5.nabble.com/JaxRS-**>
>>>>>>>>> <http://547215.n5.nabble.com/**JaxRS-**<http://547215.n5.nabble.com/JaxRS-**>
>>>>>>>>>>
>>>>>>>>> Client-with-Deletes-td5731444.******html<http://cxf.547215.n5.****
>>>>>>>>> nabble.com/JaxRS-Client-with-****Deletes-td5731444.html<http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>
>>>>>>>>> <http:/**/cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**
>>>>>>>>> td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> Cheers, Sergey
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thank you!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Regards, Julio
>>>>>>>>>>
>>>>>>>>>> [image: i2cat]
>>>>>>>>>> Julio C. Barrera Juez
>>>>>>>>>> Office phone: +34 93 357 99 27
>>>>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>>>>> http://dana.i2cat.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>> Sergey Beryozkin
>>>>>>>
>>>>>>> Talend Community Coders
>>>>>>> http://coders.talend.com/
>>>>>>>
>>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
I'm trying to workaround this problem with an output CXF interceptor. I
have modified the DELETE request to be a POST request allowing a body. I
want that my interceptor will detect the POST request and will change it to
a DELETE. I'm having some problems to achieve it. How can the interceptor
modify the message object to achieve my goal?
I have written something like this:
public class PostToDeleteWithBodyInterceptor extends
AbstractPhaseInterceptor<Message> {
public final static String EXTRA_PATH = "/mutatePOSTtoDELETE";
public PostToDeleteWithBodyInterceptor() {
super(Phase.PRE_PROTOCOL);
}
public void handleMessage(Message message) {
String path = (String)
message.getExchange().getOutMessage().get(Message.REQUEST_URI);
String method = (String)
message.getExchange().getOutMessage().get(Message.HTTP_REQUEST_METHOD);
if (method != null && method.equals("POST") && path != null &&
path.endsWith(EXTRA_PATH)) {
// TODO remove EXTRA_PATH
// TODO transform POST into DELETE
}
}
}
I have a few doubts:
- I don't know how to modify the path and the method of the request. I
have tried modifying the content of the
- I don't know what is the exact phase where apply it.
- Why do I need to look for exchange, out message to see current path
and method? It should be in the message, but the values are null.
Thank you!
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 16 October 2013 16:54, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi,
>
> On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
>
>> Yes, the server is not under my control. I want to develop a client
>> because
>> I like how CXF works and it is a dependency for other issues in my
>> project.
>> Obviously I would never develop a service with body in DELETE requests.
>>
>> The, taking into account that I'm using CXF 2.7.x, is it possible to
>> workaround my problem using CXF?
>>
>> Probably not at the moment,
> I've opened
> https://issues.apache.org/**jira/browse/CXF-5337<https://issues.apache.org/jira/browse/CXF-5337>
>
> Please watch it.
>
> In meantime, may be it is possible to 'tunnel' it, example, use POST but
> set some header with the real/intended HTTP verb such as DELETE, the target
> server would need to replace POST with DELETE, the easy way is to say
> create Servlet filter which will use HTTPServletRequest wrapper to return
> DELETE, some work is needed there but no changes to the server code itself
> will be required.
>
> Otherwise - try snapshots once CXF-5337 gets resolved
>
> Thanks, Sergey
>
>> Thank you Sergey!
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 16:23, Sergey Beryozkin <sb...@gmail.com> wrote:
>>
>> Right, looks like the following has to be done with HTTPClient:
>>>
>>> https://code.google.com/p/****rest-client/source/browse/**<https://code.google.com/p/**rest-client/source/browse/**>
>>> restclient-lib/src/main/java/****org/wiztools/restclient/http/****
>>> EntityEnclosingDelete.java<htt**ps://code.google.com/p/rest-**
>>> client/source/browse/**restclient-lib/src/main/java/**
>>> org/wiztools/restclient/http/**EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>>> >
>>>
>>>
>>> This is the code based on the advice from HttpClient forums.
>>>
>>> I guess we should check if CXF Async Conduit can be updated respectively
>>>
>>> By the way, I'm assuming you have to do DELETE with a body because you
>>> have some existing/legacy service expecting it this way ? Now and then
>>> users ask about it, and I don't mind to get the Async HTTP conduit
>>> updated
>>> a bit anyway, but if you have say a CXF server listening, then I'm sure
>>> there could be an easier way :-)
>>>
>>> Cheers, Sergey
>>>
>>>
>>> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>>>
>>> Looking for logs, I've realized that the property is producing changes.
>>>> I
>>>> mean the Async HTTP client is being used. However my DELETE request has
>>>> no
>>>> body. My client interface is JAX-RS annotated, my Resource class is JaxB
>>>> annotated:
>>>>
>>>> @Path("/server/path")
>>>> @DELETE
>>>> @Consumes(MediaType.****APPLICATION_JSON)
>>>>
>>>> public void deleteResource(Resource resource);
>>>>
>>>> I have a create method working with de same configuration and it works:
>>>>
>>>> @Path("/server/path")
>>>> @POST
>>>> @Consumes(MediaType.****APPLICATION_JSON)
>>>>
>>>> public void createResource(Resource resource);
>>>>
>>>> I'm using Jackson as JSON serializer, but I guess it has no relation
>>>> with
>>>> this problem.
>>>>
>>>> These log lines show that the DELETE request has content-lenght 0 and
>>>> the Async HTTP client is being used
>>>>
>>>> [I/O dispatcher 2] DEBUG
>>>> org.apache.cxf.transport.http.****asyncclient.****AsyncHTTPConduitFactory$2
>>>> -
>>>>
>>>> Connection leased: [id: 2][route: {}->http://my_server][total kept
>>>> alive:
>>>> 0; route allocated: 1 of 1000; total allocated: 0 of 5000]
>>>> [I/O dispatcher 2] DEBUG
>>>> org.apache.cxf.transport.http.****asyncclient.****AsyncHTTPConduitFactory$3
>>>> -
>>>> [exchange: 3] Connection allocated:
>>>> [id:2][route:{}->http:/my_****server][state:null]
>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>> reactor.IOSessionImpl
>>>> -
>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][r:]: Set
>>>> attribute
>>>> http.nio.exchange-handler
>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>> reactor.IOSessionImpl
>>>> -
>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][rw:]:
>>>> Event
>>>> set [w]
>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>> reactor.IOSessionImpl
>>>> -
>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][rw:]: Set
>>>>
>>>> attribute http.nio.http-exchange-state
>>>> [I/O dispatcher 2] DEBUG
>>>> org.apache.cxf.transport.http.****asyncclient.****AsyncHTTPConduitFactory$3
>>>> -
>>>>
>>>> [exchange: 3] Attempt 1 to execute request
>>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.****
>>>> reactor.IOSessionImpl
>>>> -
>>>> http-outgoing-2 192.168.254.86:35152<->server_****ip[ACTIVE][rw:]: Set
>>>> timeout
>>>> 60000
>>>> [I/O dispatcher 2] DEBUG org.apache.http.client.****
>>>> protocol.RequestAuthCache
>>>>
>>>> -
>>>> Auth cache not set in the context
>>>> [I/O dispatcher 2] DEBUG
>>>> org.apache.http.client.****protocol.****RequestTargetAuthentication -
>>>> Target
>>>>
>>>> auth
>>>> state: UNCHALLENGED
>>>> [I/O dispatcher 2] DEBUG
>>>> org.apache.http.client.****protocol.****RequestProxyAuthentication -
>>>> Proxy
>>>>
>>>> auth
>>>> state: UNCHALLENGED
>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> *
>>>> DELETE* /server/path HTTP/1.1
>>>>
>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>> Accept: text/plain
>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>> User-Agent: Apache CXF 2.7.4
>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>> *Content-Length:
>>>> 0*
>>>>
>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>> Host:
>>>> my_server
>>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>>> Connection: Keep-Alive
>>>>
>>>> [image: i2cat]
>>>> Julio C. Barrera Juez
>>>> Office phone: +34 93 357 99 27
>>>> Distributed Applications and Networks Area (DANA)
>>>> i2CAT Foundation, Barcelona, Spain
>>>> http://dana.i2cat.net
>>>>
>>>>
>>>> On 16 October 2013 15:17, Julio Carlos Barrera Juez <
>>>> juliocarlos.barrera@i2cat.net> wrote:
>>>>
>>>> I don't know how to install CXF Async HTTP transport. I have the maven
>>>>
>>>>> artifact in my project dependencies, but nothing else.
>>>>>
>>>>> [image: i2cat]
>>>>> Julio C. Barrera Juez
>>>>> Office phone: +34 93 357 99 27
>>>>> Distributed Applications and Networks Area (DANA)
>>>>> i2CAT Foundation, Barcelona, Spain
>>>>> http://dana.i2cat.net
>>>>>
>>>>>
>>>>> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> I guess you don't have CXF Async HTTP transport installed ?
>>>>>
>>>>>> Other than that I've no idea, if it won;t work with the Async module
>>>>>> then
>>>>>> I guess it is possible to do
>>>>>> Sergey
>>>>>>
>>>>>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>>>>>
>>>>>> I tried to use this information before, but I don't know how to
>>>>>> solve
>>>>>>
>>>>>>> my
>>>>>>> problem.
>>>>>>>
>>>>>>> I have something like this:
>>>>>>>
>>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>>> classLoader.addLoader(******IServiceInterface.class.****
>>>>>>> getClassLoader());
>>>>>>> classLoader.addLoader(******JAXRSClientFactoryBean.class.******
>>>>>>>
>>>>>>>
>>>>>>> getClassLoader());
>>>>>>>
>>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>>> bean.setAddress(uri);
>>>>>>> bean.setResourceClass(******IServiceInterface.class);
>>>>>>> bean.setClassLoader(******classLoader);
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> client (IServiceInterface) bean.create();
>>>>>>>
>>>>>>> Then I can use the client object as usual. But if fails sending
>>>>>>> DELETE
>>>>>>> requests with body.
>>>>>>>
>>>>>>> I tried doing this:
>>>>>>>
>>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>>> classLoader.addLoader(******IServiceInterface.class.****
>>>>>>> getClassLoader());
>>>>>>> classLoader.addLoader(******JAXRSClientFactoryBean.class.******
>>>>>>>
>>>>>>>
>>>>>>> getClassLoader());
>>>>>>>
>>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>>> bean.setAddress(uri);
>>>>>>> bean.setResourceClass(******IServiceInterface.class);
>>>>>>> bean.setClassLoader(******classLoader);
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> // allow body in DELETE requests
>>>>>>> Client client = bean.create();
>>>>>>> WebClient.getConfig(client).******getRequestContext().put("**
>>>>>>> use.****
>>>>>>> async.http.conduit",
>>>>>>> true);
>>>>>>>
>>>>>>> (IServiceInterface) client.******whateverMethodThatSendsDelete(**
>>>>>>> ****);
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> But it didn't work.
>>>>>>>
>>>>>>> What am I missing?
>>>>>>>
>>>>>>> [image: i2cat]
>>>>>>> Julio C. Barrera Juez
>>>>>>> Office phone: +34 93 357 99 27
>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>> http://dana.i2cat.net
>>>>>>>
>>>>>>>
>>>>>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>>
>>>>>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>>>>>
>>>>>>>> Hi.
>>>>>>>>
>>>>>>>>
>>>>>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>>>>>
>>>>>>>>> I want to send a DELETE with body, which is not recommended by
>>>>>>>>> RESTful
>>>>>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>>>>>
>>>>>>>>> The body is not sent by the client and I have read a lot of
>>>>>>>>> problems
>>>>>>>>> to
>>>>>>>>> allow it.
>>>>>>>>>
>>>>>>>>> Is it possible send a body in my DELETE requests with this
>>>>>>>>> configuration?
>>>>>>>>>
>>>>>>>>> Please check this thread
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://cxf.547215.n5.nabble.********com/JaxRS-Client-with-**
>>>>>>>> Deletes-****
>>>>>>>> td5731444.html<http://cxf.****54**7215.n5.nabble.com/JaxRS-****<http://7215.n5.nabble.com/JaxRS-**>
>>>>>>>> <http://547215.n5.nabble.com/**JaxRS-**<http://547215.n5.nabble.com/JaxRS-**>
>>>>>>>> >
>>>>>>>> Client-with-Deletes-td5731444.******html<http://cxf.547215.n5.****
>>>>>>>> nabble.com/JaxRS-Client-with-****Deletes-td5731444.html<http://nabble.com/JaxRS-Client-with-**Deletes-td5731444.html>
>>>>>>>> <http:/**/cxf.547215.n5.nabble.com/**JaxRS-Client-with-Deletes-**
>>>>>>>> td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>>>>>> >
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>> Cheers, Sergey
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Thank you!
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards, Julio
>>>>>>>>>
>>>>>>>>> [image: i2cat]
>>>>>>>>> Julio C. Barrera Juez
>>>>>>>>> Office phone: +34 93 357 99 27
>>>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>>>> http://dana.i2cat.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>> --
>>>>>> Sergey Beryozkin
>>>>>>
>>>>>> Talend Community Coders
>>>>>> http://coders.talend.com/
>>>>>>
>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi,
On 16/10/13 15:36, Julio Carlos Barrera Juez wrote:
> Yes, the server is not under my control. I want to develop a client because
> I like how CXF works and it is a dependency for other issues in my project.
> Obviously I would never develop a service with body in DELETE requests.
>
> The, taking into account that I'm using CXF 2.7.x, is it possible to
> workaround my problem using CXF?
>
Probably not at the moment,
I've opened
https://issues.apache.org/jira/browse/CXF-5337
Please watch it.
In meantime, may be it is possible to 'tunnel' it, example, use POST but
set some header with the real/intended HTTP verb such as DELETE, the
target server would need to replace POST with DELETE, the easy way is to
say create Servlet filter which will use HTTPServletRequest wrapper to
return DELETE, some work is needed there but no changes to the server
code itself will be required.
Otherwise - try snapshots once CXF-5337 gets resolved
Thanks, Sergey
> Thank you Sergey!
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 16:23, Sergey Beryozkin <sb...@gmail.com> wrote:
>
>> Right, looks like the following has to be done with HTTPClient:
>>
>> https://code.google.com/p/**rest-client/source/browse/**
>> restclient-lib/src/main/java/**org/wiztools/restclient/http/**
>> EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>>
>> This is the code based on the advice from HttpClient forums.
>>
>> I guess we should check if CXF Async Conduit can be updated respectively
>>
>> By the way, I'm assuming you have to do DELETE with a body because you
>> have some existing/legacy service expecting it this way ? Now and then
>> users ask about it, and I don't mind to get the Async HTTP conduit updated
>> a bit anyway, but if you have say a CXF server listening, then I'm sure
>> there could be an easier way :-)
>>
>> Cheers, Sergey
>>
>>
>> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>>
>>> Looking for logs, I've realized that the property is producing changes. I
>>> mean the Async HTTP client is being used. However my DELETE request has no
>>> body. My client interface is JAX-RS annotated, my Resource class is JaxB
>>> annotated:
>>>
>>> @Path("/server/path")
>>> @DELETE
>>> @Consumes(MediaType.**APPLICATION_JSON)
>>> public void deleteResource(Resource resource);
>>>
>>> I have a create method working with de same configuration and it works:
>>>
>>> @Path("/server/path")
>>> @POST
>>> @Consumes(MediaType.**APPLICATION_JSON)
>>> public void createResource(Resource resource);
>>>
>>> I'm using Jackson as JSON serializer, but I guess it has no relation with
>>> this problem.
>>>
>>> These log lines show that the DELETE request has content-lenght 0 and
>>> the Async HTTP client is being used
>>>
>>> [I/O dispatcher 2] DEBUG
>>> org.apache.cxf.transport.http.**asyncclient.**AsyncHTTPConduitFactory$2 -
>>> Connection leased: [id: 2][route: {}->http://my_server][total kept alive:
>>> 0; route allocated: 1 of 1000; total allocated: 0 of 5000]
>>> [I/O dispatcher 2] DEBUG
>>> org.apache.cxf.transport.http.**asyncclient.**AsyncHTTPConduitFactory$3 -
>>> [exchange: 3] Connection allocated:
>>> [id:2][route:{}->http:/my_**server][state:null]
>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>>> -
>>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][r:]: Set
>>> attribute
>>> http.nio.exchange-handler
>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>>> -
>>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][rw:]: Event
>>> set [w]
>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>>> -
>>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][rw:]: Set
>>> attribute http.nio.http-exchange-state
>>> [I/O dispatcher 2] DEBUG
>>> org.apache.cxf.transport.http.**asyncclient.**AsyncHTTPConduitFactory$3 -
>>> [exchange: 3] Attempt 1 to execute request
>>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>>> -
>>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][rw:]: Set
>>> timeout
>>> 60000
>>> [I/O dispatcher 2] DEBUG org.apache.http.client.**protocol.RequestAuthCache
>>> -
>>> Auth cache not set in the context
>>> [I/O dispatcher 2] DEBUG
>>> org.apache.http.client.**protocol.**RequestTargetAuthentication - Target
>>> auth
>>> state: UNCHALLENGED
>>> [I/O dispatcher 2] DEBUG
>>> org.apache.http.client.**protocol.**RequestProxyAuthentication - Proxy
>>> auth
>>> state: UNCHALLENGED
>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> *
>>> DELETE* /server/path HTTP/1.1
>>>
>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>> Accept: text/plain
>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>> User-Agent: Apache CXF 2.7.4
>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>> *Content-Length:
>>> 0*
>>>
>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>> Host:
>>> my_server
>>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>>> Connection: Keep-Alive
>>>
>>> [image: i2cat]
>>> Julio C. Barrera Juez
>>> Office phone: +34 93 357 99 27
>>> Distributed Applications and Networks Area (DANA)
>>> i2CAT Foundation, Barcelona, Spain
>>> http://dana.i2cat.net
>>>
>>>
>>> On 16 October 2013 15:17, Julio Carlos Barrera Juez <
>>> juliocarlos.barrera@i2cat.net> wrote:
>>>
>>> I don't know how to install CXF Async HTTP transport. I have the maven
>>>> artifact in my project dependencies, but nothing else.
>>>>
>>>> [image: i2cat]
>>>> Julio C. Barrera Juez
>>>> Office phone: +34 93 357 99 27
>>>> Distributed Applications and Networks Area (DANA)
>>>> i2CAT Foundation, Barcelona, Spain
>>>> http://dana.i2cat.net
>>>>
>>>>
>>>> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com> wrote:
>>>>
>>>> I guess you don't have CXF Async HTTP transport installed ?
>>>>> Other than that I've no idea, if it won;t work with the Async module
>>>>> then
>>>>> I guess it is possible to do
>>>>> Sergey
>>>>>
>>>>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>>>>
>>>>> I tried to use this information before, but I don't know how to solve
>>>>>> my
>>>>>> problem.
>>>>>>
>>>>>> I have something like this:
>>>>>>
>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>> classLoader.addLoader(****IServiceInterface.class.****
>>>>>> getClassLoader());
>>>>>> classLoader.addLoader(****JAXRSClientFactoryBean.class.****
>>>>>>
>>>>>> getClassLoader());
>>>>>>
>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>> bean.setAddress(uri);
>>>>>> bean.setResourceClass(****IServiceInterface.class);
>>>>>> bean.setClassLoader(****classLoader);
>>>>>>
>>>>>>
>>>>>> client (IServiceInterface) bean.create();
>>>>>>
>>>>>> Then I can use the client object as usual. But if fails sending DELETE
>>>>>> requests with body.
>>>>>>
>>>>>> I tried doing this:
>>>>>>
>>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>>> classLoader.addLoader(****IServiceInterface.class.****
>>>>>> getClassLoader());
>>>>>> classLoader.addLoader(****JAXRSClientFactoryBean.class.****
>>>>>>
>>>>>> getClassLoader());
>>>>>>
>>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>>> bean.setAddress(uri);
>>>>>> bean.setResourceClass(****IServiceInterface.class);
>>>>>> bean.setClassLoader(****classLoader);
>>>>>>
>>>>>>
>>>>>> // allow body in DELETE requests
>>>>>> Client client = bean.create();
>>>>>> WebClient.getConfig(client).****getRequestContext().put("use.****
>>>>>> async.http.conduit",
>>>>>> true);
>>>>>>
>>>>>> (IServiceInterface) client.****whateverMethodThatSendsDelete(****);
>>>>>>
>>>>>>
>>>>>> But it didn't work.
>>>>>>
>>>>>> What am I missing?
>>>>>>
>>>>>> [image: i2cat]
>>>>>> Julio C. Barrera Juez
>>>>>> Office phone: +34 93 357 99 27
>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>> http://dana.i2cat.net
>>>>>>
>>>>>>
>>>>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>>>
>>>>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>>>>
>>>>>>> Hi.
>>>>>>>
>>>>>>>>
>>>>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>>>>
>>>>>>>> I want to send a DELETE with body, which is not recommended by
>>>>>>>> RESTful
>>>>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>>>>
>>>>>>>> The body is not sent by the client and I have read a lot of problems
>>>>>>>> to
>>>>>>>> allow it.
>>>>>>>>
>>>>>>>> Is it possible send a body in my DELETE requests with this
>>>>>>>> configuration?
>>>>>>>>
>>>>>>>> Please check this thread
>>>>>>>>
>>>>>>>>
>>>>>>> http://cxf.547215.n5.nabble.******com/JaxRS-Client-with-**
>>>>>>> Deletes-****
>>>>>>> td5731444.html<http://cxf.**54**7215.n5.nabble.com/JaxRS-**<http://547215.n5.nabble.com/JaxRS-**>
>>>>>>> Client-with-Deletes-td5731444.****html<http://cxf.547215.n5.**
>>>>>>> nabble.com/JaxRS-Client-with-**Deletes-td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> Cheers, Sergey
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thank you!
>>>>>>>
>>>>>>>
>>>>>>>> Regards, Julio
>>>>>>>>
>>>>>>>> [image: i2cat]
>>>>>>>> Julio C. Barrera Juez
>>>>>>>> Office phone: +34 93 357 99 27
>>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>>> http://dana.i2cat.net
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>> --
>>>>> Sergey Beryozkin
>>>>>
>>>>> Talend Community Coders
>>>>> http://coders.talend.com/
>>>>>
>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
Yes, the server is not under my control. I want to develop a client because
I like how CXF works and it is a dependency for other issues in my project.
Obviously I would never develop a service with body in DELETE requests.
The, taking into account that I'm using CXF 2.7.x, is it possible to
workaround my problem using CXF?
Thank you Sergey!
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 16 October 2013 16:23, Sergey Beryozkin <sb...@gmail.com> wrote:
> Right, looks like the following has to be done with HTTPClient:
>
> https://code.google.com/p/**rest-client/source/browse/**
> restclient-lib/src/main/java/**org/wiztools/restclient/http/**
> EntityEnclosingDelete.java<https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java>
>
> This is the code based on the advice from HttpClient forums.
>
> I guess we should check if CXF Async Conduit can be updated respectively
>
> By the way, I'm assuming you have to do DELETE with a body because you
> have some existing/legacy service expecting it this way ? Now and then
> users ask about it, and I don't mind to get the Async HTTP conduit updated
> a bit anyway, but if you have say a CXF server listening, then I'm sure
> there could be an easier way :-)
>
> Cheers, Sergey
>
>
> On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
>
>> Looking for logs, I've realized that the property is producing changes. I
>> mean the Async HTTP client is being used. However my DELETE request has no
>> body. My client interface is JAX-RS annotated, my Resource class is JaxB
>> annotated:
>>
>> @Path("/server/path")
>> @DELETE
>> @Consumes(MediaType.**APPLICATION_JSON)
>> public void deleteResource(Resource resource);
>>
>> I have a create method working with de same configuration and it works:
>>
>> @Path("/server/path")
>> @POST
>> @Consumes(MediaType.**APPLICATION_JSON)
>> public void createResource(Resource resource);
>>
>> I'm using Jackson as JSON serializer, but I guess it has no relation with
>> this problem.
>>
>> These log lines show that the DELETE request has content-lenght 0 and
>> the Async HTTP client is being used
>>
>> [I/O dispatcher 2] DEBUG
>> org.apache.cxf.transport.http.**asyncclient.**AsyncHTTPConduitFactory$2 -
>> Connection leased: [id: 2][route: {}->http://my_server][total kept alive:
>> 0; route allocated: 1 of 1000; total allocated: 0 of 5000]
>> [I/O dispatcher 2] DEBUG
>> org.apache.cxf.transport.http.**asyncclient.**AsyncHTTPConduitFactory$3 -
>> [exchange: 3] Connection allocated:
>> [id:2][route:{}->http:/my_**server][state:null]
>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][r:]: Set
>> attribute
>> http.nio.exchange-handler
>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][rw:]: Event
>> set [w]
>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][rw:]: Set
>> attribute http.nio.http-exchange-state
>> [I/O dispatcher 2] DEBUG
>> org.apache.cxf.transport.http.**asyncclient.**AsyncHTTPConduitFactory$3 -
>> [exchange: 3] Attempt 1 to execute request
>> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.**reactor.IOSessionImpl
>> -
>> http-outgoing-2 192.168.254.86:35152<->server_**ip[ACTIVE][rw:]: Set
>> timeout
>> 60000
>> [I/O dispatcher 2] DEBUG org.apache.http.client.**protocol.RequestAuthCache
>> -
>> Auth cache not set in the context
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.client.**protocol.**RequestTargetAuthentication - Target
>> auth
>> state: UNCHALLENGED
>> [I/O dispatcher 2] DEBUG
>> org.apache.http.client.**protocol.**RequestProxyAuthentication - Proxy
>> auth
>> state: UNCHALLENGED
>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> *
>> DELETE* /server/path HTTP/1.1
>>
>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>> Accept: text/plain
>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>> User-Agent: Apache CXF 2.7.4
>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>> *Content-Length:
>> 0*
>>
>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>> Host:
>> my_server
>> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
>> Connection: Keep-Alive
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 15:17, Julio Carlos Barrera Juez <
>> juliocarlos.barrera@i2cat.net> wrote:
>>
>> I don't know how to install CXF Async HTTP transport. I have the maven
>>> artifact in my project dependencies, but nothing else.
>>>
>>> [image: i2cat]
>>> Julio C. Barrera Juez
>>> Office phone: +34 93 357 99 27
>>> Distributed Applications and Networks Area (DANA)
>>> i2CAT Foundation, Barcelona, Spain
>>> http://dana.i2cat.net
>>>
>>>
>>> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com> wrote:
>>>
>>> I guess you don't have CXF Async HTTP transport installed ?
>>>> Other than that I've no idea, if it won;t work with the Async module
>>>> then
>>>> I guess it is possible to do
>>>> Sergey
>>>>
>>>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>>>
>>>> I tried to use this information before, but I don't know how to solve
>>>>> my
>>>>> problem.
>>>>>
>>>>> I have something like this:
>>>>>
>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>> classLoader.addLoader(****IServiceInterface.class.****
>>>>> getClassLoader());
>>>>> classLoader.addLoader(****JAXRSClientFactoryBean.class.****
>>>>>
>>>>> getClassLoader());
>>>>>
>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>> bean.setAddress(uri);
>>>>> bean.setResourceClass(****IServiceInterface.class);
>>>>> bean.setClassLoader(****classLoader);
>>>>>
>>>>>
>>>>> client (IServiceInterface) bean.create();
>>>>>
>>>>> Then I can use the client object as usual. But if fails sending DELETE
>>>>> requests with body.
>>>>>
>>>>> I tried doing this:
>>>>>
>>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>>> classLoader.addLoader(****IServiceInterface.class.****
>>>>> getClassLoader());
>>>>> classLoader.addLoader(****JAXRSClientFactoryBean.class.****
>>>>>
>>>>> getClassLoader());
>>>>>
>>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>>> bean.setAddress(uri);
>>>>> bean.setResourceClass(****IServiceInterface.class);
>>>>> bean.setClassLoader(****classLoader);
>>>>>
>>>>>
>>>>> // allow body in DELETE requests
>>>>> Client client = bean.create();
>>>>> WebClient.getConfig(client).****getRequestContext().put("use.****
>>>>> async.http.conduit",
>>>>> true);
>>>>>
>>>>> (IServiceInterface) client.****whateverMethodThatSendsDelete(****);
>>>>>
>>>>>
>>>>> But it didn't work.
>>>>>
>>>>> What am I missing?
>>>>>
>>>>> [image: i2cat]
>>>>> Julio C. Barrera Juez
>>>>> Office phone: +34 93 357 99 27
>>>>> Distributed Applications and Networks Area (DANA)
>>>>> i2CAT Foundation, Barcelona, Spain
>>>>> http://dana.i2cat.net
>>>>>
>>>>>
>>>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>>>
>>>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>>>
>>>>>> Hi.
>>>>>>
>>>>>>>
>>>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>>>
>>>>>>> I want to send a DELETE with body, which is not recommended by
>>>>>>> RESTful
>>>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>>>
>>>>>>> The body is not sent by the client and I have read a lot of problems
>>>>>>> to
>>>>>>> allow it.
>>>>>>>
>>>>>>> Is it possible send a body in my DELETE requests with this
>>>>>>> configuration?
>>>>>>>
>>>>>>> Please check this thread
>>>>>>>
>>>>>>>
>>>>>> http://cxf.547215.n5.nabble.******com/JaxRS-Client-with-**
>>>>>> Deletes-****
>>>>>> td5731444.html<http://cxf.**54**7215.n5.nabble.com/JaxRS-**<http://547215.n5.nabble.com/JaxRS-**>
>>>>>> Client-with-Deletes-td5731444.****html<http://cxf.547215.n5.**
>>>>>> nabble.com/JaxRS-Client-with-**Deletes-td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>>>> >
>>>>>>
>>>>>>
>>>>>>>
>>>>>>
>>>>>> Cheers, Sergey
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank you!
>>>>>>
>>>>>>
>>>>>>> Regards, Julio
>>>>>>>
>>>>>>> [image: i2cat]
>>>>>>> Julio C. Barrera Juez
>>>>>>> Office phone: +34 93 357 99 27
>>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>>> http://dana.i2cat.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>>
>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
Right, looks like the following has to be done with HTTPClient:
https://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/org/wiztools/restclient/http/EntityEnclosingDelete.java
This is the code based on the advice from HttpClient forums.
I guess we should check if CXF Async Conduit can be updated respectively
By the way, I'm assuming you have to do DELETE with a body because you
have some existing/legacy service expecting it this way ? Now and then
users ask about it, and I don't mind to get the Async HTTP conduit
updated a bit anyway, but if you have say a CXF server listening, then
I'm sure there could be an easier way :-)
Cheers, Sergey
On 16/10/13 15:11, Julio Carlos Barrera Juez wrote:
> Looking for logs, I've realized that the property is producing changes. I
> mean the Async HTTP client is being used. However my DELETE request has no
> body. My client interface is JAX-RS annotated, my Resource class is JaxB
> annotated:
>
> @Path("/server/path")
> @DELETE
> @Consumes(MediaType.APPLICATION_JSON)
> public void deleteResource(Resource resource);
>
> I have a create method working with de same configuration and it works:
>
> @Path("/server/path")
> @POST
> @Consumes(MediaType.APPLICATION_JSON)
> public void createResource(Resource resource);
>
> I'm using Jackson as JSON serializer, but I guess it has no relation with
> this problem.
>
> These log lines show that the DELETE request has content-lenght 0 and
> the Async HTTP client is being used
>
> [I/O dispatcher 2] DEBUG
> org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory$2 -
> Connection leased: [id: 2][route: {}->http://my_server][total kept alive:
> 0; route allocated: 1 of 1000; total allocated: 0 of 5000]
> [I/O dispatcher 2] DEBUG
> org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory$3 -
> [exchange: 3] Connection allocated:
> [id:2][route:{}->http:/my_server][state:null]
> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
> http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][r:]: Set attribute
> http.nio.exchange-handler
> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
> http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][rw:]: Event set [w]
> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
> http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][rw:]: Set
> attribute http.nio.http-exchange-state
> [I/O dispatcher 2] DEBUG
> org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory$3 -
> [exchange: 3] Attempt 1 to execute request
> [I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
> http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][rw:]: Set timeout
> 60000
> [I/O dispatcher 2] DEBUG org.apache.http.client.protocol.RequestAuthCache -
> Auth cache not set in the context
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.protocol.RequestTargetAuthentication - Target auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG
> org.apache.http.client.protocol.RequestProxyAuthentication - Proxy auth
> state: UNCHALLENGED
> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> *
> DELETE* /server/path HTTP/1.1
> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
> Accept: text/plain
> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
> User-Agent: Apache CXF 2.7.4
> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
> *Content-Length:
> 0*
> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> Host:
> my_server
> [I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
> Connection: Keep-Alive
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 15:17, Julio Carlos Barrera Juez <
> juliocarlos.barrera@i2cat.net> wrote:
>
>> I don't know how to install CXF Async HTTP transport. I have the maven
>> artifact in my project dependencies, but nothing else.
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com> wrote:
>>
>>> I guess you don't have CXF Async HTTP transport installed ?
>>> Other than that I've no idea, if it won;t work with the Async module then
>>> I guess it is possible to do
>>> Sergey
>>>
>>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>>
>>>> I tried to use this information before, but I don't know how to solve my
>>>> problem.
>>>>
>>>> I have something like this:
>>>>
>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>> classLoader.addLoader(**IServiceInterface.class.**getClassLoader());
>>>> classLoader.addLoader(**JAXRSClientFactoryBean.class.**
>>>> getClassLoader());
>>>>
>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>> bean.setAddress(uri);
>>>> bean.setResourceClass(**IServiceInterface.class);
>>>> bean.setClassLoader(**classLoader);
>>>>
>>>> client (IServiceInterface) bean.create();
>>>>
>>>> Then I can use the client object as usual. But if fails sending DELETE
>>>> requests with body.
>>>>
>>>> I tried doing this:
>>>>
>>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>>> classLoader.addLoader(**IServiceInterface.class.**getClassLoader());
>>>> classLoader.addLoader(**JAXRSClientFactoryBean.class.**
>>>> getClassLoader());
>>>>
>>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>>> bean.setAddress(uri);
>>>> bean.setResourceClass(**IServiceInterface.class);
>>>> bean.setClassLoader(**classLoader);
>>>>
>>>> // allow body in DELETE requests
>>>> Client client = bean.create();
>>>> WebClient.getConfig(client).**getRequestContext().put("use.**
>>>> async.http.conduit",
>>>> true);
>>>>
>>>> (IServiceInterface) client.**whateverMethodThatSendsDelete(**);
>>>>
>>>> But it didn't work.
>>>>
>>>> What am I missing?
>>>>
>>>> [image: i2cat]
>>>> Julio C. Barrera Juez
>>>> Office phone: +34 93 357 99 27
>>>> Distributed Applications and Networks Area (DANA)
>>>> i2CAT Foundation, Barcelona, Spain
>>>> http://dana.i2cat.net
>>>>
>>>>
>>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com> wrote:
>>>>
>>>> Hi
>>>>>
>>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>>
>>>>> Hi.
>>>>>>
>>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>>
>>>>>> I want to send a DELETE with body, which is not recommended by RESTful
>>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>>
>>>>>> The body is not sent by the client and I have read a lot of problems to
>>>>>> allow it.
>>>>>>
>>>>>> Is it possible send a body in my DELETE requests with this
>>>>>> configuration?
>>>>>>
>>>>>> Please check this thread
>>>>>>
>>>>>
>>>>> http://cxf.547215.n5.nabble.****com/JaxRS-Client-with-Deletes-****
>>>>> td5731444.html<http://cxf.**547215.n5.nabble.com/JaxRS-**
>>>>> Client-with-Deletes-td5731444.**html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>>>>
>>>>>
>>>>>
>>>>> Cheers, Sergey
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Thank you!
>>>>>
>>>>>>
>>>>>> Regards, Julio
>>>>>>
>>>>>> [image: i2cat]
>>>>>> Julio C. Barrera Juez
>>>>>> Office phone: +34 93 357 99 27
>>>>>> Distributed Applications and Networks Area (DANA)
>>>>>> i2CAT Foundation, Barcelona, Spain
>>>>>> http://dana.i2cat.net
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
Looking for logs, I've realized that the property is producing changes. I
mean the Async HTTP client is being used. However my DELETE request has no
body. My client interface is JAX-RS annotated, my Resource class is JaxB
annotated:
@Path("/server/path")
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public void deleteResource(Resource resource);
I have a create method working with de same configuration and it works:
@Path("/server/path")
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void createResource(Resource resource);
I'm using Jackson as JSON serializer, but I guess it has no relation with
this problem.
These log lines show that the DELETE request has content-lenght 0 and
the Async HTTP client is being used
[I/O dispatcher 2] DEBUG
org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory$2 -
Connection leased: [id: 2][route: {}->http://my_server][total kept alive:
0; route allocated: 1 of 1000; total allocated: 0 of 5000]
[I/O dispatcher 2] DEBUG
org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory$3 -
[exchange: 3] Connection allocated:
[id:2][route:{}->http:/my_server][state:null]
[I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][r:]: Set attribute
http.nio.exchange-handler
[I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][rw:]: Event set [w]
[I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][rw:]: Set
attribute http.nio.http-exchange-state
[I/O dispatcher 2] DEBUG
org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory$3 -
[exchange: 3] Attempt 1 to execute request
[I/O dispatcher 2] DEBUG org.apache.http.impl.nio.reactor.IOSessionImpl -
http-outgoing-2 192.168.254.86:35152<->server_ip[ACTIVE][rw:]: Set timeout
60000
[I/O dispatcher 2] DEBUG org.apache.http.client.protocol.RequestAuthCache -
Auth cache not set in the context
[I/O dispatcher 2] DEBUG
org.apache.http.client.protocol.RequestTargetAuthentication - Target auth
state: UNCHALLENGED
[I/O dispatcher 2] DEBUG
org.apache.http.client.protocol.RequestProxyAuthentication - Proxy auth
state: UNCHALLENGED
[I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> *
DELETE* /server/path HTTP/1.1
[I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
Accept: text/plain
[I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
User-Agent: Apache CXF 2.7.4
[I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
*Content-Length:
0*
[I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >> Host:
my_server
[I/O dispatcher 2] DEBUG org.apache.http.headers - http-outgoing-2 >>
Connection: Keep-Alive
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 16 October 2013 15:17, Julio Carlos Barrera Juez <
juliocarlos.barrera@i2cat.net> wrote:
> I don't know how to install CXF Async HTTP transport. I have the maven
> artifact in my project dependencies, but nothing else.
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com> wrote:
>
>> I guess you don't have CXF Async HTTP transport installed ?
>> Other than that I've no idea, if it won;t work with the Async module then
>> I guess it is possible to do
>> Sergey
>>
>> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>>
>>> I tried to use this information before, but I don't know how to solve my
>>> problem.
>>>
>>> I have something like this:
>>>
>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>> classLoader.addLoader(**IServiceInterface.class.**getClassLoader());
>>> classLoader.addLoader(**JAXRSClientFactoryBean.class.**
>>> getClassLoader());
>>>
>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>> bean.setAddress(uri);
>>> bean.setResourceClass(**IServiceInterface.class);
>>> bean.setClassLoader(**classLoader);
>>>
>>> client (IServiceInterface) bean.create();
>>>
>>> Then I can use the client object as usual. But if fails sending DELETE
>>> requests with body.
>>>
>>> I tried doing this:
>>>
>>> ProxyClassLoader classLoader = new ProxyClassLoader();
>>> classLoader.addLoader(**IServiceInterface.class.**getClassLoader());
>>> classLoader.addLoader(**JAXRSClientFactoryBean.class.**
>>> getClassLoader());
>>>
>>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>>> bean.setAddress(uri);
>>> bean.setResourceClass(**IServiceInterface.class);
>>> bean.setClassLoader(**classLoader);
>>>
>>> // allow body in DELETE requests
>>> Client client = bean.create();
>>> WebClient.getConfig(client).**getRequestContext().put("use.**
>>> async.http.conduit",
>>> true);
>>>
>>> (IServiceInterface) client.**whateverMethodThatSendsDelete(**);
>>>
>>> But it didn't work.
>>>
>>> What am I missing?
>>>
>>> [image: i2cat]
>>> Julio C. Barrera Juez
>>> Office phone: +34 93 357 99 27
>>> Distributed Applications and Networks Area (DANA)
>>> i2CAT Foundation, Barcelona, Spain
>>> http://dana.i2cat.net
>>>
>>>
>>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com> wrote:
>>>
>>> Hi
>>>>
>>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>>
>>>> Hi.
>>>>>
>>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>>
>>>>> I want to send a DELETE with body, which is not recommended by RESTful
>>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>>
>>>>> The body is not sent by the client and I have read a lot of problems to
>>>>> allow it.
>>>>>
>>>>> Is it possible send a body in my DELETE requests with this
>>>>> configuration?
>>>>>
>>>>> Please check this thread
>>>>>
>>>>
>>>> http://cxf.547215.n5.nabble.****com/JaxRS-Client-with-Deletes-****
>>>> td5731444.html<http://cxf.**547215.n5.nabble.com/JaxRS-**
>>>> Client-with-Deletes-td5731444.**html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>>> >
>>>>
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>>
>>>>
>>>> Thank you!
>>>>
>>>>>
>>>>> Regards, Julio
>>>>>
>>>>> [image: i2cat]
>>>>> Julio C. Barrera Juez
>>>>> Office phone: +34 93 357 99 27
>>>>> Distributed Applications and Networks Area (DANA)
>>>>> i2CAT Foundation, Barcelona, Spain
>>>>> http://dana.i2cat.net
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
I don't know how to install CXF Async HTTP transport. I have the maven
artifact in my project dependencies, but nothing else.
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 16 October 2013 13:14, Sergey Beryozkin <sb...@gmail.com> wrote:
> I guess you don't have CXF Async HTTP transport installed ?
> Other than that I've no idea, if it won;t work with the Async module then
> I guess it is possible to do
> Sergey
>
> On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
>
>> I tried to use this information before, but I don't know how to solve my
>> problem.
>>
>> I have something like this:
>>
>> ProxyClassLoader classLoader = new ProxyClassLoader();
>> classLoader.addLoader(**IServiceInterface.class.**getClassLoader());
>> classLoader.addLoader(**JAXRSClientFactoryBean.class.**getClassLoader());
>>
>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>> bean.setAddress(uri);
>> bean.setResourceClass(**IServiceInterface.class);
>> bean.setClassLoader(**classLoader);
>>
>> client (IServiceInterface) bean.create();
>>
>> Then I can use the client object as usual. But if fails sending DELETE
>> requests with body.
>>
>> I tried doing this:
>>
>> ProxyClassLoader classLoader = new ProxyClassLoader();
>> classLoader.addLoader(**IServiceInterface.class.**getClassLoader());
>> classLoader.addLoader(**JAXRSClientFactoryBean.class.**getClassLoader());
>>
>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>> bean.setAddress(uri);
>> bean.setResourceClass(**IServiceInterface.class);
>> bean.setClassLoader(**classLoader);
>>
>> // allow body in DELETE requests
>> Client client = bean.create();
>> WebClient.getConfig(client).**getRequestContext().put("use.**
>> async.http.conduit",
>> true);
>>
>> (IServiceInterface) client.**whateverMethodThatSendsDelete(**);
>>
>> But it didn't work.
>>
>> What am I missing?
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com> wrote:
>>
>> Hi
>>>
>>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>>
>>> Hi.
>>>>
>>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>>
>>>> I want to send a DELETE with body, which is not recommended by RESTful
>>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>>
>>>> The body is not sent by the client and I have read a lot of problems to
>>>> allow it.
>>>>
>>>> Is it possible send a body in my DELETE requests with this
>>>> configuration?
>>>>
>>>> Please check this thread
>>>>
>>>
>>> http://cxf.547215.n5.nabble.****com/JaxRS-Client-with-Deletes-****
>>> td5731444.html<http://cxf.**547215.n5.nabble.com/JaxRS-**
>>> Client-with-Deletes-td5731444.**html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>> >
>>>
>>>
>>> Cheers, Sergey
>>>
>>>
>>>
>>>
>>> Thank you!
>>>
>>>>
>>>> Regards, Julio
>>>>
>>>> [image: i2cat]
>>>> Julio C. Barrera Juez
>>>> Office phone: +34 93 357 99 27
>>>> Distributed Applications and Networks Area (DANA)
>>>> i2CAT Foundation, Barcelona, Spain
>>>> http://dana.i2cat.net
>>>>
>>>>
>>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
I guess you don't have CXF Async HTTP transport installed ?
Other than that I've no idea, if it won;t work with the Async module
then I guess it is possible to do
Sergey
On 16/10/13 11:49, Julio Carlos Barrera Juez wrote:
> I tried to use this information before, but I don't know how to solve my
> problem.
>
> I have something like this:
>
> ProxyClassLoader classLoader = new ProxyClassLoader();
> classLoader.addLoader(IServiceInterface.class.getClassLoader());
> classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
>
> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
> bean.setAddress(uri);
> bean.setResourceClass(IServiceInterface.class);
> bean.setClassLoader(classLoader);
>
> client (IServiceInterface) bean.create();
>
> Then I can use the client object as usual. But if fails sending DELETE
> requests with body.
>
> I tried doing this:
>
> ProxyClassLoader classLoader = new ProxyClassLoader();
> classLoader.addLoader(IServiceInterface.class.getClassLoader());
> classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
>
> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
> bean.setAddress(uri);
> bean.setResourceClass(IServiceInterface.class);
> bean.setClassLoader(classLoader);
>
> // allow body in DELETE requests
> Client client = bean.create();
> WebClient.getConfig(client).getRequestContext().put("use.async.http.conduit",
> true);
>
> (IServiceInterface) client.whateverMethodThatSendsDelete();
>
> But it didn't work.
>
> What am I missing?
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>
>
> On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com> wrote:
>
>> Hi
>>
>> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>>
>>> Hi.
>>>
>>> I'm creating a REST client using JAXRSClientFactoryBean and
>>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>>
>>> I want to send a DELETE with body, which is not recommended by RESTful
>>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>>
>>> The body is not sent by the client and I have read a lot of problems to
>>> allow it.
>>>
>>> Is it possible send a body in my DELETE requests with this configuration?
>>>
>>> Please check this thread
>>
>> http://cxf.547215.n5.nabble.**com/JaxRS-Client-with-Deletes-**
>> td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>>
>> Cheers, Sergey
>>
>>
>>
>>
>> Thank you!
>>>
>>> Regards, Julio
>>>
>>> [image: i2cat]
>>> Julio C. Barrera Juez
>>> Office phone: +34 93 357 99 27
>>> Distributed Applications and Networks Area (DANA)
>>> i2CAT Foundation, Barcelona, Spain
>>> http://dana.i2cat.net
>>>
>>>
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Julio Carlos Barrera Juez <ju...@i2cat.net>.
I tried to use this information before, but I don't know how to solve my
problem.
I have something like this:
ProxyClassLoader classLoader = new ProxyClassLoader();
classLoader.addLoader(IServiceInterface.class.getClassLoader());
classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(uri);
bean.setResourceClass(IServiceInterface.class);
bean.setClassLoader(classLoader);
client (IServiceInterface) bean.create();
Then I can use the client object as usual. But if fails sending DELETE
requests with body.
I tried doing this:
ProxyClassLoader classLoader = new ProxyClassLoader();
classLoader.addLoader(IServiceInterface.class.getClassLoader());
classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(uri);
bean.setResourceClass(IServiceInterface.class);
bean.setClassLoader(classLoader);
// allow body in DELETE requests
Client client = bean.create();
WebClient.getConfig(client).getRequestContext().put("use.async.http.conduit",
true);
(IServiceInterface) client.whateverMethodThatSendsDelete();
But it didn't work.
What am I missing?
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net
On 16 October 2013 12:00, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
>
>> Hi.
>>
>> I'm creating a REST client using JAXRSClientFactoryBean and
>> ProxyClassLoader based on a JAXRS annotated Java interface.
>>
>> I want to send a DELETE with body, which is not recommended by RESTful
>> philosophy, but it is allowed by HTTP 1.1 RFC.
>>
>> The body is not sent by the client and I have read a lot of problems to
>> allow it.
>>
>> Is it possible send a body in my DELETE requests with this configuration?
>>
>> Please check this thread
>
> http://cxf.547215.n5.nabble.**com/JaxRS-Client-with-Deletes-**
> td5731444.html<http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html>
>
> Cheers, Sergey
>
>
>
>
> Thank you!
>>
>> Regards, Julio
>>
>> [image: i2cat]
>> Julio C. Barrera Juez
>> Office phone: +34 93 357 99 27
>> Distributed Applications and Networks Area (DANA)
>> i2CAT Foundation, Barcelona, Spain
>> http://dana.i2cat.net
>>
>>
>
Re: Sending body in DELETE HTTP Requests with JAXRSClientFactoryBean
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 16/10/13 09:18, Julio Carlos Barrera Juez wrote:
> Hi.
>
> I'm creating a REST client using JAXRSClientFactoryBean and
> ProxyClassLoader based on a JAXRS annotated Java interface.
>
> I want to send a DELETE with body, which is not recommended by RESTful
> philosophy, but it is allowed by HTTP 1.1 RFC.
>
> The body is not sent by the client and I have read a lot of problems to
> allow it.
>
> Is it possible send a body in my DELETE requests with this configuration?
>
Please check this thread
http://cxf.547215.n5.nabble.com/JaxRS-Client-with-Deletes-td5731444.html
Cheers, Sergey
> Thank you!
>
> Regards, Julio
>
> [image: i2cat]
> Julio C. Barrera Juez
> Office phone: +34 93 357 99 27
> Distributed Applications and Networks Area (DANA)
> i2CAT Foundation, Barcelona, Spain
> http://dana.i2cat.net
>