[英]Https connection for web service
i am trying to connect with https site but i am getting response code=500 when i send my request XML don't why i am getting this error when i am trying to get response from web service.below is my sample code.Please help me out from this problem. 我正在尝试连接https站点,但是在发送请求XML时得到响应代码= 500,这不是为什么我试图从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;
}
I don't have much experience of web-development with Java
, but yes, I have worked over Php
, there I had the same problem of server Error - 500
. 我没有使用
Java
进行网络开发的丰富经验,但是是的,我在Php
工作过,在那里我遇到了相同的server Error - 500
。 It was because of the session value mismatch. 这是因为会话值不匹配。 I had two websites sharing the same
session
variable names. 我有两个共享相同
session
变量名称的网站。 This lead to mismatch in active sessions
, And I got this error. 这导致活动
sessions
不匹配,而我得到了这个错误。 Check with that, I guess you might be making the same mistake. 检查一下,我想您可能会犯同样的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.