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. HTML-<a>标签添加下划线

    <a href="ddrb/090630.asp" target="_blank" style="text-decoration:underli ...

  2. 【转】word排版宏的使用

    原文: https://blog.csdn.net/bruce_shan/article/details/73302756 -------------------------------------- ...

  3. System.Drawing.Color的颜色对照表

    经常使用System.Drawing.Color, 本篇介绍一下颜色与名称及RGB值的对应关系. 1. 颜色与名称的对照表(点击下图放大看): 2. 颜色与RGB值对照表: Color.AliceBl ...

  4. (C++)已知String类的定义,实现其函数体

    CString类的定义如下: class CMyString{ public: CMyString(const char* pData=NULL); CMyString(const CMyString ...

  5. Xcode 生成 ipa包

    原地址:http://zengwu3915.blog.163.com/blog/static/2783489720136213239916/ app store的审核收费的需要二周,免费的需要一个月左 ...

  6. 查看正在执行的sql语句

    ;WITH t AS( SELECT [Spid] = session_Id, ecid, [Database] = DB_NAME(sp.dbid), [User] = nt_username, [ ...

  7. mini2440裸机试炼之——看门狗中断和复位操作

    看门狗的工作原理: 设本系统程序完整执行一周期的时间是Tp,看门狗的定时周期为Ti,Ti>Tp,在程序正常执行时,定时器就不会溢出,若因为干扰等原因使系统不能在Tp时刻改动定时器的记数值,定时器 ...

  8. Android实现开机自动运行程序

    有些时候,应用需要在开机时就自动运行,例如某个自动从网上更新内容的后台service.怎样实现开机自动运行的应用?在撰写本文时,联想到高焕堂先生以“Don't call me, I'll call y ...

  9. C#:转换类型(待补充)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyCo ...

  10. Spark SQL and DataFrame Guide(1.4.1)——之DataFrames

    Spark SQL是处理结构化数据的Spark模块.它提供了DataFrames这样的编程抽象.同一时候也能够作为分布式SQL查询引擎使用. DataFrames DataFrame是一个带有列名的分 ...