You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by Michael Clark <em...@yahoo.com> on 2012/07/09 18:39:11 UTC

Unable to tunnel through proxy. Proxy returns HTTP/1.1 500 - Error

Hi, 

I am using simple stand alone Java application to test the external
webservice thru proxy and getting the error 
"Caused by: javax.xml.stream.XMLStreamException: java.io.IOException: Unable
to tunnel through proxy. Proxy returns "HTTP/1.1 500 Internal Server Error" 

And this is failing when i use https url. (for http url it is not even
validating the proxy credentials). 

NEXTGENLiteSoap client; try { JaxWsProxyFactoryBean proxyFactory = new
JaxWsProxyFactoryBean();
proxyFactory.setServiceClass(NEXTGENLiteSoap.class); proxyFactory
.setAddress("https://www.nextgen.com/soap/v1.0/service.asmx?WSDL"); client =
(NEXTGENLiteSoap) proxyFactory.create(); Client endpointClient =
ClientProxy.getClient(client); HTTPConduit http = (HTTPConduit)
endpointClient.getConduit(); HTTPClientPolicy httpClientPolicy =
http.getClient(); httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setProxyServer("101.213.190.104");
httpClientPolicy.setProxyServerPort(8080);
httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
httpClientPolicy.setAutoRedirect(false);
httpClientPolicy.setConnection(ConnectionType.KEEP_ALIVE);
ProxyAuthorizationPolicy proxyAuthPolicy = new ProxyAuthorizationPolicy();
proxyAuthPolicy.setUserName("testUser");
proxyAuthPolicy.setPassword("testPass");
proxyAuthPolicy.setAuthorizationType("Basic");
http.setProxyAuthorization(proxyAuthPolicy);
http.setClient(httpClientPolicy); DataInput input = new DataInput();
input.setUsername("NEXTGEN0941"); input.setPassword("M0XLY7VH");
input.setVRM("12345678"); Object a = client.getNextGenData(input); } catch
(Exception e) { // TODO Auto-generated catch block e.printStackTrace(); 

>From Eclipse it is running fine.. even with incorrect credentials. But from
Linux it is throwing 500 error. 

Java Version : JDK 1.6_24 
CXF Version 2.6.0 

Any help on this is highly appreciated. 


To validate the Proxy credentials, I have used simple http client (v 4.03)
and i am able to pass thru https url. Find below working client program. 

 
 HttpHost proxy = new HttpHost("101.213.190.104", 8080, "http"); 

        // general setup 
        SchemeRegistry supportedSchemes = new SchemeRegistry(); 

        // Register the "http" and "https" protocol schemes, they are 
        // required by the default operator to look up socket factories. 
        supportedSchemes.register(new Scheme("http", 
                PlainSocketFactory.getSocketFactory(), 80)); 
        supportedSchemes.register(new Scheme("https", 
                SSLSocketFactory.getSocketFactory(), 443)); 

        // prepare parameters 
        HttpParams params = new BasicHttpParams(); 
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); 
        HttpProtocolParams.setContentCharset(params, "UTF-8"); 
        HttpProtocolParams.setUseExpectContinue(params, true); 

        ClientConnectionManager ccm = new
ThreadSafeClientConnManager(params, 
                supportedSchemes); 

        DefaultHttpClient httpclient = new DefaultHttpClient(ccm, params); 

        httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy); 
                httpclient.getCredentialsProvider().setCredentials( 
                                    new AuthScope("101.213.190.104", 8080), 
                    new UsernamePasswordCredentials("testUser",
"testPass")); 
        
        HttpGet req = new
HttpGet("https://www.nextgen.com/soap/v1.0/service.asmx?WSDL");

        //System.out.println("executing request to " + target + " via " +
proxy); 
        HttpResponse rsp = httpclient.execute(req); 
        HttpEntity entity = rsp.getEntity(); 

        System.out.println("----------------------------------------"); 
        System.out.println(rsp.getStatusLine()); 
        Header[] headers = rsp.getAllHeaders(); 
        for (int i = 0; i&lt;headers.length; i++) { 
            System.out.println(headers[i]); 
        } 
&lt;/nabble_embed&gt; 



Thanks, 
Michael.

--
View this message in context: http://cxf.547215.n5.nabble.com/Unable-to-tunnel-through-proxy-Proxy-returns-HTTP-1-1-500-Error-tp5710768.html
Sent from the cxf-issues mailing list archive at Nabble.com.