最近Java后台使用HttpURLConnection 调用webservice接口时,返回500错误,代码如下(URL/SOAPAction等使用的假数据)
public void callInterface() throws IOException{
try {
//第一步:创建服务地址
URL url = new URL("http://XXXX/Portal/WebServices/XXX.asmx?wsdl");
//第二步:打开一个通向服务地址的连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//第三步:设置参数
//3.1发送方式设置:POST必须大写
connection.setRequestMethod("POST");
//3.2设置数据格式:content-type
connection.setRequestProperty("content-type", "text/xml;charset=UTF-8");
connection.setRequestProperty("SOAPAction", "actionName");
//3.3设置输入输出,因为默认新创建的connection没有读写权限,
connection.setDoInput(tru