webService 客户端调用及异常信息First Element must contain the local name, Envelope , but found definitions
报错:“First Element must contain the local name, Envelope , but found definitions”;
原因:EndpointReference end = new EndpointReference(url) ,url错误;
源代码:
1 import org.apache.axiom.om.OMAbstractFactory;
2 import org.apache.axiom.om.OMElement;
3 import org.apache.axiom.om.OMFactory;
4 import org.apache.axiom.om.OMNamespace;
5 import org.apache.axis2.AxisFault;
6 import org.apache.axis2.addressing.EndpointReference;
7 import org.apache.axis2.client.Options;
8 import org.apache.axis2.client.ServiceClient;
9
10 public class Test {
11 public static void main(String[] args) throws AxisFault {
12 OMElement element = test("22","444","123");
13 System.out.println(element.getText());
14 }
15
16 private static OMElement test(String contractNo, String contractName, String auditMoney) throws AxisFault {
17 OMFactory factory = OMAbstractFactory.getOMFactory();
18 OMNamespace ns1 = factory.createOMNamespace("http://wwww.test.com/UpdateContractDeductMoneySrv/", "upd");
19 OMNamespace ns = factory.createOMNamespace("", "");
20 OMElement result;
21 ServiceClient sc = new ServiceClient();
22 Options opts = sc.getOptions();
23 // String url = "http://localhost:8989/test/services/UpdateContractAuditMoneySrv?wsdl"; //错误
24 String url = "http://localhost:8989/test/services/UpdateContractDeductMoneySrv"; //正确
25 EndpointReference end = new EndpointReference(url);
26 OMElement method = factory.createOMElement("UpdateMoneyCollection", ns);
27 OMElement param = factory.createOMElement("ContractNo", ns);
28 param.setText(contractNo);
29 method.addChild(param);
30 param = factory.createOMElement("ContractName", ns);
31 param.setText(contractName);
32 method.addChild(param);
33 param = factory.createOMElement("AuditMoney", ns);
34 param.setText(auditMoney);
35 method.addChild(param);
37 param = factory.createOMElement("Items", ns);
38 OMElement newOperation = factory.createOMElement("NewOperation1", ns1);
39 param.addChild(newOperation);
40 OMElement contractLineNo = factory.createOMElement("ContractLineNo", ns);
41 contractLineNo.setText("1");
42 newOperation.addChild(contractLineNo);
43 OMElement lineAuditMoney = factory.createOMElement("LineAuditMoney", ns);
44 lineAuditMoney.setText("23");
45 newOperation.addChild(lineAuditMoney);
46
47 method.addChild(param);
48 method.build();
49 System.out.println("method==="+method.toString());
50 try {
51 sc.setTargetEPR(end);
52 result = sc.sendReceive(method);
53 } catch (AxisFault axisFault) {
54 result = factory.createOMElement("return", ns);
55 OMElement flag = factory.createOMElement("flag", ns);
56 // flag.setText(Integer.toString(ERROR));
57 result.addChild(flag);
58 OMElement message = factory.createOMElement("message", ns);
59 message.setText(axisFault.getReason());
60 result.addChild(message);
61 System.out.println("result = " + result);
62 }
63 System.out.println("result = " + result);
64 return result;
65 }
66 }
webService 客户端调用及异常信息First Element must contain the local name, Envelope , but found definitions的更多相关文章
- 根据wsdl文件,Java工程自动生成webservice客户端调用
根据wsdl文件,Java工程自动生成webservice客户端调用 1,工具:带有webservice插件的myeclips 2,步骤: (1),新建一个Java工程:relationship (2 ...
- 根据wsdl文件,Web工程自动生成webservice客户端调用
根据wsdl文件,Web工程自动生成webservice客户端调用 1,工具:带有webservice插件的eclips 2,步骤: (1),新建一个Web工程:WSDLTest (2),浏览器访问W ...
- WebService学习之旅(六)使用Apache Axis2实现WebService客户端调用
上节介绍了如何使用Axis2 发布一个WebService,Axis2除了为我们编写WebService应用带来了便利,也同样简化的客户端调用的过程,本节在上节的基础上使用Axis2自带的工具生成客户 ...
- jdk的wsimport方法实现webservice客户端调用服务
1.配置好jdk环境,打开命令行,输入wsimport回车能看到很多该命令的参数, -s:要生成客户端代码的存储路径 -p:对生成的代码从新打包 这两个最常用. 在打开的命令行中输入:wsimport ...
- webservice客户端添加soap Header信息
根据wsdl文件的header信息,在客户端中添加相应的header 1.wsdl信息如图 <soapenv:Envelope xmlns:soapenv="http://schema ...
- 采用WebService客户端调用WSDL/SOAP网络报错的解决办法
WebService接口是网络传输控制的重要途径,在Windows系统下运行客户端时,平时一直能正确运行,但某天可能突然会发生调用wsdl soap邮件标头无法识别等莫名其妙的错误提示,出现这种情况一 ...
- 04.webservice客户端调用
不要求所有的元素都理解,真正做开发的时候,有一些必须是要用的. 以后我们做开发的时候服务访问点的集合就一个服务的访问点.服务访问点绑定了具体的一个服务类,绑定的这个东西它本身也是一个元素.往上找,四个 ...
- webservice 客户端调用
/** * 通过webserevice下发工单 * @param url * @param method * @param requestMap * @return * @throws Service ...
- WebService客户端调用的几种方式
1.用组件HTTPRIO,支持VCL WIN32和FIRE MONKEY跨平台Android手机 HTTPRIO1.URL := 'http://127.0.0.1:8080/soap/IsoapTe ...
随机推荐
- 打开vmvare出现The VMware Authorization Service is not running。
win+r再输入cmd打开doc,输入services.msc打开服务,吧Vmware Authorization Service 更改为自动或者将其启动即可.
- laravel中间件使用
1.在app/Http/Kernel.php文件中配置中间件文件,例如: protected $routeMiddleware = [ 'auth' => \Illuminate\Auth\Mi ...
- Spring 控制反转
Spring 控制反转 具体内容 Spring 开发框架之中有几个概念DI&IOC.AOP.那么要想理解Spring就必须首先理解控制反转的核心意义是什么? 对于IOC来讲如果直接进行文字的描 ...
- python模块之os模块详解
os.listdir(dirname):列出dirname下的目录和文件 os.getcwd():获得当前工作目录 os.curdir:返回当前目录('.') os.chdir(dirname):改变 ...
- .net ElasticSearch-Sql 扩展类
官方提供的是java sdk,并支持jdbc方式的查询结果输出;但是却没有.net sdk的支持. 开发 ElasticSearch-Sql 第三方开源项目的.net sdk,未来集成入bsf框架.( ...
- Android 上层应用读写设备节点
Android 上层应用读写设备节点 Android L [TOC] 1. Android 设备节点 Android基于Linux内核.设备节点文件是设备驱动的逻辑文件,可以通过设备节点来访问设备驱动 ...
- dotpeek的导出
在开始写之前先说明下,搜了很久的度娘,就是没找到dotpeek的导出功能,····,看来用的人不多, ------------------------------------------------- ...
- 【NOIP模拟】board(线段树维护二进制,树序号化为二进制)
题目背景 SOURCE:NOIP2016-RZZ-2 T3 题目描述 给出这样一棵“二叉树”: 每个节点有左右两个儿子,并如下定义每个节点的高度:假设父亲节点的高度为 h ,那么他的两个儿子的节点的高 ...
- (转)java之runnable jar与普通jar
背景:项目中有时候需要导出相关的jar包,可是总是不能分清楚. 1 导出包 导出普通jar包(可作为第三方库,类似dll,so等) 在eclipse中右键选择except->java->j ...
- (转)java提高篇(二)-----理解java的三大特性之继承
在<Think in java>中有这样一句话:复用代码是Java众多引人注目的功能之一.但要想成为极具革命性的语言,仅仅能够复制代码并对加以改变是不够的,它还必须能够做更多的事情.在这句 ...