定义webservice接口服务端
web.xml配置<servlet><servlet-name>xxx</servlet-name><servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class><load-on-startup&g...
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
更多推荐
所有评论(0)