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

Java调用doNet webService方法的更多相关文章

  1. Java调用.NET webservice方法的几种方式

    最近做项目,涉及到web-service调用,现学了一个星期,现简单的做一个小结.下面实现的是对传喜物流系统(http://vip.cxcod.com/PodApi/GetPodStr.asmx?ws ...

  2. Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法 转

    Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法   同事遇到一个很囧的问题,java调,netwebservice的时候,调用无参数方法成功,调用有参 ...

  3. java调用C# webService发布的接口

    java调用C# webService发布的接口 java调用C# webService方式有很多种我这里只介绍一种 首先需要引入axis的jar包 axis的maven坐标如下 <depend ...

  4. 调用具体webservice方法时时报错误:请求因 HTTP 状态 503 失败: Service Temporarily Unavailable

    添加web引用会在相应项目的app.cofig文件中产生如下代码: <sectionGroup name="applicationSettings" type="S ...

  5. android ksoap2调用.net Webservice 方法总结

    android  ksoap2调用.net Webservice 方法直接放到一个类里: package com.util; import org.ksoap2.SoapEnvelope; impor ...

  6. Android-WebView与本地HTML (Java调用--->HTML的方法)-(new WebView(this)方式)

    之前的博客,Android-WebView与本地HTML (Java调用--->HTML的方法),是在 findViewById(R.id.webview);,来得到WebView, 此博客使用 ...

  7. Android-WebView与本地HTML (Java调用--->HTML的方法)

    上一篇博客 Android-WebView与本地HTML (HTML调用-->Java的方法) 介绍了 JavaScript 调用--> Java中的方法,而此篇博客是介绍 Java 调用 ...

  8. Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法

    同事遇到一个很囧的问题,java调,netwebservice的时候,调用无参数方法成功,调用有参数的方法每次我这边的webservice日志都记录参数为空,而我自己.Net程序调用完全没有问题,后面 ...

  9. JAVA调用.NET WebService终极方案(包含对SoapHeader的处理)

    一.前言:      今日部门的产品需要用到短信功能,需要走公司统一的接口,而该短信接口是由.net开发的,利用两天时间彻底搞定了用java来调用.net 的web service,包括对soap h ...

随机推荐

  1. android AIDL 入门讲解非常好的文章(网页代码着色给力)

    转自: http://tech.cnnetsec.com/585.html

  2. C#应用视频教程1.4 实现完整以太网通讯

    对于事件和委托机制不够理解的读者可以参考本节提供的委托相关的范例程序,这个是控制台的程序,比较简洁(书店发布一本书的事件注册到某个读者A身上,原理跟前面一小节讲的是一致的,只不过没有通过委托对外发送数 ...

  3. Oracle 之 常用函数

    SQL语句根据参数的不同,分为单行函数 和 多行函数. [1] 单行函数:输入是一行,输出也是一行: [2] 多行函数:输入多行数据,输出一个结果. 在执行时,单行函数是检索一行处理一次,而多行函数是 ...

  4. ZOJ 3630 Information 强连通

    题意:n m表示n个节点,m条边,下面m行a b 表示a-b点有一条有向边 题目:给定有向图,删去一个点后,可以求出该图中强连通分量中最大的点数 问:删去某点后,最大点数 最小是多少 思路:枚举删点, ...

  5. python发送QQ邮箱方法

    import smtplib from email.mime.text import MIMEText mail_user = "user1@qq.com" mail_pwd = ...

  6. [Exception JavaWeb 1] - Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P2' 附近有语法错误。

    严重: Servlet.service() for servlet [springMVC] in context with path [/ExceptionManageSystem] threw ex ...

  7. UIScrollView 循环滚动,代码超简单

    如今非常多应用里面多多少少都用到了循环滚动,要么是图片.要么是view,或者是其它,我总结一下,写了个demo分享给大家. 先看代码之后在讲原理: 1.创建一个空的项目(这个我就不多说了). 2.加入 ...

  8. js 动态创建变量

      js 动态创建变量 CreationTime--2018年7月2日15点04分 Author:Marydon 1.实现方式 通过eval()实现 2.代码实现 /** * 声明一个函数 * @ex ...

  9. Appium环境的安装与配置,Python测试脚本测试

    Appium自动化测试系列1 - Appium环境的安装与配置 发表于4个月前(2015-01-27 14:34)   阅读(803) | 评论(0) 0人收藏此文章, 我要收藏 赞0 寻找 会’偷懒 ...

  10. android的NDK和java进行本地socket通信

    关于Android应用与Framework的socket通信,相信关心这个问题的朋友们已经看过<android使用socket使底层和framework通信>这篇文章,美中不足的是作者只贴 ...