CXF WebService 学习总结

一、需要的引入的jar包(具体存在了百度云里面)

二、web.xml配置

1、引入cxf-servlet.xml文件

具体写法如下:

<web-app>

<context-param>

      <param-name>contextConfigLocation</param-name>

     <param-value>

     /WEB-INFO/cxf-servlet.xml

     </param-value>

</context-param>

</web-app>

三、编写接口和java类

1、接口:

import java.util.Map;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
import com.inspur.sdm.mapplus.ObjectFactory;

@WebService(targetNamespace = "http://som.inspur.com", name = "BCSFlowService")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface IBCSFlowService {
    /**
     * im接口
     * @param flowId
     * @param xml
     * @return
     */
    @WebMethod(operationName = "replyIM")
    @WebResult(name = "replyIM_response", partName = "request")
    public String replyIM(@WebParam(name = "flowId") String flowId,@WebParam(name = "xml") String xml);
    
    
    @WebMethod(operationName = "replyAM")
    @WebResult(name = "replyAM_response", partName = "request")
    public String replyAM(@WebParam(name = "xml") String xml);
    
    
    @WebMethod(operationName = "replyWFM")
    @WebResult(name = "replyWFM_response", partName = "request")
    public String replyWFM(@WebParam(name = "sevType") String sevType,@WebParam(name = "xml") String xml);
    
    

}

2、java类:

@javax.jws.WebService(
        serviceName = "BCSFlowService",
        portName = "BCSFlowService_servicePort",
        targetNamespace = "http://som.inspur.com",
        wsdlLocation = "file:/F:/BCSFlowService.wsdl",
        endpointInterface = "com.inspur.om.webService.wsInterfaces.IBCSFlowService")
@Service("BCSFlowService")
public class BCSFlowService implements IBCSFlowService{

    private static Logger log = Logger.getLogger(BCSFlowService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    
    @Autowired
    private RedisTemplate<Serializable, Serializable> redisTemplate;
    @Autowired
    private IProcessDefService processDefService;
    public String replyIM(@WebParam(name = "flowId") String flowId,
            @WebParam(name = "xml") String xml) {
        
    }
 

四、cxf-servlet.xml配置

<?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">  
          
  <import resource="classpath:META-INF/cxf/cxf.xml" />

 <!-- OM Web Service -->
  <jaxws:server id="BCSFlowService" serviceClass="com.inspur.om.webService.wsInterfaces.IBCSFlowService" address="/BCSFlowService">  
    <jaxws:serviceBean>
        <bean class="com.inspur.om.webService.service.BCSFlowService" />  
    </jaxws:serviceBean>
  </jaxws:server>

  
</beans>

猜你喜欢

转载自blog.csdn.net/qq_38282454/article/details/84333087
今日推荐