很纠结的问题:org.apache.axis2.AxisFault: 服务器未能识别 HTTP 头 SOAPAction 的值
2016-07-12 16:56
507 查看
很纠结的问题:org.apache.axis2.AxisFault: 服务器未能识别 HTTP 头 SOAPAction 的值
纠结了半天,网上找了很多办法。。。
试来试去都不行。。。用了soapui里取到的报文来用不行。。。。
老是报错:::org.apache.axis2.AxisFault: 服务器未能识别 HTTP 头 SOAPAction 的值
怀疑是代码写错的原因。。。决定不用框架里的代码。。。
单独写。。。
在网上找了几段来试一下。
终于发现有一段可以了:
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.net.URL;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
String myCall(String operationCode, HashMap param){
String theRegionCode = "31124";
try{
String endpoint = "http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://WebXml.com.cn/",
"getStockInfoByCode"));
call.addParameter(new QName
(");
//call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA);
call.setUseSOAPAction(true);
call.setReturnClass(String[].class);
call.setSOAPActionURI("http://WebXml.com.cn/getStockInfoByCode");
String[] result = (String[])call.invoke(new Object[]{"sh600477"});
System.out.print("");
}catch(Exception w){}
return "";
}
http://blog.csdn.net/aixiaorenzhe123/article/details/4292465
=====================
和原先老是报错的对比一下:
String theIpAddress = (String)param.get("ip");
try {
//调用webservice的地址
String endPoint = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(endPoint));
//调用webservice方法,必须这样调用该方法,是根据soap协议里的方法声明
call.setOperationName(new QName("http://webxml.com.cn/getCountryCityByIp"));
//webservice里method的参数,必须这样定义,否则必然出错
call.addParameter(new QName("http://WebXml.com.cn/", "theIpAddress"),XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://WebXml.com.cn/getCountryCityByIp");
String result = (String) call.invoke(new Object[] { theIpAddress});
// String[] infos = result.split(":", 2);
// if (infos.length == 2) {
// mobileInfos = infos[1].split(" ", 3);
// }
} catch (Exception e) {
e.printStackTrace();
}
return "";
==============
尝试着参照正确的修改一下后居然行了,哈哈哈哈:
String myCall(String operationCode, HashMap param){
String theIpAddress = (String)param.get("ip");
try {
//调用webservice的地址
String endPoint = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(endPoint));
//调用webservice方法,必须这样调用该方法,是根据soap协议里的方法声明
call.setOperationName(new QName(""));
//webservice里method的参数,必须这样定义,否则必然出错
call.addParameter(new QName(");
call.setUseSOAPAction(true);
call.setReturnClass(String[].class);
call.setSOAPActionURI("http://WebXml.com.cn/getCountryCityByIp");
String[] results = (String[])call.invoke(new Object[]{theIpAddress});
System.out.print("");
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
============太有才了==========
收藏于 2012-05-07
纠结了半天,网上找了很多办法。。。
试来试去都不行。。。用了soapui里取到的报文来用不行。。。。
老是报错:::org.apache.axis2.AxisFault: 服务器未能识别 HTTP 头 SOAPAction 的值
怀疑是代码写错的原因。。。决定不用框架里的代码。。。
单独写。。。
在网上找了几段来试一下。
终于发现有一段可以了:
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.net.URL;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
String myCall(String operationCode, HashMap param){
String theRegionCode = "31124";
try{
String endpoint = "http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://WebXml.com.cn/",
"getStockInfoByCode"));
call.addParameter(new QName
(");
//call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA);
call.setUseSOAPAction(true);
call.setReturnClass(String[].class);
call.setSOAPActionURI("http://WebXml.com.cn/getStockInfoByCode");
String[] result = (String[])call.invoke(new Object[]{"sh600477"});
System.out.print("");
}catch(Exception w){}
return "";
}
http://blog.csdn.net/aixiaorenzhe123/article/details/4292465
=====================
和原先老是报错的对比一下:
String theIpAddress = (String)param.get("ip");
try {
//调用webservice的地址
String endPoint = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(endPoint));
//调用webservice方法,必须这样调用该方法,是根据soap协议里的方法声明
call.setOperationName(new QName("http://webxml.com.cn/getCountryCityByIp"));
//webservice里method的参数,必须这样定义,否则必然出错
call.addParameter(new QName("http://WebXml.com.cn/", "theIpAddress"),XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://WebXml.com.cn/getCountryCityByIp");
String result = (String) call.invoke(new Object[] { theIpAddress});
// String[] infos = result.split(":", 2);
// if (infos.length == 2) {
// mobileInfos = infos[1].split(" ", 3);
// }
} catch (Exception e) {
e.printStackTrace();
}
return "";
==============
尝试着参照正确的修改一下后居然行了,哈哈哈哈:
String myCall(String operationCode, HashMap param){
String theIpAddress = (String)param.get("ip");
try {
//调用webservice的地址
String endPoint = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(endPoint));
//调用webservice方法,必须这样调用该方法,是根据soap协议里的方法声明
call.setOperationName(new QName(""));
//webservice里method的参数,必须这样定义,否则必然出错
call.addParameter(new QName(");
call.setUseSOAPAction(true);
call.setReturnClass(String[].class);
call.setSOAPActionURI("http://WebXml.com.cn/getCountryCityByIp");
String[] results = (String[])call.invoke(new Object[]{theIpAddress});
System.out.print("");
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
============太有才了==========
收藏于 2012-05-07
相关文章推荐
- C#学习 【HttpClient学习】
- sip/sdp/rtp/rtcp/rtsp间的关系
- 网络爬虫(二):利用urllib2通过指定的URL抓取网页内容
- https
- 微信测试工程师手把手教你做弱网络模拟测试
- 升级okhttp3.0+和retrofit2.0+的过程以及遇到的坑
- 安天每日安全简讯20160712
- Java 网络编程实例
- 网络基石 —— 电话线
- 【华为WLAN】WLAN网络,AC旁挂直接转发基本配置。
- 网络基石 —— ADSL
- 笔记----httpd得basic认证基于组
- iOS中4种判断网络请求的方式(系统状态栏、AFNetworking、Reachability、自定义)
- 2使用XMLHttpRequest对象
- TCP和UDP?
- linux关闭tcp连接工具--killcx
- HTTP和HTTPS的区别?
- Java网络编程之(二): TCP的多线程连接
- 笔记----httpd得basic认证基于用户
- 内置Jetty HTTPS启动