You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Vjacheslav V. Borisov" <sl...@gmail.com> on 2016/10/05 09:02:08 UTC
How to use PATCH method in CXF
Hi!
There is "How to use PATCH method in CXF" thread
http://stackoverflow.com/questions/32067687/how-to-use-patch-method-in-cxf
Where author is using
use.async.http.conduit to allow proxy client generated to work.
To do this he recommends to write interceptor:
if ( message.get(Message.HTTP_REQUEST_METHOD).equals("PATCH") {
message.put("use.async.http.conduit", true);}
Does this is preferred workaround to make PATCH method work in client?
Re: How to use PATCH method in CXF
Posted by Sergey Beryozkin <sb...@gmail.com>.
Sorry, just checked the code.
So, if one does add an async transport dependency then this property
will not have to be set explicitly.
If you use Java HTTP transport: it has never been improved to support
extension verbs so Dan had to do some reflective hacks around HTTP url
connection which would be a bit expensive for usual POST, etc, calls.
So to support PATCH or any other custom verb with HTTPUrlConnection one
has to set a different property, "use.httpurlconnection.method.reflection"
https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java#L110
either the way it is shown in the test, or as suggested below using the
interceptor
Sergey
On 05/10/16 12:16, Vjacheslav V. Borisov wrote:
> Checked in 3.1.8-SNAPSHOT, getting Caused by: java.net.ProtocolException:
> Invalid HTTP method: PATCH
>
> WARN o.a.cxf.phase.PhaseInterceptorChain - Interceptor for {
> http://api.geoservices.ilb.ru/}FeaturesResource has thrown exception,
> unwinding now
> org.apache.cxf.interceptor.Fault: Could not send Message.
> at
> org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:48)
> ~[cxf-core-3.1.8-20160929.065015-38.jar:3.1.8.SNAPSHOT]
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
> [cxf-core-3.1.8-20160929.065015-38.jar:3.1.8.SNAPSHOT]
> at
> org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:666)
> [cxf-rt-rs-client-3.1.8-20160929.070108-32.jar:3.1.8.SNAPSHOT]
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:744)
> [cxf-rt-rs-client-3.1.8-20160929.070108-32.jar:3.1.8.SNAPSHOT]
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:231)
> [cxf-rt-rs-client-3.1.8-20160929.070108-32.jar:3.1.8.SNAPSHOT]
> at com.sun.proxy.$Proxy236.createBatch(Unknown Source) [na:na]
>
> 2016-10-05 13:23 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:
>
>> Hi
>>
>> No, setting this property is not really needed any longer.
>> With the latest CXFs it should just work with or without the async conduit
>> being loaded, Dan did some HTTPURLConnection reflective work.
>>
>> Cheers, Sergey
>>
>>
>> On 05/10/16 10:02, Vjacheslav V. Borisov wrote:
>>
>>> Hi!
>>>
>>> There is "How to use PATCH method in CXF" thread
>>> http://stackoverflow.com/questions/32067687/how-to-use-patch
>>> -method-in-cxf
>>>
>>> Where author is using
>>>
>>> use.async.http.conduit to allow proxy client generated to work.
>>>
>>> To do this he recommends to write interceptor:
>>>
>>>
>>> if ( message.get(Message.HTTP_REQUEST_METHOD).equals("PATCH") {
>>> message.put("use.async.http.conduit", true);}
>>>
>>>
>>> Does this is preferred workaround to make PATCH method work in client?
>>>
>>>
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Re: How to use PATCH method in CXF
Posted by "Vjacheslav V. Borisov" <sl...@gmail.com>.
Checked in 3.1.8-SNAPSHOT, getting Caused by: java.net.ProtocolException:
Invalid HTTP method: PATCH
WARN o.a.cxf.phase.PhaseInterceptorChain - Interceptor for {
http://api.geoservices.ilb.ru/}FeaturesResource has thrown exception,
unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at
org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:48)
~[cxf-core-3.1.8-20160929.065015-38.jar:3.1.8.SNAPSHOT]
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
[cxf-core-3.1.8-20160929.065015-38.jar:3.1.8.SNAPSHOT]
at
org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:666)
[cxf-rt-rs-client-3.1.8-20160929.070108-32.jar:3.1.8.SNAPSHOT]
at
org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:744)
[cxf-rt-rs-client-3.1.8-20160929.070108-32.jar:3.1.8.SNAPSHOT]
at
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:231)
[cxf-rt-rs-client-3.1.8-20160929.070108-32.jar:3.1.8.SNAPSHOT]
at com.sun.proxy.$Proxy236.createBatch(Unknown Source) [na:na]
2016-10-05 13:23 GMT+04:00 Sergey Beryozkin <sb...@gmail.com>:
> Hi
>
> No, setting this property is not really needed any longer.
> With the latest CXFs it should just work with or without the async conduit
> being loaded, Dan did some HTTPURLConnection reflective work.
>
> Cheers, Sergey
>
>
> On 05/10/16 10:02, Vjacheslav V. Borisov wrote:
>
>> Hi!
>>
>> There is "How to use PATCH method in CXF" thread
>> http://stackoverflow.com/questions/32067687/how-to-use-patch
>> -method-in-cxf
>>
>> Where author is using
>>
>> use.async.http.conduit to allow proxy client generated to work.
>>
>> To do this he recommends to write interceptor:
>>
>>
>> if ( message.get(Message.HTTP_REQUEST_METHOD).equals("PATCH") {
>> message.put("use.async.http.conduit", true);}
>>
>>
>> Does this is preferred workaround to make PATCH method work in client?
>>
>>
>
Re: How to use PATCH method in CXF
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
No, setting this property is not really needed any longer.
With the latest CXFs it should just work with or without the async
conduit being loaded, Dan did some HTTPURLConnection reflective work.
Cheers, Sergey
On 05/10/16 10:02, Vjacheslav V. Borisov wrote:
> Hi!
>
> There is "How to use PATCH method in CXF" thread
> http://stackoverflow.com/questions/32067687/how-to-use-patch-method-in-cxf
>
> Where author is using
>
> use.async.http.conduit to allow proxy client generated to work.
>
> To do this he recommends to write interceptor:
>
>
> if ( message.get(Message.HTTP_REQUEST_METHOD).equals("PATCH") {
> message.put("use.async.http.conduit", true);}
>
>
> Does this is preferred workaround to make PATCH method work in client?
>
Re: How to use PATCH method in CXF
Posted by Jose MarĂa Zaragoza <de...@gmail.com>.
2016-10-05 11:02 GMT+02:00 Vjacheslav V. Borisov <sl...@gmail.com>:
> Hi!
>
> There is "How to use PATCH method in CXF" thread
> http://stackoverflow.com/questions/32067687/how-to-use-patch-method-in-cxf
>
> Where author is using
>
> use.async.http.conduit to allow proxy client generated to work.
>
> To do this he recommends to write interceptor:
>
>
> if ( message.get(Message.HTTP_REQUEST_METHOD).equals("PATCH") {
> message.put("use.async.http.conduit", true);}
>
>
> Does this is preferred workaround to make PATCH method work in client?
Well , I don't know if it's the best way, but itis what I use:
1) add cxf-rt-transports-http-hc libreries to classpath
2) call
client.path("/app/{phone}", phone).invoke("PATCH", phoneType);
where client is a WebClient instance
(It's a synchronous call)
You can have a look to
http://cxf.apache.org/docs/asynchronous-client-http-transport.html
Regards