一 建立service:
1)CxfService:
@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);
}
2)CxfServiceImpl:
@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