【技术贴】webservice cxf2 客户端动态调用报错No operation was found with the name
No operation was found with the name xxx
出错原因是因为发布服务的接口所在包路径和此接口实现类包路径不一致,比如你的服务接口可能放在了包com.x.interFace下,但是你的实现类却在com.x.interFace.impl包下,此时,发布的服务被客户端动态调用(JaxWsDynamicClientFactory)的时候,就会报错:
org.apache.cxf.common.i18n.UncheckedException: No operation was found with the name {http://impl.server.test.com/}xxxx.
就是说找不到某个方法
解决办法也很简单:直接在你的实现类上,加上注解:targetNamespace = "http://service.webservice.com/",这个包名(服务接口所在的包名)反写
如下:
我的实现类包名是com.webservice.service.impl
我的服务接口包名:com.webservice.service
所以 targetNamespace要写成我的服务接口所在包名的反写
@WebService(endpointInterface = "com.webservice.service.Server1", serviceName = "server1", targetNamespace = "http://service.webservice.com/")
public class Server1Impl implements Server1 { public String getInfo(String name, int age) {
return name.concat(",Hello Word! ! " + name + " age: " + age);
} public static void main2(String[] args) {
Server1Impl serverImpl = new Server1Impl();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(Server1.class); factory.setAddress("http://localhost:1111/server1");
factory.setServiceBean(serverImpl);
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getInInterceptors().add(new LoggingOutInterceptor()); factory.create(); } }
以下摘自:http://www.cnblogs.com/yshyee/p/3633537.html
信息: Created classes: com.test.server.HelloWorld, com.test.server.HelloWorldResponse, com.test.server.ObjectFactory
Exception in thread "main" org.apache.cxf.common.i18n.UncheckedException: No operation was found with the name {http://impl.server.test.com/}helloWorld.
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:342)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:336)
at com.test.client.HelloWorl.main(HelloWorl.java:20)
Java Result: 1
解决方法:对服务端的接口实现类中的@WebService添加targetNamespace,其值为接口包名的倒置,
例如我的IHelloWorld接口所在的包为com.test.server,此时对应的targeNamespace的值为http://server.test.com/
例如:
@WebService(
endpointInterface = "com.test.server.IHelloWorld",
serviceName="helloWorld",
targetNamespace="http://server.test.com/")
public class HelloWorldImp implements IHelloWorld { public String helloWorld(String name) {
return name+" Hello,World!"; }
【技术贴】webservice cxf2 客户端动态调用报错No operation was found with the name的更多相关文章
- dubbo 使用zookeeper 出现 Dubbo客户端调用报错NullPointerException
现在将网上的方法总结一下 方法一:.https://blog.csdn.net/u011294519/article/details/81810631 dubbo-provider.xml:提供者先扫 ...
- Struts2.3动态调用报 No result defined for action 错误
struts 2.3.16 採用动态调用发现不工作报404 not found,网上查找原因: 1.由于:struts2中默认不同意使用DMI 所以:须要在配置文件里打开: <constant ...
- CFX客户端调用报错
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unex ...
- Windows平台下使用CodeBlocks+GCC编译器生成动态dll,C#调用报错
报无法加载dll错误,解决方法: 1) 编译选择设置成x86,即-m322) 必须在c#程序目录下加上libgcc_s_dw2-1.dll
- Weblogic10.3.6部署解决CXF webService 调用报错: “Cannot create a secure XMLInputFactory”
一,解决步骤 1.添加jar包 stax2-api-3.1.4.jar woodstox-core-asl-4.4.1.jar 2.编写监听器 package com.neusoft.cxf.list ...
- springboot多模块项目下,子模块调用报错:程序包xxxxx不存在
今天在用springboot搭建多模块项目,结构中有一个父工程Parent 一个通用核心工程core 以及一个项目工程A 当我在工程A中引入core时,没有问题,maven install正常 当我 ...
- jmeter 启动jmeter-server.bat远程调用报错: java.io.FileNotFoundException: rmi_keystore.jks (系统找不到指定的文件。)
1.找到apache-jmeter-5.0\bin\jmeter.properties 2.修改server.rmi.ssl.disable=true (记得去除server.rmi.ssl.disa ...
- bug:进程可调用函数而子线程调用报错
在调试摄像头时遇到问题:在主进程里调用下述函数能够成功,但在子线程里创建时总是失败,错误打印为 sched: RT throttling activated. UniqueObj<OutputS ...
- artTemplate--使用artTemplate时,由于json对象属性有特殊格式 导致调用报错artTemplate,syntax error,Template Error
我们首先看下面的代码 data = { "siteName" : "西部云谷二期17", "PM10" : "10017" ...
随机推荐
- Java -- Thread中start和run方法的区别
一.认识Thread的 start() 和 run() 1.start(): 我们先来看看API中对于该方法的介绍: 使该线程开始执行:Java 虚拟机调用该线程的 run 方法. 结果是两个线程并发 ...
- Android之ORMLite实现数据持久化的简单使用
Android中内置了sqlite,但是常用的开发语言java是面向对象的,而数据库是关系型的,二者之间的转化每次都很麻烦.(作为程序员,应该学会偷懒)而Java Web开发中有很多orm框架(其实我 ...
- 设计模式——设计模式之禅day2
接口隔离原则 接口分为两种: ● 实例接口( Object Interface) , 在Java中声明一个类, 然后用new关键字产生一个实例, 它是对一个类型的事物的描述, 这是一种接口. 比如你定 ...
- [Entity Framework] MySQL @ Entity Framework 6
原文 [Entity Framework] MySQL @ Entity Framework 6 要让MySQL能够用EF6,我花了一点时间,在此记录一下 安装元件 在设定档加入Provider 安装 ...
- WebService中控制字符的处理
情景 最近项目中很多WebService都发不出去,报的错误如下: Invalid white space character in text to output (in xml 1.1 ...
- setTimeout、clearTimeout、setInterval,clearInterval ——小小计时器
先看下效果 话不多说上代码~ <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Typ ...
- java计时器
//用于计时,要求xx秒后开始发送短信,短信之间间隔xx秒 public static Date dateOperateBySecond(Date date,int second){ Calendar ...
- windows phone URI映射
UriMapping用于在一个较短的URI和你项目中的xaml页的完整路径定义一个映射(别名).通过使用别名URI,开发者可以在不改变导航代码的情况下来改变一个项目的内部结构.该机制还提供了一个简单的 ...
- 一次GC问题定位
同事有段代码执行时间过长,需要进行优化, Hashmultimap<Int,Bean> map = ...; for (400w*96) { // 计算过程 Bean = doComput ...
- 用C语言实现统计一个文件夹中各种文件的比例
<UNIX环境高级编程>中的程序清单4-7就介绍了如何实现递归地统计某个目录下面的文件!我刚开始看过它的代码后,觉得照着敲太没意思了,所以就合上书自己写了一遍!为此还写了一篇博文,这是博文 ...