报错:“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. 从 JavaScript 到 TypeScript

    本文首发在我的个人博客:http://muyunyun.cn/posts/66a54fc2/ 文中的案例代码已经上传到 TypeScript TypeScript 并不是一个完全新的语言, 它是 Ja ...

  2. Java程序设计模式系列之适配器模式

    理解适配器设计模式需要从生活中的场景进行联系,在生活当中有那些东西能够称为适配器呢?从字面上理解,"适配"的意思就是让一个东西和另一个东西配对,能够让他们一起工作,比如大家用的笔记 ...

  3. 一张图告诉你angular2所有知识点

    忙活了半年,从angular2.0到现在angular4.2.从没AOT到有AOT.我想说,angular2的学习曲线真的有点陡峭.只能说,angular2是一个比较完整的框架,框架就是这样,一大堆条 ...

  4. usaco 2008 月赛 lites 开关灯 题解

      题目:     Farmer John尝试通过和奶牛们玩益智玩具来保持他的奶牛们思维敏捷. 其中一个大型玩具是 牛栏中的灯. N (2 <= N <= 100,000) 头奶牛中的每一 ...

  5. oracle常用函数及关键字笔记

    --函数及关键字--1.trim,ltrim,rtrim 去除字符,无指定默认去除空格SELECT TRIM('a' FROM 'aafhfhaaaaaaaa'), LTRIM('aafhfhaaaa ...

  6. HDU 2955 Robberies(DP)

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=2955 题目: Problem Description The aspiring Roy the Rob ...

  7. github 项目管理

    一.在GitHub上创建项目 1. 打开浏览器 在地址栏输入地址:github.com 填写用户名.邮箱.密码 点击Sign up即可简单地注册 2. 完成注册,进入github平台, 点击new r ...

  8. Swift语法初见

    Swift语法初见 http://c.biancheng.net/cpp/html/2424.html 类型的声明: let implicitInteger = 70 let implicitDoub ...

  9. CentOS7.2设置静态IP

    首先将源文件进行备份: [zgw@localhost 桌面]$ sudo cp /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/syscon ...

  10. 《HelloGitHub》第 16 期

    <HelloGitHub>第 16 期 兴趣是最好的老师,HelloGitHub 就是帮你找到兴趣! 简介 分享 GitHub 上有趣.入门级的开源项目. 这是一个面向编程新手.热爱编程. ...