报错:“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 }

转载于:https://www.cnblogs.com/jeffreyluo/p/5236074.html

webService 客户端调用及异常信息First Element must contain the local name, Envelope , but found definitions...相关推荐

  1. WebService客户端调用常见5种方式

    之前系统中使用到了webservice进行第三方通信,这里总结一下常见的5种客户端调用方式. 在此之前我们先简单搭建一个webservice服务端项目,发布一个webservice服务.我这里使用sp ...

  2. cxf-2.4.1 webservice客户端调用代码

    1:首先看清楚cxf的版本cxf-2.4.1 需要5个jar包 2:new一个java工程把上面的5个jar包放进去 main方法中下面三句话就搞定了 JaxWsDynamicClientFactor ...

  3. .net webservice studio调用方法传参_springboot整合WebService简单版

    一.什么是webservice 这里给大家分享一下我们的专栏<Java 进阶集中营>,每天都会给大家分享一个最新的java技术内容,有优秀的技术讯息,也欢迎分享在我的专栏里. JAVA 进 ...

  4. 生成webservice客户端以及解决SSL异常

    生成Webservice代码 并解决异常HTTP 传输错 误:javax.net.ssl.SSLHandshakeException:javax.net.ssl.SSLHandshakeExcepti ...

  5. WebService客户端添加SOAPHeader信息

    WebService客户端添加SOAPHeader信息 通过JAXBContext创建Marshaller对头信息进行解析为dom,获取WSBindingProvider,使用Headers.crea ...

  6. httpclient妙用一 httpclient作为客户端调用soap webservice(转)

    前面有一篇使用HttpClient调用带参数的post接口方法,这里找到一篇使用HttpClient调用Soap协议接口的方式. 原文地址:httpclient妙用一 httpclient作为客户端调 ...

  7. WebService的四种客户端调用方式(基本)

    转载:http://blog.csdn.net/csdn_gia/article/details/54863549 web服务网址:http://www.webxml.com.cn/zh_cn/web ...

  8. WebService客户端三种调用方式整理

    1 WebService基础 1.1 作用 1,       WebService是两个系统的远程调用,使两个系统进行数据交互,如应用: 天气预报服务.银行ATM取款.使用邮箱账号登录各网站等. 2, ...

  9. logback配置控制打印台异常信息_logback异常输出详细信息(调用堆栈)分析

    Logback背景 Logback是一个开源的日志组件,是log4j的作者开发的用来替代log4j的. logback由三个部分组成,logback-core, logback-classic, lo ...

最新文章

  1. 优化SQl语句的十个重要步骤
  2. 【javascript】javascript设计模式mixin模式
  3. linux搭建SonarQube代码质量平台_Oracle 最新详细版本
  4. python语言的主网址-Python简介
  5. ios拇指社保应用源码
  6. docker容器中bash: vi: command not found
  7. windows 花式装系统
  8. 一三五、服务器部署Node项目、Vue spa静态项目、ssr项目
  9. linux 使用rtl8153 USB网卡
  10. 实验十七 通信录csv文件管理
  11. 企业私有云资源规划及设计
  12. pandas分组分析:GroupBy和pandas交叉分析:pivot_table/crosstab【学习记录】
  13. 二维码与条形码的生成和识别使用
  14. 怎样把普洱熟茶泡得更好喝?
  15. UVA-10499 The Land of Justice
  16. Python+Zookeeper操作
  17. 微信小程序 post请求发送x-www-form-urlencoded类型数据
  18. elasticsearch配置告警方案问题记录
  19. 智慧农业: STM32F103ZE+ESP8266+腾讯云物联网平台+微信小程序设计
  20. 盛大数位红 正式进军手机游戏

热门文章

  1. Python Django 正向查询与逆向查询
  2. eureka服务续约机制
  3. Java多线程安全问题解决的两种方式代码案例
  4. jQuery ajax简单案例-验证用户名是否可用
  5. Coding:两个从大到小的有序链表合并成一个从小到大有序链表
  6. malloc和free的深层次分析
  7. 超详细轮播图的三种实现方法html+css+javascript
  8. linux 守护进程_Linux 守护进程
  9. math python 向上取整_Python的数值基本运算和其它数学运算方法
  10. linux下使用make指令生成程序时提示“XXX is up to date”问题的解决办法