公司对外通过webservice访问别人接口,对方webservice IP地址发生变化,切换过去之后,始终报错,在网上搜索了各种办法之后,暂时总结该问题几种可能解决办法,待真正解决时用的到。

异常详情:

org.apache.cxf.binding.soap.SoapFault: "http://schemas.xmlsoap.org/wsdl/", the namespace on the "definitions" element, is not a valid SOAP version.

javax.xml.ws.WebServiceException: org.apache.cxf.binding.soap.SoapFault: "http://schemas.xmlsoap.org/wsdl/", the namespace on the "definitions" element, is not a valid SOAP version.

        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:154)

可能的几种解决办法:

1. 在编写代码时不要使用factory.create创建service,而使用cxf生成的类创建,具体如下:

// 原先在代码里使用的方法
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(IWebPService.class);
String address1 = "http://192.168.0.121:9090/cloudsun/HelloWorldService?wsdl";
factory.setAddress(address1);
IWebPService ws1 = (IWebPService) factory.create(); // 修改成以下方式初始化
URL url = new URL(address1);
IWebPService ws1 = new (url).getWebPServiceImplPort();
参考:http://www.devexception.com/apache/31208.htm

2. 在调用时设置Address时,在方法1的factory.setAddress后面设置的地址,将?wsdl去掉:

例如:http://服务器IP/UA/TrustAuth?wsdl

修改为:http://服务器IP/UA/TrustAuth

参考:http://www.oschina.net/question/115223_37755

总结下来,使用第1种方法修改,会一劳永逸。

另外补充其他知识:

在搜索过程中有个办法使用

new WebPServiceImplService().getWebPServiceImplPort()生成对象,经查后这个方法有两个多态方法,

public IWebPService getWebPServiceImplPort(WebServiceFeature... features)

public IWebPService getWebPServiceImplPort() {

个人理解下来前面的那个WebServiceFeature是用来改变相应的地址或其他的,可能是理解错误,然后对此做了一些深入的了解:

WebServiceFeature是一个abstract class,其有以下几个子类:

javax.xml.ws.RespectBindingFeature
javax.xml.ws.soap.AddressingFeature
javax.xml.ws.soap.MTOMFeature

搜了半天也没弄清楚这个类是用来干嘛的,有知道的朋友可能帮忙解答解答,以后有机会再深入研究。

参考:http://www.massapi.com/class/ad/AddressingFeature.html

[WebService] the namespace on the "definitions" element, is not a valid SOAP version的更多相关文章

  1. WebService发布与调用问题:expected: {http://schemas.xmlsoap.org/soap/envelope/}Envelope but found: {http://schemas.xmlsoap.org/wsdl/}definitions

    Mailbox===AsYVzdwoY_b6uD s>>>>>>>javax.xml.ws.Service@103bf65 hs>>>> ...

  2. Property 'validate' does not exist on type 'Element | Element[] | Vue | Vue[]'. Property 'valid...

    使用vue-cli 3.0+Element-ui时候,调用form表单校验时候出现的问题是: Property 'validate' does not exist on type 'Element | ...

  3. 【Java EE 学习 80 上】【WebService】

    一.WebService概述 什么是WebService,顾名思义,就是基于Web的服务,它使用Http方式接收和响应外部系统的某种请求,从而实现远程调用.WebService实际上就是依据某些标准, ...

  4. 计算器之webservice实现

    以下是本人原创,如若转载和使用请注明转载地址.本博客信息切勿用于商业,可以个人使用,若喜欢我的博客,请关注我,谢谢!博客地址 一.根据我的上一篇博客 MyEclipse构建Web Service(Xf ...

  5. WebService的简单介绍与入门使用

    WebService是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布式 ...

  6. Java调用WebService方法总结(1)--准备工作

    WebService是一种跨编程语言.跨操作系统平台的远程调用技术,已存在很多年了,很多接口也都是通过WebService方式来发布的:本系列文章主要介绍Java调用WebService的各种方法,使 ...

  7. spring webservice 搭建出现的异常处理。异常: NAMESPACE_ERR: An attempt is made to create or change an object in a way whi

    异常:NAMESPACE_ERR: An attempt is made to create or change an object in a way whi---- 这是我自己写客户端调用webse ...

  8. Java之webService知识

    Java之webService知识 1 webservice基础知识 1.1 webService请求的本质 一次webService本质请求,如下所示: 1.2 wsdl文档解析 wsdl文档元素结 ...

  9. 用Python写WebService接口并且调用

    一.用ladon框架封装Python为Webservice接口 另用soaplib实现请看:    http://www.jianshu.com/p/ad3c27d2a946 功能实现的同时,希望将接 ...

随机推荐

  1. MySQL客户端Workbench

    MySQL客户端除了Navicat之外,还有官方推出的MySQL Workbench,能看到数据库包含的存储过程,而Navicate不能. 下载链接: 32位:http://cdn.mysql.com ...

  2. 《oracle每日一练》免安装Oracle客户端使用PL/SQL

    免安装Oracle客户端使用PL/SQL Oracle客户端挺招人烦的,部署连接它的应用通常需要先安装它的客户端,安装程序要求在目标机器上写注册表,假设你没有洁癖的话,你仍可能被下面的事情绊住:当你的 ...

  3. 全局对象的构造函数会在main 函数之前执行

    #include <iostream> using namespace std; class A { public: A() { cout << "Generator ...

  4. 隐藏左侧快速导航除DMS导航树之外的其他区域

    <style type="text/css"> /*隐藏左侧快速导航除DMS导航树之外的其他区域*/ .ms-quicklaunchouter { display: n ...

  5. 饿了么 openapi demo

    http://merchant.openapi.eleme.io/merchant.html#id215 class Program { static void Main(string[] args) ...

  6. 一步步搭建docker私有仓库并从私有仓库中下载镜像

    一步步搭建docker私有仓库 #下载镜像 docker pull registry#查看镜像 docker images #运行私有仓库,指定端口和数据卷 docker run -d -p : -v ...

  7. Linux下安装Flask开发框架

    Flask是开发pythonweb的一个轻量级框架,适合初学者使用,当有了熟练的web基础后,再继续学习高级框架的开发,Linux一般安装好之后都会有python开发环境,给开发带来方便,下面是Fla ...

  8. selenium WebDriver 操作高德地图

    String URL="http://www.amap.com/"; WebDriver driver = new FirefoxDriver(profile); driver.g ...

  9. mysql时间字符串按年/月/天/时分组查询

    SELECT DATE_FORMAT( deteline, "%Y-%m-%d %H" ) , COUNT( * ) FROM test GROUP BY DATE_FORMAT( ...

  10. 【leetcode】Shortest Palindrome(hard)★

    Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...