Hi
Sorry I remember now where the problem is.
CXF WebTargetImpl initializes an internal WebClient only at the moment
Invocation.Builder is created:
String address = "http://localhost:" + PORT +
"/bookstore/bookheaders/simple";
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(address);
// Internal WebClient is not ready yet for WebClient.getConfig(webTarget);
Invocation.Builder builder =
webTarget.request("application/xml").header("a", "b");
//OK
WebClient.getConfig(builder);
//OK
WebClient.getConfig(webTarget);
The reason is that a web target can be initialized with an address like
WebTarget webTarget = client.target("http://host/{a}/{b}";
so initializing the internal WebClient until these variables have been
resolved will fail.
So the best option is to start from WebClient.getConfig(builder), though
it does seem using a feature is much cleaner
Cheers, Sergey
On 28/09/16 15:55, venkatesham nalla wrote:
Hi Sergey,
I used both CXF 3.0.4 and 3.1.6. Both these versions has same result.
[java] Client Class ==> org.apache.cxf.jaxrs.client.spec.ClientImpl
[java] WebTarget class = org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTar
getImpl
[java] Exception in thread "main" java.lang.IllegalArgumentException: Not a
valid Client
[java] at org.apache.cxf.jaxrs.client.WebClient.getConfig(WebClient.jav
a:319)
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
// CXF Specific for Logging
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.apache.cxf.transport.http.HTTPConduit;
public class Test {
public static void main(String [] args) throws Exception {
URL base = new URL("http://localhost:58080/jaxrs-fileupload/");
// Turn on logging on
Bus bus = BusFactory.getDefaultBus();
bus.getInInterceptors().add(new LoggingInInterceptor());
bus.getOutInterceptors().add(new LoggingOutInterceptor());
BusFactory.setDefaultBus(bus);
Client client = ClientBuilder.newClient();
System.out.println("Client Class ==> " + client.getClass().getName());
WebTarget target = client.target(URI.create(new URL(base,
"restservices/files").toExternalForm()));
System.out.println("WebTarget class = " + target.getClass().getName());
HTTPConduit http =
org.apache.cxf.jaxrs.client.WebClient.getConfig(target).getHttpConduit();
}
}
________________________________
From: Sergey Beryozkin <sberyoz...@gmail.com>
Sent: Tuesday, September 27, 2016 8:34:16 PM
To: users@cxf.apache.org
Subject: Re: How to enable/disable transfer-encoding: chunked in jax-rs?
Hi
Can you double check that Client instance is actually created by CXF ?
I.e, that no other JAX-RS impl libraries are loaded.
If it is CXF - which CXF version it is ?
Sergey
On 27/09/16 20:55, venkatesham nalla wrote:
Hi,
The following code is throwing exception - MyResourceTest.setUp:83
IllegalArgument Not a valid Client
Client client = ClientBuilder.newClient();
WebTarget target = client.target(URI.create(new URL(base,
"restservices/files").toExternalForm()));
HTTPConduit http =
org.apache.cxf.jaxrs.client.WebClient.getConfig(target).getHttpConduit();
Thanks,
Venkat
________________________________
From: Sergey Beryozkin <sberyoz...@gmail.com>
Sent: Tuesday, September 27, 2016 3:24 PM
To: users@cxf.apache.org
Subject: Re: How to enable/disable transfer-encoding: chunked in jax-rs?
Hi
You can pass WebTarget or InvocationBuilder (they wrap WebClient) to
WebClient.getConfig.
FYI, a different approach was also described:
http://cxf.547215.n5.nabble.com/HttpConduit-for-WebTarget-td5773080.html#a5773086,
Cheers, Sergey
On 27/09/16 15:45, venkatesham nalla wrote:
Hi,
How to convert the Client object created using ClientBuilder.newClient() to
WebClient or org.apache.cxf.jaxrs.client.Client?
thanks,
Venkat
________________________________
From: Sergey Beryozkin <sberyoz...@gmail.com>
Sent: Monday, September 26, 2016 9:20 PM
To: users@cxf.apache.org
Subject: Re: How to enable/disable transfer-encoding: chunked in jax-rs?
Hi
For the client you can do WebClient.getConfig(client),getHttpConduit and
configure it as needed, while on the server you'd likely need to
configure the underlying container
Sergey
On 26/09/16 15:58, venkatesham nalla wrote:
Hi,
How to enable/disable transfer-encoding: chunked in JAX-RS server and client
without using spring xml configuration ?
thanks,
Venkat
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Latest Activity | Talend Community Coders<http://coders.talend.com/>
coders.talend.com
Talend Community Coders. At Talend, we contribute to open source projects
because they challenge us with new ideas and keep us sharp. We also do it
because it's the ...
Latest Activity | Talend Community Coders<http://coders.talend.com/>
Latest Activity | Talend Community Coders<http://coders.talend.com/>
coders.talend.com
Talend Community Coders. At Talend, we contribute to open source projects
because they challenge us with new ideas and keep us sharp. We also do it
because it's the ...
coders.talend.com
Talend Community Coders. At Talend, we contribute to open source projects
because they challenge us with new ideas and keep us sharp. We also do it
because it's the ...
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/