默认代理Java
我试图使用JAVA调用WebServicesAPI,但我有连接问题,可能是由于代理 我已经用C#WPF应用程序完成了,为了避免连接问题,我在App.config文件中设置了以下选项默认代理Java,java,c#,web-services,proxy,Java,C#,Web Services,Proxy,我试图使用JAVA调用WebServicesAPI,但我有连接问题,可能是由于代理 我已经用C#WPF应用程序完成了,为了避免连接问题,我在App.config文件中设置了以下选项 <system.net> <defaultProxy useDefaultCredentials="true"></defaultProxy> 非常感谢你的帮助也许这可以帮助你:非常有用谢谢 /** * Executes the request and returns i
<system.net>
<defaultProxy useDefaultCredentials="true"></defaultProxy>
非常感谢你的帮助也许这可以帮助你:非常有用谢谢
/**
* Executes the request and returns its response.
*
* @return the request's response
* @throws IOException if the underlying {@link HttpsURLConnection} could
* not be set up or executed
*/
public String execute() throws IOException {
HttpsURLConnection connection = null;
try {
connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
// write POST data to request
// Exception is raised at this level
if (postData != null && !postData.toString().isEmpty()) {
connection.setDoOutput(true);
try (OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()))
{
out.write(postData.toString());
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
// execute request and read response
try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
response.append(line);
}
return response.toString();
}
}
finally {
connection.disconnect();
}
}