【技术贴】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" ...
随机推荐
- IT技术开发人员35岁之前应该做的十件事
第一,学会本行业所需要的一切知识并有所发展.已故零件大王布鲁丹在他35岁时,已经成为零件行业的领袖,并且组建了年收入达千万美元的海湾与西部工业公司.每个人在年轻时都可能有过彻夜不眠.刻苦攻读,这在20 ...
- Android之自定义画图文字动画
结构: BaseView: package com.caiduping.canvas; import android.content.Context; import android.graphics. ...
- Agile.Net 组件式开发平台 - 权限管理组件
RBAC原则 (1)最小权限原则之所以被RBAC所支持,是因为RBAC可以将其角色配置成其完成任务所需要的最小的权限集. (2)责任分离原则可以通过调用相互独立互斥的角色来共同 ...
- js判断输入字符串长度(汉字算两个字符,字母数字算一个)
js判断输入字符串长度(汉字算两个字符,字母数字算一个) 文本输入时,由于数据库表字段长度限制会导致提交失败,因此想到了此方法验证. 废话不多说上代码: <html> <head&g ...
- c# using 引用和别名的使用
1.使用别名 在同时引用的两个命名空间中有相同的类型时,可以使用别名来区分.如下所示: using System; using System.Threading; using System.Timer ...
- 接口(interface)
接口(interface) 接口(interface)定义了一个可由类和结构实现的协定.接口可以包含方法.属性.事件和索引器.接口不提供它所定义的成员的实现-它仅指定实现该接口的类或结构必须提供的成员 ...
- JavaScript、jQuery、HTML5、Node.js实例大全-读书笔记1
技术很多,例子很多,只好慢慢学,慢慢实践!!现在学的这本书是[JavaScript实战----JavaScript.jQuery.HTML5.Node.js实例大全] 第 3 章 用 JavaScri ...
- InnoDB 离线转储工具
一,应用场景; 1,表空间严重损坏,无法恢复;2,数据库表空间文件丢失后从磁盘上打捞出部分数据页面;3,恢复删除记录; 二,功能; 从数据页中直接转储出文本格式的行数据,从而可以后期用 LOAD DA ...
- 指针与strncpy---内存
指针的形式的赋值和strncpy的赋值 e.SetAttr("Amt", ToString(dAmt) ); e.SetAttr("Amt", sAm ...
- IOCP模型总结(转)
IOCP模型总结(转) IOCP(I/O Completion Port,I/O完成端口)是性能最好的一种I/O模型.它是应用程序使用线程池处理异步I/O请求的一种机制.在处理多个并发的异步I/O请求 ...