公司今年初導入 Agentflow BPM 3.5,已上線運作了 3 之流程,目前需要將之前已上線的程式改搭配Agentflow的流程引擎來實作,但說實在的...參考文件少的可憐...XD
那就將自己的心得集結分享吧!
不多說,就來看怎麼由外部的 Web App 來呼叫 Agentflow 吧!(因為他們是Pure Java的開發團隊,所以要他們擠 .Net的範例...)
Step 1.
請先參考
Agentflow WebService 整合方案 JDK 5文件將 Apache/Tomcat的WebServices 環境建立起來
http://forum.flowring.com/user/download/2365/AgentflowWebService%20%E6%95%B4%E5%90%88JDK5.pdf
先下載 axis Packages http://ws.apache.org/axis
設定環境變數
- AXIS_HOME=D:\axis14
- AXIS_LIB=%AXIS_HOME%\lib
- AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\axis-ant.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar
- JAVA_HOME=即為使用者的 Java
- path=%使用者的 path%;%JAVA_HOME%\bin
- CLASSPATH=.;JAVA_HOME%\lib\tools.jar%;%AXISCLASSPATH%
修改 WebAgenda/WEB-INF/web.xml 檔案,加入幾項 servlet mapping 如下:
- <! - - 定義目前 AxisServlet 執行之 Class -- >
- <servlet>
- <servlet-name>AxisServlet</servlet-name>
- <display-name>Apache-Axis Servlet</display-name>
- <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
- </servlet>
- <! - - 定義目前執行 Web Service 檔案目錄或副檔名 -- >
- <servlet-mapping>
- <servlet-name>AxisServlet</servlet-name>
- <url-pattern>*.jws</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>AxisServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>AxisServlet</servlet-name>
- <url-pattern>/servlet/AxisServlet</url-pattern>
- </servlet-mapping>
- < -- 定義 mime 的 mapping 以讓 Browser 能夠了解所傳回的資訊 -- >
- <mime-mapping>
- <extension>wsdl</extension>
- <mime-type>text/xml</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>xsd</extension>
- <mime-type>text/xml</mime-type>
- </mime-mapping>
設定好後,要重新啟動Tomcat
並且測試一下 WSDL文件是否可以產生
http://127.0.0.1:8080/WebAgenda/webservice/AgentflowWeb.jws
出現
There is a Web Service here
即表示OK
http://127.0.0.1:8080/WebAgenda/webservice/AgentflowWeb.jws?wsdl
可以看 Web Service 內容
Step 2.
開啟 Visual Studio建立一個 Web 專案,加入 Web 參考
輸入 WebServices wsdl url http://127.0.0.1:8080/WebAgenda/webservice/AgentflowWeb.jws?wsdl
按移至
即可找到 Web Service的位置,給定名稱後,加入參考即可使用
Step 3.
撰寫一支WebForm,於Page_Load中寫一段測試馬,來測試看看是否可以呼叫並啟動流程
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Dim service As AFWebReference.AgentflowWebService
- Dim serviceURL As String = "http://127.0.0.1:8080/WebAgenda/webservice/AgentflowWeb.jws"
- Dim cRet As String
- Try
- service = New AFWebReference.AgentflowWebService()
- Dim arr(1) As Object
- Dim aKey(4) As String
- Dim aVal(4) As String
- aKey(0) = "arg1"
- aKey(1) = "arg2"
- aKey(2) = "arg3"
- aKey(3) = "arg4"
- aKey(4) = "arg5"
- aVal(0) = "val1"
- aVal(1) = "val2"
- aVal(2) = "val3"
- aVal(3) = "val4"
- aVal(4) = "val5"
- arr(0) = aKey
- arr(1) = aVal
- cRet = service.createProcess("MEMxxxxxxxxxxxxxxxxx", "PROxxxxxxxxxxxxxxxxx", arr)
- If cRet <> "" Then
- Response.Write(cRet)
- End If
- Catch ex As Exception
- Response.Write(ex.Message)
- End Try
- End Sub
Step 4.
張貼留言