@webservice报错org.apache.cxf.common.i18n.UncheckedException: No operation was found with
文章目录
- 1. 现象
- 2. 解决办法1
- 3. 解决办法2
1. 现象
整合spring+cxf的webservice,成功发布了wsdl,但在调用的时候报错
org.apache.cxf.common.i18n.UncheckedException: No operation was found with;
2. 解决办法1
: 在service接口中添加targetNamespace
package com.gblfy.service;import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;@WebService(targetNamespace = "http://impl.service.gblfy.com/")
public interface IUserService {@WebMethodpublic String getCxf(@WebParam(name = "reqXml") String reqXml);
}
实现类
package com.gblfy.service.impl;import com.gblfy.service.IUserService;import javax.jws.WebService;@WebService
public class UserServiceImpl implements IUserService {@Overridepublic String getCxf(String reqXml) {System.out.println("接收到的报文:" + reqXml);return "OK";}
}
客户端
/*** 单/多参调用工具类(Object类型)** @param cxfUrl url地址* @param method 调用方法名* @param reqXml 发送报文体* @return res 返回结果* @throws Exception 若有异常,在控制台输出异常,并将异常抛出*/public static String cxfClientParam(String cxfUrl, String method, Object... reqXml) throws Exception {String res = null;// 创建动态客户端JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();Client client = dcf.createClient(cxfUrl);// 需要密码的情况需要加上用户名和密码// client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME, PASS_WORD));Object[] objects = new Object[0];try {// 基本格式:invoke("方法名",参数1,参数2,参数3....);objects = client.invoke(method, reqXml);res = objects[0].toString();System.out.println("返回数据:" + res);} catch (java.lang.Exception e) {e.printStackTrace();throw e;}return res;}
3. 解决办法2
使用 QName 然后添加 service接口的地址
package com.gblfy.service.client;import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.stereotype.Component;import javax.xml.namespace.QName;/*** cxf客户端调用(企业内部已封装)** @author gblfy* @date 2021-09-17*/
@Component
public class CxfClient {public static void main(String[] args) throws Exception {String cxfUrl = "http://127.0.0.1:8080/spring_cxf_war/webservice/userWS?wsdl";String method = "getCxf";String reqXml = "cxf请求报文";//调用服务CxfClient.cxfClientParam(cxfUrl, method, reqXml);}/*** 单/多参调用工具类(Object类型)** @param cxfUrl url地址* @param method 调用方法名* @param reqXml 发送报文体* @return res 返回结果* @throws Exception 若有异常,在控制台输出异常,并将异常抛出*/public static String cxfClientParam(String cxfUrl, String method, String reqXml) throws Exception {String res = null;// 创建动态客户端JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();Client client = dcf.createClient(cxfUrl);// 需要密码的情况需要加上用户名和密码// client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME, PASS_WORD));Object[] objects = new Object[0];try {// 基本格式:invoke("方法名",参数1,参数2,参数3....);QName qName = new QName("http://impl.service.gblfy.com/",method);objects = client.invoke(qName, reqXml);res = objects[0].toString();System.out.println("返回数据:" + res);} catch (Exception e) {e.printStackTrace();throw e;}return res;}
}
@webservice报错org.apache.cxf.common.i18n.UncheckedException: No operation was found with相关推荐
- springboot版本升级导致webservice调用失败org.apache.cxf.common.jaxb.JAXBUtils.createMininumEscapeHandle
很感谢这位作者的文章https://blog.csdn.net/q340505050518/article/details/105394315 近期对项目版本进行升级 原项目版本 从 Springcl ...
- SpringBoot报错 org.apache.catalina.LifecycleException: Protocol handler start failed
很多人在第一次创建运行SpringBoot项目的时候会报错 org.apache.catalina.LifecycleException: Protocol handler start failed ...
- SpringBoot:运行项目是报错org.apache.ibatis.builder.IncompleteElementException:
本人在左前后端分离项目时,运算后端的项目,出现报错 org.apache.ibatis.builder.IncompleteElementException: Could not find resul ...
- spring boot一个模块加载不到引用另一个模块的mapper.xml报错org.apache.ibatis.binding.BindingException: Invalid bound sta
场景:parent项目有两个子模块,分别是shiro和server,两个子模块各自有各自的实体类.mapper,然后server需要引用shiro中的实体类和mapper.已经在启动类添加注解配置扫描 ...
- php调用webservice报错Class 'SoapClient' not found
php调用webservice报错Class 'SoapClient' not found 原文:php调用webservice报错Class 'SoapClient' not found php在调 ...
- 【Hbase】报错org.apache.hadoop.hbase.RegionTooBusyException
执行了一个spark-submit程序,操作hbase但是报错org.apache.hadoop.hbase.RegionTooBusyException,具体错误如下 17/12/07 11:49: ...
- 关于activeMq在本地测试报错org.apache.activemq.transport.InactivityIOException: Cannot send, channel has alrea
关于activeMq在本地测试报错org.apache.activemq.transport.InactivityIOException: Cannot send, channel has alrea ...
- servlet报错:org.apache.catalina.core.StandardWrapperValve invoke
今天写程序时遇到以下报错 : servlet报错:org.apache.catalina.core.StandardWrapperValve invoke 具体错误代码如下: 网上找到的一些解决方法如 ...
- 2、maven案例idexXML调模板maven运Tomcat报错org.apache.jasper.JasperException: Unable to compile class forJSP
报错org.apache.jasper.JasperException: Unable to compile class forJS解决方案 如图,启动服务器成功,但是登陆时报错,原因是6一下版本不兼 ...
最新文章
- 【Deep Learning笔记】常用的激活函数
- win8 -telnet安装
- Http上传Xml文件
- 不用安装Oracle Client如何使用PLSQL Developer
- Python数据分析Numpy库方法简介(一)
- 【黑客】利用VBS脚本让QQ永远在线,等级速升
- Labview完全卸载工具msiblast NI
- python扫描器_Python扫描器-端口扫描
- 12 经络的走向图和说明
- DHSNet: Deep Hierarchical Saliency Network for Salient Object Detection阅读总结
- RGL: A Simple yet Effective Relation.. 文章详解
- php 内网/外网ip判断
- 元素垂直居中的几种方法
- 图解传说中的HTTP协议
- 基于verilog的 PRBS编码
- 手动爬取炉石传说所有卡牌
- input框中的文字加下划线
- CodeWarrior flash
- linux合成软件下载,Yoshimi下载 软件合成器Yoshimi for Linux v2.0 官方免费版 下载-脚本之家...
- 安卓一键清理内存_只需一键,即可清理iPhone内存