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 ...
随机推荐
- 如何解释json的字符串
public void getToken(){ String json = getJedis().get("f2b9152f36424e8b8a454df9b50eb743"); ...
- Texlive + TexStudio + Language Tool Win7配置
Texlive的配置很简单,安装的时候跟着向导一步一步安装就可以了. TexStudio也是同样的安装过程,没什么技巧.这里提一下界面颜色的配置.习惯了暗底白字,所以就google了一下相关的配置,大 ...
- js中各个类型的转换总结
字符串转换为数组: 1 正则表达式var string=“abcdedef”var obj=string.replace(/(.)(?=[^$])/g,"$1,").split ...
- Servlet Filter 中init和destroy问题
测试源码如下: package com.FilterTest.Filter; import java.io.IOException; import javax.servlet.Filter; impo ...
- 使用Web页面配置ESP8266的参数
前言 使用Web页面配置ESP8266的参数相对于使用串口AT指令配置更加直观和简单.与配置路由器方式类似. 基本思路 基本思路是ESP8266工作AP模式下,作为TCP Server监听TCP Cl ...
- Java IO设计模式(装饰模式与适配器模式)
01. 装饰模式 1. 定义 Decorator装饰器,就是动态地给一个对象添加一些额外的职责,动态扩展,和下面继承(静态扩展)的比较.因此,装饰器模式具有如下的特征: 它必须持有一个被装饰的对象(作 ...
- 【SqlServer系列】子查询
1 概述 1.1 已发布[SqlServer系列]文章 [SqlServer系列]SQLSERVER安装教程 [SqlServer系列]数据库三大范式 [SqlServer系列]表单查询 [Sq ...
- python中函数的定义,调用,全局变量,局部变量,函数的嵌套使用-初级篇
函数的基本概述 在学习函数之前,一直遵循:面向过程编程,即:根据业务逻辑从上到下实现功能,可以思考一下如果有某个功能的代码是在多个地方使用的是否可以只写一次?此时的代码该如何定义.先观察以下的案例: ...
- java设计模式 01 开山篇
一. 设计模式概述 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代码可靠性. ...
- 如何清除img图片下面有一片空白
最近在做项目突然发现用了img后有个空白区,如下图: 真的很影响美观,那么是什么原因造成的呢? 右键查看元素查看上下文的margin和padding也没有找到这个空白的来源. 只好上网看看别人是怎么说 ...