web.xml配置
<servlet>
<servlet-name>xxx</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>xxx</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
cxf_server_beans.xml配置
<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="MessageNotificationImpl" class="com.tydic.smpm.isag.service.impl.xxxImpl"></bean>
<jaxws:endpoint id="xxxService"
implementor="#xxxImpl"
address="/xxx">
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
接口类
@WebService(targetNamespace="http://server.xxx.com")
public interface xxx {
public void methodReceipt(@WebParam(name="param1")String xxx, @WebParam(name="param2")Xxx xxx) throws java.rmi.RemoteException;
}
实现类
@javax.jws.WebService(serviceName = "xxxImpl", targetNamespace = "http://server.xxx.com",
endpointInterface = "cn.package.xxx")
@Service("xxxImpl")
public class xxxImpl implements xxx {
public void methodReceipt(String param1, Xxx param2) {
}
}
注意事项:
1、servlet-name和address必须相同,否则由于找不到服务会报错:
No service was found
2、刚开始在实现类上没有使用注解@Service("xxxImpl")标记为bean,导致缓存和业务service注入不进去
3、implementor和@Service("xxxImpl")里面的值必须相等,否则报错找不到bean
本文详细介绍了如何使用Apache CXF框架配置和部署Web服务,包括web.xml和cxf_server_beans.xml文件的设置,以及接口类和实现类的创建。强调了servlet-name、address和implementor的一致性,并提供了常见错误及其解决方案。
2017

被折叠的 条评论
为什么被折叠?



