doNet的webService

浏览器访问测试地址:http://192.168.4.17/JLWWS/sendCommand.asmx,出现

点击getDeviceValue方法,出现

上图的xml代码再贴一遍:
POST /JLWWS/sendCommand.asmx HTTP/1.1
Host: 192.168.4.17
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/getDeviceValue" <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getDeviceValue xmlns="http://tempuri.org/">
<n>int</n>
<s>string</s>
</getDeviceValue>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getDeviceValueResponse xmlns="http://tempuri.org/">
<getDeviceValueResult>string</getDeviceValueResult>
</getDeviceValueResponse>
</soap:Body>
</soap:Envelope>
然后

java方法:
public String cc(){
String result = "";
try{
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName("http://tempuri.org/", "getDeviceValue"));
call.addParameter(new QName("http://tempuri.org/", "n"), org.apache.axis.encoding.XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/", "s"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setTargetEndpointAddress(new URL("http://192.168.4.17/JLWWS/sendCommand.asmx"));
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/getDeviceValue"); //SOAPService soap = new SOAPService();
//soap.setName("sendCommand1");
//call.setSOAPService(soap);
result = (String) call.invoke(new Object[] { "1", "aaaaaaaaa"});
System.out.println(result);
}catch(Exception e){
e.printStackTrace();
} return result;
}

注意上述代码的红色部分。第一、命名空间注意不要写错了;第二、参数如果是int类型的话,设置值的时候用String的方式入参,(addParameter的时候还是要org.apache.axis.encoding.XMLType.XSD_INT)。

参考csdn论坛上有个帖子是这么说的:

错误信息如下:
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
 faultSubcode: 
 faultString: 服务器无法读取请求。 ---&gt; XML 文档(1, 582)中有错误。 ---&gt; 输入字符串的格式不正确。

==================

虽然xml中是
<soap:Body>
    <PubClientLogin xmlns="http://NewCap.com/NewCapecWebService/">
      <appid>int</appid>
    </PubClientLogin>
 </soap:Body>
但是传入参数要输入string类型,
call.addParameter(new QName(targetNameSpace, "appid"), XMLType.XSD_INT, ParameterMode.IN);
call.invoke(new Object[]{""})

帖子地址:http://bbs.csdn.net/topics/360243982

最新文章

  1. 在Ubuntu下安装ISE并给Atlys板子编程
  2. 洛谷P1168 中位数
  3. DX使用texconv工具批处理dds格式图片
  4. IOS开发之——自定义导航控制器
  5. js部分---数组及练习题;
  6. 程序员书单_HeadFirst系列
  7. linux下如何导入导出MySQL数据库
  8. linux解压cpio.gz类型文件
  9. Real-Rime Rendering (2) - 变换和矩阵(Translation and Matrics)
  10. iscroll4实现轮播图效果
  11. ueditor的工具按钮配置
  12. [Struts2] &lt;s:property&gt;标签
  13. 【30集iCore3_ADP出厂源代码(ARM部分)讲解视频】30-13 emWin底层驱动接口介绍
  14. Python的rand vs randn以及linspace
  15. java中身份证号和的银行卡的深度校验
  16. Teleport Ultra 抓包工具
  17. web开发学习之旅
  18. 20155305 2016-2017-2 《Java程序设计》实验四 Android程序开发基础
  19. Node Server零基础——开发环境文件自动重载
  20. C# 判断是否是节假日

热门文章

  1. 已知m和n是两个整数,并且m^2+mn+n^2能被9整除,试证m,n都能被3整除。
  2. Cocos2d-x源代码解析(1)——地图模块(1)
  3. hdu 1035 Robot Motion(dfs)
  4. 使用Visual Studio 2017编译opencv 3.2版本
  5. 初次使用IntelliJ IDEA
  6. 搭建ssm+maven环境遇到的问题
  7. UESTC-1307-windy数
  8. 几种通讯协议的比较RMI &gt; Httpinvoker &gt;= Hessian &gt;&gt; Burlap &gt;&gt; web service (转)
  9. 深入RecyclerView-为什么要使用ItemDecoration
  10. 发布WebService 1.1