cxf Can't find the request for Observer
场景:Cxf开发webservice时遇到Can't find the request for xx's Observer,该怎么解决
Cxf开发webservice时遇到Can't find the request for xx's Observer
最近在用CXF开发web service时遇到这个很郁闷的问题。第一次用CXF,先说说我的配置吧。
web.xml文件中
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
cxf配置文件中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<!-- CXF webservice配置 -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="fyqqRespServiceImpl" class="com.thunisoft.fy.gxpt.server.webservice.service.impl.FyqqRespServiceImpl"/>
<jaxws:endpoint
id="fyqqResp"
implementor="#fyqqRespServiceImpl"
address="/fyqqResp" ></jaxws:endpoint>
</beans>
接口:
@WebService
public interface IFyqqRespService {
public String getRespXML(@WebParam(name="cbr")int cbr) throws ParseException;
}
实现类:
@WebService(endpointInterface = "com.thunisoft.fy.gxpt.server.webservice.service.IFyqqRespService")
public class FyqqRespServiceImpl extends GXPTBaseService implements IFyqqRespService {
}
http://localhost:8888/FyServer/fyqqResp?wsdl 这样访问时,报404,控制台报
Can't find the request for http://localhost:8888/FyServer/fyqqResp's Observer;
http://localhost:8888/FyServer/这样访问时,报
No services have been found.
希望高手们帮帮忙吧!我刚开始以为是JAR 包的问题,一朋友帮做了个例子,可以正常访问。然后我把我系统里的JAR包全拷到那个例子里面还是可以正常访问,但我把例子里的JAR包拷到我的项目里面仍然是同样的错儿。由于我们的web.xml配了一些listener,而且url-pattern全是/*,朋友猜可能是这个的问题,但我把配置注释了还是同样的错误。
------解决方案--------------------
路径问题错误
看看你的配置文件不是什么其它的错误就是报找不到相应的服务和页面
------解决方案--------------------
贴出来的这些确实没发现问题。
可能楼主要多帖点东西了。
------解决方案--------------------
哦,楼主不会忘了配置Spring吧
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
------解决方案--------------------
------解决方案--------------------
哥恰好有一个cxf的小demo,给邮箱发给你
------解决方案--------------------
------解决方案--------------------
spring和struts的结合方式。
两者的结合可以有以下三种方式:
1.使用 spring 的 actionsupport 类整合 structs
2.使用 spring 的 delegatingrequestprocessor 覆盖 struts 的 requestprocessor
3.将 struts action 管理委托给 spring 框架
第1种方式用我们自己的action继承actionsupport。这种方式只是方便了我们在action中获得spring容器对象,在actionsupport中提供了getwebapplicationcontext()方法。获得了spring容器后,就可以享用spring容器中的bean了。
第2种方式和第3种方式,都是把struts action 管理委托给 spring 框架 ,只是委托方式不一样。
第2种方式使用 spring 的 delegatingrequestprocessor 覆盖 struts 的 requestprocessor。而delegatingrequestprocessor 所做的工作,也就是,获得spring容器,获得被spring容器管理的真正action。
第3种方式在struts.xml中的action配置中配置:
< action path=" /searchsubmit" type=" org.springframework.web.struts.delegatingactionproxy" > ...
而这个代理action:delegatingactionproxy所做的工作也是,获得spring容器,获得被spring容器管理的真正action。
这3种结合方式,都需要获得spring容器:
在这三种spring和struts的结合方式中都通过以下方式获得spring容器:
delegatingactionutils.findrequiredwebapplicationcontext(actionservlet actionservlet moduleconfig moduleconfig)
而这种方法会先去寻找以struts插件形式,创建的spring容器。也就是以上面spring加载方式3中的key值到servletcontext中找。
如果找不到,再调用webapplicationcontextutils.getwebapplicationcontext(servletcontext context)方法获得spring容器。
结论:spring和struts的三种结合方式中,会先去寻找以struts插件形式,创建的spring容器。所以我们在struts中配置spring的加载插件,可以满足这三种结合方式。在找不到以struts插件形式,创建的spring容器后,会去找以contextloaderlistener或contextloaderservlet创建的spring容器,所以,不管以那种方式创建的spring容器都能满足spring和struts的三种结合方式。
Cxf开发webservice时遇到Can't find the request for xx's Observer
最近在用CXF开发web service时遇到这个很郁闷的问题。第一次用CXF,先说说我的配置吧。
web.xml文件中
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
cxf配置文件中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<!-- CXF webservice配置 -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="fyqqRespServiceImpl" class="com.thunisoft.fy.gxpt.server.webservice.service.impl.FyqqRespServiceImpl"/>
<jaxws:endpoint
id="fyqqResp"
implementor="#fyqqRespServiceImpl"
address="/fyqqResp" ></jaxws:endpoint>
</beans>
接口:
@WebService
public interface IFyqqRespService {
public String getRespXML(@WebParam(name="cbr")int cbr) throws ParseException;
}
实现类:
@WebService(endpointInterface = "com.thunisoft.fy.gxpt.server.webservice.service.IFyqqRespService")
public class FyqqRespServiceImpl extends GXPTBaseService implements IFyqqRespService {
}
http://localhost:8888/FyServer/fyqqResp?wsdl 这样访问时,报404,控制台报
Can't find the request for http://localhost:8888/FyServer/fyqqResp's Observer;
http://localhost:8888/FyServer/这样访问时,报
No services have been found.
希望高手们帮帮忙吧!我刚开始以为是JAR 包的问题,一朋友帮做了个例子,可以正常访问。然后我把我系统里的JAR包全拷到那个例子里面还是可以正常访问,但我把例子里的JAR包拷到我的项目里面仍然是同样的错儿。由于我们的web.xml配了一些listener,而且url-pattern全是/*,朋友猜可能是这个的问题,但我把配置注释了还是同样的错误。
------解决方案--------------------
路径问题错误
看看你的配置文件不是什么其它的错误就是报找不到相应的服务和页面
------解决方案--------------------
贴出来的这些确实没发现问题。
可能楼主要多帖点东西了。
------解决方案--------------------
哦,楼主不会忘了配置Spring吧
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
------解决方案--------------------
------解决方案--------------------
哥恰好有一个cxf的小demo,给邮箱发给你
------解决方案--------------------
------解决方案--------------------
spring和struts的结合方式。
两者的结合可以有以下三种方式:
1.使用 spring 的 actionsupport 类整合 structs
2.使用 spring 的 delegatingrequestprocessor 覆盖 struts 的 requestprocessor
3.将 struts action 管理委托给 spring 框架
第1种方式用我们自己的action继承actionsupport。这种方式只是方便了我们在action中获得spring容器对象,在actionsupport中提供了getwebapplicationcontext()方法。获得了spring容器后,就可以享用spring容器中的bean了。
第2种方式和第3种方式,都是把struts action 管理委托给 spring 框架 ,只是委托方式不一样。
第2种方式使用 spring 的 delegatingrequestprocessor 覆盖 struts 的 requestprocessor。而delegatingrequestprocessor 所做的工作,也就是,获得spring容器,获得被spring容器管理的真正action。
第3种方式在struts.xml中的action配置中配置:
< action path=" /searchsubmit" type=" org.springframework.web.struts.delegatingactionproxy" > ...
而这个代理action:delegatingactionproxy所做的工作也是,获得spring容器,获得被spring容器管理的真正action。
这3种结合方式,都需要获得spring容器:
在这三种spring和struts的结合方式中都通过以下方式获得spring容器:
delegatingactionutils.findrequiredwebapplicationcontext(actionservlet actionservlet moduleconfig moduleconfig)
而这种方法会先去寻找以struts插件形式,创建的spring容器。也就是以上面spring加载方式3中的key值到servletcontext中找。
如果找不到,再调用webapplicationcontextutils.getwebapplicationcontext(servletcontext context)方法获得spring容器。
结论:spring和struts的三种结合方式中,会先去寻找以struts插件形式,创建的spring容器。所以我们在struts中配置spring的加载插件,可以满足这三种结合方式。在找不到以struts插件形式,创建的spring容器后,会去找以contextloaderlistener或contextloaderservlet创建的spring容器,所以,不管以那种方式创建的spring容器都能满足spring和struts的三种结合方式。