Skip to Content
0
Former Member
May 13, 2010 at 07:00 AM

Calling web service through proxy ...

207 Views

Hello all,

I have following problem. I've developed a portal application that try to connect to a web service. It's necessary to use proxy for connecting to WS so I used this code:

...

Properties systemProperties = System.getProperties();

systemProperties.setProperty("https.proxySet", "true");

systemProperties.setProperty("https.proxyHost","xxx.xxx.xxx.xxx");

systemProperties.setProperty("https.proxyPort","3128");

URL url = new URL(addr);

HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();

connection.setDoOutput(true);

connection.setDoInput(true);

BASE64Encoder base64enc = new BASE64Encoder();

String auth = base64enc.encodeBuffer((user + ":" + passwd).getBytes("UTF-8")).trim();

connection.setRequestProperty("Authorization","Basic " + auth);

OutputStream out = connection.getOutputStream();

Writer wout = new OutputStreamWriter(out);

wout.write(" http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v20=\" http://isds.czechpoint.cz/v20\">");

...

wout.write("</soapenv:Envelope>");

wout.flush();

wout.close();

InputStream in = connection.getInputStream();

Reader reader = new InputStreamReader(in);

...

But the command InputStream in = connection.getInputStream(); thows exeption "Connect timed out".

It seems that proxy is not used and application try to connect directlly to WS. Do you have any idea where could be problem?

Thanks in advance for every advice!

Bertuccio