报错:“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. 『转』MarsEdit快速插入源代码

    开始用MarsEdit来写博文,客户端的,毕竟是要方便的多啊. 遇到的第一个问题就是:MarsEdit没有提供快速插入源代码的工具,而对于我这枚码农而言,这个就有点太杯具了. 简单研究了一下,发现Ma ...

  2. Gradle学习笔记之Groovy

    [TOC] Gradle 的核心功能是由Java实现. 在这些功能之上, 有一个使用动态编程语言Groovy编写的领域特定语言(DSL). Gradle的构建脚本build.gradle和settin ...

  3. 浅谈angular中的promise

    promise目的就是为了跳出回调地狱.老掉牙的东西,大神轻拍. 举个最简单的例子:请求数据(getData),解析数据(executeData),显示数据(showData). //获取数据 fun ...

  4. Linux安装SVN服务器

    “svn都快淘汰了” #安装subversion yum -y install subversion #创建svn仓库基础路径 mkdir /home/svn #创建svn仓库 svnadmin cr ...

  5. VB6之阴影图层

    要是能创建半透明的刷子就好了,就不必像这样以图层的方式实现透明阴影效果. 代码: 'code by lichmama@cnblogs.com '绘制阴影图层 Private Declare Funct ...

  6. 浅谈Ajax 异步的几点细节

    1.浏览器执行到Ajax代码的这行语句的时候,发出了一个HTTP请求,欲想请求服务器上的数据.服务器此时开始I/O,所谓的I/O就是磁盘的读写,需要花费一些时间,所以不会立即产生下行的HTTP报文: ...

  7. php使用flock阻塞写入文件和非阻塞写入文件的实例讲解

    php使用flock阻塞写入文件和非阻塞写入文件的实例讲解: 阻塞写入代码:(所有程序会等待上次程序执行结束才会执行,30秒会超时) <?php $file = fopen("test ...

  8. 使用stackOfIntegers实现降序素数

    使用stackOfIntegers实现降序素数 代码如下: package day06; public class TestSU { public static void main(String[] ...

  9. 登录界面Demo

    今天记载一个Demo,这个是我练习项目中用到,供新手看看,界面图:

  10. Maven安装及使用-超级图文初级篇-

    针对新手刚接触maven,并且不知道如何去搭建和使用maven,那么我来写一篇浅显易懂的初级篇教程吧. 不同的是,别人会先将概念再安装,我来帮大家先搭建好以后再去看概念,不然概念会变的很模糊. 安装: ...