微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WebService CSF使用详解

    建立service:  

       1CxfService

@WebService

public interface CxfService {

    @WebMethod 

    public @WebResult List<TaskBean> getTasksByActor(

@WebParam(name="actor") String actor);

@WebMethod 

public void createAndStartProcessInstance(

@WebParam(name="processName") String processName,

@WebParam @XmlJavaTypeAdapter(MapAdapter.class)  Map<String,String> variables);

}

       2CxfServiceImpl                      

@WebService(endpointInterface = "com.CxfService")

public class CxfServiceImpl implements CxfService {

@Override

public void completeTask(String taskId) {

    JbpmHelper.taskService.completeTask(taskId);

}

    @Override

    public void createAndStartProcessInstance(String processName,

           Map<String,String> variables) {

       if(variables == null){

           JbpmHelper.executionService.startProcessInstanceByKey(processName);

       }else{

JbpmHelper.executionService.startProcessInstanceByKey(processName,variables);

       }

    }

}

 

web.xml:

    <context-param> 

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

        <param-value>

          classpath:/applicationContext.xml

        </param-value>

    </context-param>

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    </listener>

    <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>/service/*</url-pattern>

    </servlet-mapping>

    <filter>

spring配置文件applicationContext.xml

<beans

    xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:p="http://www.springframework.org/schema/p"

    xmlns:jaxws="http://cxf.apache.org/jaxws"

    xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"

    default-autowire="byName"

    default-lazy-init="true">

 

    <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"/>

    <!-- 以下两种方式均可 -->

    <jaxws:endpoint id="cxfService" address="/CxfService"

       implementor="com.CxfServiceImpl"/>

<jaxws:server id="cxfService1" serviceClass="com.CxfService"

    address="/CxfService ">

        <jaxws:serviceBean> 

            <bean class="com.CxfServiceImpl"/> 

        </jaxws:serviceBean> 

    </jaxws:server> 

</beans>

    客户端调用                                                                     

    JaxWsProxyfactorybean jwfb = new JaxWsProxyfactorybean();

    jwfb.setServiceClass(CxfService.class);

    jwfb.setAddress("http://132.94.135.15:8080/service/CxfService");

    CxfService client = (CxfService) jwfb.create();

   

    调用方法

    client.createAndStartProcessInstance("question", varMap);

       List list = client. getTasksByActor("custom");

 

-------------------------------------------------------------------

JDK: jdk1.6.0_13(jdk1.6.0_4版本以下可能用)

Jar包:(不十分准确,可能有些包并不需要)

commons-dbcp-1.2.2.jar

commons-logging-1.1.1.jar

commons-pool-1.5.4.jar

cxf-2.2.6.jar

geronimo-activation_1.1_spec-1.0.2.jar

geronimo-annotation_1.0_spec-1.1.1.jar

geronimo-javamail_1.4_spec-1.6.jar

geronimo-ws-Metadata_2.0_spec-1.1.2.jar

ibatis-2.3.4.726.jar(不需要)

jaxb-api-2.1.jar

jaxb-impl-2.1.13.jar

jaxws-api.jar

log4j-1.2.15.jar

neethi-2.0.4.jar

ojdbc14.jar

spring.jar

spring-beans-2.5.6.jar

spring-context-2.5.6.jar

spring-core-2.5.6.jar

spring-web-2.5.6.jar

stax-api-1.0.1.jar

wsdl4j-1.6.2.jar

wstx-asl-3.2.0.jar

xercesImpl.jar

xercesSamples.jar

xml-apis.jar

xmlParserAPIs.jar

xml-resolver-1.2.jar

XmlSchema-1.4.5.jar

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐