我正在尝试连接https网站但我收到响应代码= 500,当我发送我的请求XML时,为什么我在尝试从Web服务获取响应时收到此错误。我是示例代码请帮我解决这个问题。
public static HttpsURLConnection gethttpsConnection(String wsdl,
String soapAction, StringBuffer buf) {
try {
URL url = new URL(wsdl);
HttpsURLConnection connjava = (HttpsURLConnection) url
.openConnection();
connjava.setRequestMethod("GET");
connjava.setRequestProperty("Content-length",
"" + Integer.toString(buf.toString().getBytes().length));
connjava.setRequestProperty("Content-Type",
"text/xml; charset=utf-8");
connjava.setRequestProperty("User-Agent", "text/xml; charset=utf-8");
connjava.addRequestProperty("SOAPAction", soapAction);
connjava.setDoOutput(true);
connjava.setDoInput(true);
connjava.setAllowUserInteraction(true);
java.io.DataOutputStream printout = new java.io.DataOutputStream(
connjava.getOutputStream());
printout.writeBytes(buf.toString());
if (connjava != null) {
Logs.logger.info("Response Code : "
+ connjava.getResponseCode());
X509Certificate[] certs = (X509Certificate[]) connjava
.getServerCertificates();
for (X509Certificate cert : certs) {
Logs.logger.info("Cert Hash Code : " + cert.hashCode());
Logs.logger.info("Cert Public Key Algorithm : "
+ cert.getPublicKey().getAlgorithm());
Logs.logger.info("Cert Public Key Format : "
+ cert.getPublicKey().getFormat());
}
printout.flush();
printout.close();
return connjava;
}
答案 0 :(得分:0)
我没有使用Java
进行网络开发的经验,但是,我曾在Php
工作过,我遇到server Error - 500
同样的问题。这是因为会话值不匹配。我有两个网站共享相同的session
变量名称。这会导致活动sessions
不匹配,并且我收到此错误。检查一下,我猜你可能会犯同样的错误。