报错:“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的更多相关文章

  1. 根据wsdl文件,Java工程自动生成webservice客户端调用

    根据wsdl文件,Java工程自动生成webservice客户端调用 1,工具:带有webservice插件的myeclips 2,步骤: (1),新建一个Java工程:relationship (2 ...

  2. 根据wsdl文件,Web工程自动生成webservice客户端调用

    根据wsdl文件,Web工程自动生成webservice客户端调用 1,工具:带有webservice插件的eclips 2,步骤: (1),新建一个Web工程:WSDLTest (2),浏览器访问W ...

  3. WebService学习之旅(六)使用Apache Axis2实现WebService客户端调用

    上节介绍了如何使用Axis2 发布一个WebService,Axis2除了为我们编写WebService应用带来了便利,也同样简化的客户端调用的过程,本节在上节的基础上使用Axis2自带的工具生成客户 ...

  4. jdk的wsimport方法实现webservice客户端调用服务

    1.配置好jdk环境,打开命令行,输入wsimport回车能看到很多该命令的参数, -s:要生成客户端代码的存储路径 -p:对生成的代码从新打包 这两个最常用. 在打开的命令行中输入:wsimport ...

  5. webservice客户端添加soap Header信息

    根据wsdl文件的header信息,在客户端中添加相应的header 1.wsdl信息如图 <soapenv:Envelope xmlns:soapenv="http://schema ...

  6. 采用WebService客户端调用WSDL/SOAP网络报错的解决办法

    WebService接口是网络传输控制的重要途径,在Windows系统下运行客户端时,平时一直能正确运行,但某天可能突然会发生调用wsdl soap邮件标头无法识别等莫名其妙的错误提示,出现这种情况一 ...

  7. 04.webservice客户端调用

    不要求所有的元素都理解,真正做开发的时候,有一些必须是要用的. 以后我们做开发的时候服务访问点的集合就一个服务的访问点.服务访问点绑定了具体的一个服务类,绑定的这个东西它本身也是一个元素.往上找,四个 ...

  8. webservice 客户端调用

    /** * 通过webserevice下发工单 * @param url * @param method * @param requestMap * @return * @throws Service ...

  9. WebService客户端调用的几种方式

    1.用组件HTTPRIO,支持VCL WIN32和FIRE MONKEY跨平台Android手机 HTTPRIO1.URL := 'http://127.0.0.1:8080/soap/IsoapTe ...

随机推荐

  1. PHP连接数据库、创建数据库、创建表的三种方式

    这篇博客主要介绍了三种方式来连接MySQL数据库以及创建数据库.创建表.(代码是我在原来的基础上改的) MySQLi - 面向对象 MySQLi - 面向过程 PDO MySQLi 面向对象 < ...

  2. 为Dynamics 365启用部署级的跟踪以及跟踪文件的定期删除

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复260或者20170712可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...

  3. POJ 3659 Cell Phone Network / HUST 1036 Cell Phone Network(最小支配集,树型动态规划,贪心)-动态规划做法

    POJ 3659 Cell Phone Network / HUST 1036 Cell Phone Network(最小支配集,树型动态规划,贪心) Description Farmer John ...

  4. Educational Codeforces Round 25 Five-In-a-Row(DFS)

    题目网址:http://codeforces.com/contest/825/problem/B 题目:   Alice and Bob play 5-in-a-row game. They have ...

  5. docker~学习笔记索引

    回到占占推荐博客索引 使用docker也有段时间了,写了不少文章与总结,下面把它整理个目录出来,方便大家去学习与检索! docker~学习笔记索引 docker~linux下的部署和基本命令(2017 ...

  6. FZU 2253 salty fish

    https://vjudge.net/problem/FZU-2253 题意:略 思路: 一开始改变区间,还以为是线段树...还是dp的题做得太少了. 这题一开始我们可以统计出一共有多少只翻身的咸鱼, ...

  7. poj_3122:Pie(二分)

    不算难的一道二分..各种玄学错误..eps小了T,大了WA..最后G++改成C++提交就AC了.. #include<iostream> #include<cstdio> #i ...

  8. getcomputedstyle()获取border像素差异问题

    getComputedStyle()方法返回的是一个CSS样式声明对象--CSSStyleDeclaration对象(与style属性的类型相同),包含当前元素所有最终使用的CSS属性值: <! ...

  9. java 读取文件的路径

    1. 通用定位到用户目录下:   String userDir = System.getProperty("user.dir"); 2. web项目定位到WEB-INF/class ...

  10. windows系统查看支持最大内存

    1.使用快捷键:win+r打开命令窗口. 按回车到命令界面 2.弹出如下命令界面,在界面C:\Users\Administrator>处输入wmic memphysical get maxcap ...