首页 > 代码库 > activiti designer源码的研究(三) 之servicetask调用除Java之后的其他语言发布的webservice
activiti designer源码的研究(三) 之servicetask调用除Java之后的其他语言发布的webservice
按照上一篇文章的配置,ServiceTask已经可以调用带有@webParam和@webResult发布的webservice了,但是怎么调用这些不带这些参数的发布的webservice了,因为其他语言并没有@webParam这些参数,请看下面的例子:
Counter.java
<span style="font-size:14px;">@WebService public interface Counter { /** * Increase the counter in 1 */ void inc(); /** * Returns the current count * * @return the count */ @WebResult(name="count") int getCount(); /** * Resets the counter to 0 */ void reset(); /** * Sets the counter to value * * @param value the value of the new counter */ void setTo(@WebParam(name="value") int value); <em> String prettyPrintCount(String prefix, String suffix); <strong> </strong>String prettyPrintCountTwo(String suffixTwo, String prefixTwo);</em> }</span>发布之后,wsdl文件如下(关键内容):
<xs:complexType name="prettyPrintCountTwo"> <xs:sequence> <xs:element minOccurs="0" name="arg0" type="xs:string"/> <xs:element minOccurs="0" name="arg1" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="prettyPrintCountTwoResponse"> <xs:sequence> <xs:element minOccurs="0" name="return" type="xs:string"/> </xs:sequence> </xs:complexType>我们会发现prettyPrintCountTwo方法的第一个参数名默认为arg0,第二个参数名默认为arg1
返回值的默认名为return
于是我在bpmn20.xml中进行了下面的配置
<span style="font-size:18px;"><serviceTask id="servicetask3" name="Service Task" implementation="##WebService" operationRef="tns:prettyPrintCountTwoOperation"> <dataInputAssociation> <sourceRef>PrettyPrintResult</sourceRef> <targetRef>arg0</targetRef> </dataInputAssociation> <dataInputAssociation> <sourceRef>PrefixTwoVariable</sourceRef> <targetRef>arg1</targetRef> </dataInputAssociation> <dataOutputAssociation> <sourceRef>return</sourceRef> <targetRef>PrettyPrintTwoResult</targetRef> </dataOutputAssociation> </serviceTask></span>
部署之后,然后运行,会发现会报如下错误
<span style="font-size:18px;">junit.framework.ComparisonFailure: expected:<The counter has the value -1. Good news 0 append What news> but was:<null> at junit.framework.Assert.assertEquals(Assert.java:100) at junit.framework.Assert.assertEquals(Assert.java:107) at junit.framework.TestCase.assertEquals(TestCase.java:269) at org.activiti.engine.test.bpmn.servicetask.WebServiceSimplisticTwoTest.testWebServiceInvocationWithSimplisticDataFlow(WebServiceSimplisticTwoTest.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at junit.framework.TestCase.runTest(TestCase.java:176) at org.activiti.engine.impl.test.PvmTestCase.runTest(PvmTestCase.java:65) at junit.framework.TestCase.runBare(TestCase.java:141) at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(AbstractActivitiTestCase.java:102) at junit.framework.TestResult$1.protect(TestResult.java:122) at junit.framework.TestResult.runProtected(TestResult.java:142) at junit.framework.TestResult.run(TestResult.java:125) at junit.framework.TestCase.run(TestCase.java:129) at junit.framework.TestSuite.runTest(TestSuite.java:255) at junit.framework.TestSuite.run(TestSuite.java:250) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) </span>会发现return并不存在,明明在wsdl中是return,怎么会不存在了?
于是我在activiti-cxf的CxfWSDLImport中测试SimpleStructureDefinition中存的是什么东西,结果发现return读入之后变成了_return,所以只要把return改为_return就OK了
activiti designer源码的研究(三) 之servicetask调用除Java之后的其他语言发布的webservice
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。