亚洲综合无码AV一区二区,亚洲国产AV无码专区亚洲AV,亚洲另类精品xxxx人妖http://www.tkk7.com/libin2722/category/41752.html虛其心,可解天下之問;專其心,可治天下之學;靜其心,可悟天下之理;恒其心,可成天下之業。zh-cnThu, 24 Sep 2009 03:41:02 GMTThu, 24 Sep 2009 03:41:02 GMT60mule2.1.2 初步認識 發布cxf 和axis服務http://www.tkk7.com/libin2722/articles/296106.html禮物禮物Wed, 23 Sep 2009 01:05:00 GMThttp://www.tkk7.com/libin2722/articles/296106.htmlhttp://www.tkk7.com/libin2722/comments/296106.htmlhttp://www.tkk7.com/libin2722/articles/296106.html#Feedback0http://www.tkk7.com/libin2722/comments/commentRss/296106.htmlhttp://www.tkk7.com/libin2722/services/trackbacks/296106.html配置文件:mule_config.xml
Java代碼 復制代碼
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. <mule?xmlns="http://www.mulesource.org/schema/mule/core/2.1"??
  3. ??????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
  4. ??????xmlns:spring="http://www.springframework.org/schema/beans"??
  5. ??????xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.1"??
  6. ??????xmlns:cxf="http://www.mulesource.org/schema/mule/cxf/2.1"??
  7. ??????xmlns:axis="http://www.mulesource.org/schema/mule/axis/2.1"??
  8. ??????xmlns:smtps="http://www.mulesource.org/schema/mule/smtps/2.1"??
  9. ??????xmlns:http="http://www.mulesource.org/schema/mule/http/2.1"??
  10. ??????xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.1"??
  11. ??????xmlns:soap="http://www.mulesource.org/schema/mule/soap/2.1"??
  12. ??????xsi:schemaLocation=" ??
  13. ???????????????http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-2.5.xsd ??
  14. ???????????????http://www.mulesource.org/schema/mule/core/2.1?http://www.mulesource.org/schema/mule/core/2.1/mule.xsd ??
  15. ???????????????http://www.mulesource.org/schema/mule/stdio/2.1?http://www.mulesource.org/schema/mule/stdio/2.1/mule-stdio.xsd ??
  16. ???????????????http://www.mulesource.org/schema/mule/vm/2.1?http://www.mulesource.org/schema/mule/vm/2.1/mule-vm.xsd ??
  17. ???????????????http://www.mulesource.org/schema/mule/cxf/2.1?http://www.mulesource.org/schema/mule/cxf/2.1/mule-cxf.xsd ??
  18. ???????????????http://www.mulesource.org/schema/mule/axis/2.1?http://www.mulesource.org/schema/mule/axis/2.1/mule-axis.xsd ??
  19. ???????????????http://www.mulesource.org/schema/mule/smtps/2.1?http://www.mulesource.org/schema/mule/smtps/2.1/mule-smtps.xsd ??
  20. ???????????????http://www.mulesource.org/schema/mule/soap/2.1?http://www.mulesource.org/schema/mule/soap/2.1/mule-soap.xsd ??
  21. ???????????????http://www.mulesource.org/schema/mule/http/2.1?http://www.mulesource.org/schema/mule/http/2.1/mule-http.xsd ??
  22. ???????????????"> ??
  23. ?????<description> ??
  24. ????????eagleMule?demo?which?shows?how?to?publish?web?services?over?CXF. ??
  25. ????</description> ??
  26. ????<model?name="eagleMule"> ??
  27. ?????????<service?name="testMuleService"> ??
  28. ????????????<inbound> ??
  29. ????????????????<axis:inbound-endpoint?address="http://localhost:8899/services/testMuleService"> ??
  30. ????????????????????<soap:http-to-soap-request-transformer?/> ??
  31. ????????????????</axis:inbound-endpoint> ??
  32. ????????????????<cxf:inbound-endpoint?address="http://localhost:8898/services/testMuleService"> ??
  33. ????????????????????<soap:http-to-soap-request-transformer?/> ??
  34. ????????????????</cxf:inbound-endpoint> ??
  35. ????????????</inbound> ??
  36. ????????????<component?class="com.eagle.mule.test.imp.MuleServiceImp"> ??
  37. ????????????</component> ??
  38. ????????</service> ??
  39. ????</model> ??
  40. ????</mule>??

一個簡單的 接口 為了先跑同就這樣把。
MuleService.java
Java代碼 復制代碼
  1. ?@WebService??
  2. public?interface?MuleService?{ ??
  3. public?String?testMule(@WebParam(name="str")String?str); ??
  4. }??

MuleServiceImp.java
Java代碼 復制代碼
  1. @WebService(serviceName="eagleMuleService", ??
  2. ??????????endpointInterface="com.eagle.mule.test.MuleService") ??
  3. public?class?MuleServiceImp?implements?MuleService?{ ??
  4. ??
  5. ????public?String?testMule(String?str)?{ ??
  6. ????????System.out.println("----service---"); ??
  7. ????????return?"hello--"+str; ??
  8. ????} ??
  9. }??

啟動服務:
Java代碼 復制代碼
  1. public?class?EagleMuleMain?{ ??
  2. ????public?static?void?main(String[]?args)?throws?ConfigurationException,?InitialisationException?{ ??
  3. ????????try?{ ??
  4. ????????????String?configFile?=?"com/eagle/mule/test/mule_config.xml"; ??
  5. ????????????String[]?configFileArr?=?new?String[]?{?configFile?}; ??
  6. ????????????MuleContextFactory?muleContextFactory?=?new?DefaultMuleContextFactory(); ??
  7. ????????????MuleContext?context?=?muleContextFactory ??
  8. ????????????????????.createMuleContext(new?SpringXmlConfigurationBuilder( ??
  9. ????????????????????????????configFileArr)); ??
  10. ????????????context.start(); ??
  11. ????????}?catch?(MuleException?t)?{ ??
  12. ????????????t.printStackTrace(); ??
  13. ????????} ??
  14. ????} ??
  15. }??

測試
Java代碼 復制代碼
  1. package?com.eagle.mule.test.clint; ??
  2. ??
  3. import?java.io.IOException; ??
  4. import?java.io.InputStream; ??
  5. ??
  6. import?org.apache.commons.io.IOUtils; ??
  7. import?org.mule.api.MuleException; ??
  8. import?org.mule.api.MuleMessage; ??
  9. import?org.mule.module.client.MuleClient; ??
  10. ??
  11. public?class?Client?{ ??
  12. ????public?static?void?main(String[]?args){ ??
  13. ????????MuleClient?client?=?null;? ??
  14. ????????try?{ ??
  15. ????????????client?=?new?MuleClient(); ??
  16. ????????????String?url?=?"axis:http://localhost:8899/services/testMuleService/testMuleService?method=testMule"; ??
  17. ??
  18. ????????????MuleMessage?message?=?client.send(url,?"eagle",?null); ??
  19. ????????????Object?obj?=?message.getPayload(); ??
  20. ????????????System.out.println("--------------obj---------"+obj.getClass().getName()); ??
  21. ????????????if(obj?instanceof?String){ ??
  22. ????????????????System.out.println("---------str--------------"+obj); ??
  23. ????????????} ??
  24. ????????}?catch?(MuleException?e)?{ ??
  25. ????????????//?TODO?Auto-generated?catch?block ??
  26. ????????????e.printStackTrace(); ??
  27. ????????}finally{ ??
  28. ????????????client.dispose(); ??
  29. ????????} ??
  30. ??
  31. ????} ??
  32. } ??
  33. 注意?這里需要把mule?下lib中?endorsed??mule??opt?文件夾中的jar都加進去。如果不發布cxf的服務?可以不用添加endorsed文件夾中的jar。?


禮物 2009-09-23 09:05 發表評論
]]>
開源ESB引擎Mule初印象http://www.tkk7.com/libin2722/articles/295695.html禮物禮物Sat, 19 Sep 2009 14:20:00 GMThttp://www.tkk7.com/libin2722/articles/295695.htmlhttp://www.tkk7.com/libin2722/comments/295695.htmlhttp://www.tkk7.com/libin2722/articles/295695.html#Feedback0http://www.tkk7.com/libin2722/comments/commentRss/295695.htmlhttp://www.tkk7.com/libin2722/services/trackbacks/295695.html關鍵字: ESB SOA WebService Mule
Mule is the leading open source ESB (Enterprise Service Bus) and integration platform. It is a scalable, highly distributable
object broker that can seamlessly handle interactions with services and applications using disparate transport and messaging
technologies。

在這里我們簡單看看如何用Mule發布和調用Web服務,體驗一下Mule的簡潔和高效。

安裝Mule
Mule官方下載頁下載最新的Full版zip文件,解壓到一個目錄。
運行一下MULE_HOME\examples\maven\echo目錄下的echo.bat,則mule會自動下載合適版本的activation.jar和mail.jar到MULE_HOME\lib\user目錄
echo.bat示例了一個command prompt下的echo程序,該程序會echo你在命令行輸入的字符串。

創建Eclipse項目
我們在Eclipse下新建命名為mule的Java project,其中包結構如下:
Java代碼 復制代碼
  1. mule ??
  2. ??src-demo ??
  3. ????cn.hidetoishandsome.mule.demo ??
  4. ??????EchoService.java ??
  5. ??????IEchoService.java ??
  6. ??images ??
  7. ????mule-banner.gif ??
  8. ??WEB-INF ??
  9. ????lib ??
  10. ????mule-echo-config.xml ??
  11. ????web.xml ??
  12. ??contents.html ??
  13. ??echo.jsp ??
  14. ??header.html ??
  15. ??index.html ??
  16. ??welcome.html??

將MULE_HOME\lib\mule目錄和MULE_HOME\lib\opt目錄下所有的jar包以及MULE_HOME\lib\user目錄下的activation.jar和mail.jar統統扔到WEB-INF\lib目錄下。
其中mule-banner.gif、contents.html、header.html、index.html、welcome.html等來自將MULE_HOME\examples\ant\webapp目錄下的build.xml用ant
build后在build目錄下生成的mule-example-webapp.war中的文件。
在這里我們修改該mule-example-webapp.war工程來demo一下使用Mule發布和調用Web服務。

寫我們要發布的服務
上面列出的IEchoService.java為我們要發布的服務的接口,該接口約束了我們要發布的服務:
Java代碼 復制代碼
  1. package?cn.hidetoishandsome.mule.demo; ??
  2. ??
  3. public?interface?IEchoService?{ ??
  4. ????String?echo(String?s); ??
  5. ??
  6. ????String?haha(String?s); ??
  7. }??

如上,我們將使用該接口發布echo和haha這兩個服務。現在寫我們的服務實現類EchoService.java(系統集成時可能實現已經存在,我們只需抽離要
發布的服務的窄接口即可):
Java代碼 復制代碼
  1. package?cn.hidetoishandsome.mule.demo; ??
  2. ??
  3. public?class?EchoService?implements?IEchoService?{ ??
  4. ??
  5. ????public?String?echo(String?s)?{ ??
  6. ????????return?"Hello,?"?+?s?+?"!"; ??
  7. ????} ??
  8. ??
  9. ????public?String?haha(String?s)?{ ??
  10. ????????return?"haha"; ??
  11. ????} ??
  12. ??
  13. ????public?String?hehe(String?s)?{ ??
  14. ????????return?"hehe"; ??
  15. ????} ??
  16. }??

可以看到,雖然我們的EchoService提供了echo/haha/hehe三個服務,但我們使用IEchoService來約束它,從而只發布其中的echo和haha這兩個服務。

配置使我們的服務以Web Service發布
首先我們修改web.xml來讓servlet容器listen和mapping一些東西:
Java代碼 復制代碼
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. <!DOCTYPE?web-app?PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"?"http://java.sun.com/dtd/web-app_2_3.dtd"> ??
  3. <web-app> ??
  4. ????<display-name>Mule</display-name> ??
  5. ????<description>Mule?Demo</description> ??
  6. ??
  7. ????<context-param> ??
  8. ????????<param-name>org.mule.config</param-name> ??
  9. ????????<param-value>/WEB-INF/mule-echo-config.xml,</param-value> ??
  10. ????</context-param> ??
  11. ??
  12. ????<listener> ??
  13. ????????<listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class> ??
  14. ????</listener> ??
  15. ??
  16. ????<servlet> ??
  17. ????????<servlet-name>muleServlet</servlet-name> ??
  18. ????????<servlet-class>org.mule.providers.http.servlet.MuleReceiverServlet</servlet-class> ??
  19. ????????<load-on-startup/> ??
  20. ????</servlet> ??
  21. ??
  22. ????<servlet-mapping> ??
  23. ????????<servlet-name>muleServlet</servlet-name> ??
  24. ????????<url-pattern>/services/*</url-pattern> ??
  25. ????</servlet-mapping> ??
  26. ??
  27. ????<welcome-file-list> ??
  28. ????????<welcome-file>index.html</welcome-file> ??
  29. ????</welcome-file-list> ??
  30. </web-app>??

然后我們配置mule-echo-config.xml來以Web Service方式發布我們的服務:
Java代碼 復制代碼
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. ??
  3. <!DOCTYPE?mule-configuration?PUBLIC?"-//MuleSource?//DTD?mule-configuration?XML?V1.0//EN"??
  4. ????????????????????????????????"http://mule.mulesource.org/dtds/mule-configuration.dtd"> ??
  5. ??
  6. <mule-configuration?id="Mule_Demo"?version="1.0"> ??
  7. ????<mule-descriptor?name="echoService"?implementation="cn.hidetoishandsome.mule.demo.EchoService"> ??
  8. ????????<inbound-router> ??
  9. ????????????<endpoint?address="xfire:http://localhost:8181/services"/> ??
  10. ????????</inbound-router> ??
  11. ????????<properties>?? ??
  12. ????????????<list?name="serviceInterfaces">??? ??
  13. ????????????????<entry?value="cn.hidetoishandsome.mule.demo.IEchoService"/>??? ??
  14. ????????????</list>?? ??
  15. ????????</properties>?? ??
  16. ???</mule-descriptor> ??
  17. </mule-configuration>??

這里我們的echoService實現為cn.hidetoishandsome.mule.demo.EchoService,inbound-router中<endpoint address="xfire:http://localhost:8181/services"/>表示我們以xfire發布我們的服務到本機該端口的services這個context下,而serviceInterfaces的entry表示我們使用IEchoService
來約束我們要發布的服務接口。

運行和調用服務
讓我們將該mule項目在Tomcat中跑起來看看效果吧。
例如配置Tomcat的server.xml,在<Host>標簽中加入<Context path="/mule" docBase="D:\project\mule" reloadable="true" />
啟動Tomcat,打開瀏覽器訪問http://localhost:8181/services/echoService?wsdl可以看到Mule通過xfire自動生成的wsdl文檔,其中
我們可以看到Mule只暴露了EchoService和echo和haha方法,而沒有暴露hehe方法。
現在我們在echo.jsp中利用Mule的UMO(Universal Message Object)API寫對我們剛發布的Web服務的客戶端調用:
Java代碼 復制代碼
  1. <%@?page?import="org.mule.extras.client.MuleClient,?org.mule.umo.UMOMessage"%> ??
  2. <%@?page?language="java"?contentType="text/html;?charset=UTF-8"?%> ??
  3. ??
  4. <html> ??
  5. <head> ??
  6. <title>Mule?Echo?Example</title> ??
  7. </head> ??
  8. <body> ??
  9. <% ??
  10. ????String?s?=?request.getParameter("name"); ??
  11. ????if(s!=null)?{ ??
  12. ????????MuleClient?client?=?new?MuleClient(); ??
  13. ????????UMOMessage?message?=?client.send("xfire:http://localhost:8181/services/echoService?method=echo",?s,?null);?? ??
  14. %> ??
  15. <h3><%=message.getPayload()%></h3> ??
  16. ?????<%}%> ??
  17. Please?enter?your?name: ??
  18. <form?method="POST"?name="submitEcho"?action=""> ??
  19. ????<table> ??
  20. ????????<tr><td> ??
  21. ????????????<input?type="text"?name="name"/></td><td><input?type="submit"?name="Go"?value="?Go?"?/> ??
  22. ????????</td></tr> ??
  23. ????</table> ??
  24. </form> ??
  25. <p/> ??
  26. </body> ??
  27. </html>??

好了,用瀏覽器訪問http://localhost:8080/mule并點擊左側菜單的Echo鏈接,或者直接訪問http://localhost:8080/mule/echo.jsp,然后在input框輸入一些文本內容如"Hideto",點擊Go,則你會看到頁面返回"Hello, Hideto!"。
現在讓我們修改echo.jsp,將UMOMessage message = client.send("xfire:http://localhost:8181/services/echoService?method=echo", s, null);
這段代碼中的method改為haha,即:
Java代碼 復制代碼
  1. UMOMessage?message?=?client.send("xfire:http://localhost:8181/services/echoService?method=haha",?s,?null);??

然后刷新一下瀏覽器頁面,再輸入一些文本內容,看看頁面是不是返回"haha"字樣了?


禮物 2009-09-19 22:20 發表評論
]]>
Using the Web Service Wrapper on Mule2.xhttp://www.tkk7.com/libin2722/articles/295692.html禮物禮物Sat, 19 Sep 2009 13:53:00 GMThttp://www.tkk7.com/libin2722/articles/295692.htmlhttp://www.tkk7.com/libin2722/comments/295692.htmlhttp://www.tkk7.com/libin2722/articles/295692.html#Feedback0http://www.tkk7.com/libin2722/comments/commentRss/295692.htmlhttp://www.tkk7.com/libin2722/services/trackbacks/295692.html Using the Web Service Wrapper

The WebServiceWrapperComponent class allows you to send the result of a web service call to another endpoint. The web service call is performed within WebServiceWrapperComponent, providing the following advantages:

  • You can set any type of router on inbound and outbound.
  • Unlike the chaining router, it can send more than one HTTP request at a time
  • The URL for the web service call can be changed at run-time by sending the URL with the message

Configuring the Web Service Wrapper

To use the web service wrapper, you specify the <wrapper-component> configuration element. The following table describes the attributes you can set for this element. These attributes are described in more detail in the examples that follow.

Attribute Description Required?
address Specifies the URL of the web service to call Yes, unless addressFromMessage is set to true
addressFromMessage (default is false) Specifies that the URL of the web service will be obtained from the message itself Not required if address is set
wrapperProperties The SOAP document style, expressed as a map of two properties: style, which can be set to RPC (the default), Document, Message, or Wrapped, and use, which can be Encoded or Literal. No
<soap-method> A SOAP method to call (see Configuring SOAP Methods below) No

The web service wrapper is generic and can be used with any type of web service stack supported by Mule, including Axis and CXF. The examples below show synchronous use cases, but the web service wrapper can also support an asynchronous use case like the loan broker example.

Example Configuration Using the CXF Transport

Consider the following example. The web service wrapper is configured as a Mule component, accepting messages from a VM endpoint. A call must be made to a web service on the URL cxf:http://localhost:65081/services/TestUMO?method=onReceive and the result must be sent to the outbound endpoint vm://testout.

The inbound and outbound endpoints are configured in the usual way. The address is set as an attribute on the component, specifying the web service URL that you want to call.

								<cxf:connector name="cxf" defaultFrontend="simple" />
								<model name="Sample">
								<service name="WebServiceSample">
								<inbound>
								<vm:inbound-endpoint path="testin" />
								</inbound>
								<cxf:wrapper-component address="http://localhost:65081/services/TestUMO?method=onReceive"/>
								<outbound>
								<pass-through-router>
								<outbound-endpoint address="vm://testout"/>
								</pass-through-router>
								</outbound>
								</service>
						

Example Configuration Using the addressFromMessage Property

The "address" property is ideal to use when the web service URL for the web service is known at configuration time. However, if this URL is either not known or else needs to be changed at run-time, the "address" property can be omitted and the "adddressFromMessage" property can be set to true. The following example shows this configuration:

								<service name = "WebServiceSample2">
								<inbound>
								<vm:inbound-endpoint path = "testin2"/>
								</inbound>
								<cxf:wrapper-component addressFromMessage = "true"/>
								</service>
						

The URL must be set on the message with the property name "ws.service.url".

Configuring SOAP Methods

CXF endpoints are fairly easy to configure, whereas Axis needs some further configuration to set SOAP methods. You can set a SOAP method using the <soap-method> element as shown below:

								<service name = "WebServiceSample3">
								<inbound>
								<vm:inbound-endpoint path = "queue.in" connector-ref = "VMQueue"/>
								</inbound>
								<axis:wrapper-component address = "http://localhost:62088/axis/Calculator?method=add" style = "WRAPPED" use = "LITERAL">
								<axis:soap-method method = "qname{add:http://muleumo.org/Calc}">
								<axis:soap-parameter parameter = "Number1" type = "int" mode = "IN"/>
								<axis:soap-parameter parameter = "Number2" type = "int" mode = "IN"/>
								<axis:soap-return type = "int"/>
								</axis:soap-method>
								</axis:wrapper-component>
								<outbound>
								<pass-through-router>
								<vm:outbound-endpoint path = "queue.out" connector-ref = "VMQueue"/>
								</pass-through-router>
								</outbound>
								</service>
						


禮物 2009-09-19 21:53 發表評論
]]>
Mule web service調用中的復雜類型傳遞http://www.tkk7.com/libin2722/articles/295689.html禮物禮物Sat, 19 Sep 2009 12:42:00 GMThttp://www.tkk7.com/libin2722/articles/295689.htmlhttp://www.tkk7.com/libin2722/comments/295689.htmlhttp://www.tkk7.com/libin2722/articles/295689.html#Feedback0http://www.tkk7.com/libin2722/comments/commentRss/295689.htmlhttp://www.tkk7.com/libin2722/services/trackbacks/295689.html
? 官網上很辛苦在一個旮旯里找到如何向 Mule暴露的axis web service 傳遞復雜數據類型 ,http://www.mulesource.org/pages/viewpage.action?pageId=4678, 官網上只提供了原理,自己補充了一下客戶端測試代碼,部分服務類做了修改。
???
? 類清單:
? Person: 數據類,測試復雜數據類型的傳遞
? PersonService: 服務接口類
? PersonServiceImpl: 服務實現類。
? PersonServiceLaucher: Mule服務器啟動類
? PersonClient: 客戶端測試類。
? person-config.xml, Mule 配置,其中將 PersonServiceImpl 暴露為一個axis1.4的服務。

1. Person數據類
Java代碼 復制代碼
  1. ? public ? class ?Person? ??
  2. ??{ ??
  3. private ?String?name; ??
  4. private ?String?surname; ??
  5. private ?Date?registerDate?=? new ?Date(); ??
  6. private ? int ?age?=? 20 ; ??
  7. ???...??


2.? 服務接口類
Java代碼 復制代碼
  1. ?public?interface?PersonService?{??? ??
  2. String?printPerson(Person?person)?;? ??
  3. Person?createPerson(String?name,String?surname,int?age);???? ??
  4. ????Person[]?batchCreatePerson(String?namePattern); ??
  5. ?}??


3. 實現類:
Java代碼 復制代碼
  1. package?demo.mule.person; ??
  2. ??
  3. public?class?PersonServiceImpl?implements?PersonService?{ ??
  4. ????public?String?printPerson(Person?person)?{?????? ??
  5. ????????return?"person:name="?+?person.getName()?+",surname="?+?person.getSurname(); ??
  6. ????} ??
  7. ???? ??
  8. ????/** ?
  9. ?????*?test?return?a?complex?type?by?web?service ?
  10. ?????*/??
  11. ????public?Person?createPerson(String?name,?String?surname,int?age)?{ ??
  12. ????????Person?p?=?new?Person(name,surname); ??
  13. ????????p.setAge(age); ??
  14. ????????System.out.println("a?person?is?created:"?+?p.getName()); ??
  15. ????????return?p; ??
  16. ????} ??
  17. ???? ??
  18. ????public?Person[]?batchCreatePerson(String?namePattern)?{ ??
  19. ????????Person[]?persons?=?new?Person[3]; ??
  20. ????????for?(int?i?=?0;?i?<?persons.length;?i++)?{ ??
  21. ????????????Person?p?=?new?Person(namePattern?+?i,namePattern?+?i); ??
  22. ????????????p.setAge(?20?+?i?); ??
  23. ????????????persons[i]?=?p; ??
  24. ????????} ??
  25. ????????return?persons; ??
  26. ????} ??
  27. }??


4. person-config.xml
Xml代碼 復制代碼
  1. ??<?xml?version="1.0"?encoding="UTF-8"?>??
  2. <!DOCTYPE?mule-configuration?PUBLIC?"-//MuleSource?//DTD?mule-configuration?XML?V1.0//EN"?"http://mule.mulesource.org/dtds/mule-configuration.dtd">??
  3. <mule-configuration?id="mule-test"?version="1.0">??
  4. ????<model?name="personService">??
  5. ????????<!--?test:?http://localhost:8082/services/personService?method=createPerson?-->??????????? ??
  6. ????????<mule-descriptor?name="personService"?implementation="demo.mule.person.PersonServiceImpl">??
  7. ????????????<inbound-router>??
  8. ????????????????<endpoint?address="axis:http://localhost:8082/services"></endpoint>??
  9. ????????????</inbound-router>????? ??
  10. ????????????<!--?not?nessesary? ??
  11. ????????????<properties>??
  12. ????????????????<property?name="style"?value="wrapped"/>??
  13. ????????????????<property?name="use"?value="literal"/>??
  14. ????????????</properties>????? ??
  15. ????????????-->??
  16. ????????</mule-descriptor>???????????? ??
  17. ????</model>??
  18. </mule-configuration>??



5. server啟動
Java代碼 復制代碼
  1. ??public?class?PersonServiceLaucher?{ ??
  2. public?static?void?main(String[]?args)?throws?ConfigurationException?{ ??
  3. ????MuleXmlConfigurationBuilder?muleXmlConfigurationBuilder?=?new?MuleXmlConfigurationBuilder(); ??
  4. ????UMOManager?manager?=?muleXmlConfigurationBuilder.configure("demo/mule/person/person-config.xml"); ??
  5. } ??



6. 測試類
Java代碼 復制代碼
  1. ?public?class?PersonClient?{???? ??
  2. ????private?MuleClient?muleClient?;? ??
  3. ????public?PersonClient()?{ ??
  4. ????????try?{ ??
  5. ????????????muleClient?=?new?MuleClient(); ??
  6. ????????}?catch?(UMOException?e)?{?????? ??
  7. ????????????e.printStackTrace(); ??
  8. ????????} ??
  9. ????} ??
  10. ??
  11. ????public?void?testPrintPerson()?throws?Exception?{ ??
  12. ???????? ??
  13. ????????Person?person?=?new?Person("David","Jones"); ??
  14. ????????UMOMessage?msg?=?new?MuleMessage(person?); ??
  15. ????????UMOMessage?message?=?muleClient.send("axis:http://localhost:8082/services/personService?method=printPerson",msg); ??
  16. ???????? ??
  17. ????????System.out.println("message:"?+?message.getPayloadAsString()); ??
  18. ????} ??
  19. ???? ??
  20. ????public?void?testCreatePerson()?throws?Exception?{ ??
  21. ????????Object[]?args?=?new?Object[]{"小龍","李",?new?Integer(23)}; ??
  22. ????????UMOMessage?msg?=?new?MuleMessage(args?); ??
  23. ????????UMOMessage?message?=?muleClient.send("axis:http://localhost:8082/services/personService?method=createPerson",msg); ??
  24. ???? ??
  25. ????????Person?p?=?(Person)message.getPayload(); ??
  26. ????????System.out.println("message:"?+?message.getPayloadAsString()); ??
  27. ????????System.out.println("payload:"?+?p.getName()?+","?+?p.getSurname()?+","?+?p.getAge()); ??
  28. ????} ??
  29. ???? ??
  30. ????public?void?testBatchCreatePerson()?throws?UMOException?{ ??
  31. ????????Object[]?args?=?new?Object[]{"Admin"}; ??
  32. ????????UMOMessage?msg?=?new?MuleMessage(args?); ??
  33. ????????UMOMessage?message?=?muleClient.send("axis:http://localhost:8082/services/personService?method=batchCreatePerson",msg); ??
  34. ???????? ??
  35. ????????Person[]?ps?=?(Person[])message.getPayload(); ??
  36. ????????System.out.println("persons:"?+?ps.length); ??
  37. ????????for?(int?i?=?0;?i?<?ps.length;?i++)?{ ??
  38. ????????????Person?p?=?ps[i]; ??
  39. ????????????System.out.println("person:"?+?p.getName()?+","?+?p.getSurname()?+","?+?p.getAge()); ??
  40. ????????}??????? ??
  41. ????} ??
  42. ????public?static?void?main(String[]?args)?throws?Exception?{ ??
  43. ????????PersonClient?personClient?=?new?PersonClient(); ??
  44. ????????personClient.testPrintPerson(); ??
  45. ????????personClient.testCreatePerson();???????? ??
  46. ????????personClient.testBatchCreatePerson(); ??
  47. ????} ??
  48. }??



測試過程:
1) 啟動Mule服務容器
2) 執行PersonClient


總結:
? 1) Mule暴露POJO為一個服務還是很簡單的, 配置非常少
? 2) 傳遞和返回Java復雜數據類型,自定義數據類型都非常方便。不過,客戶端需要明確知道每個方法傳遞的參數個數和類型,以及返回的參數類型,并且需要自己type cast。 在具體項目中,可以自己再做一層封裝或用AOP, 以本地調用的方式調用 mule 的web service。


禮物 2009-09-19 20:42 發表評論
]]>
主站蜘蛛池模板: 直接进入免费看黄的网站| 亚洲日本VA中文字幕久久道具| 亚洲国产成人久久一区二区三区| 91av免费观看| 亚洲精品午夜久久久伊人| 久久久久久久99精品免费| 亚洲av一综合av一区| 三年片在线观看免费观看大全一| 亚洲av中文无码乱人伦在线r▽ | 亚洲熟妇av午夜无码不卡| 成人在线免费观看| 亚洲国产精品成人AV在线| 国产精品无码免费视频二三区| 亚洲AV无码一区二区三区久久精品 | 国产成人人综合亚洲欧美丁香花| 特级淫片国产免费高清视频| 色婷婷亚洲一区二区三区| jjzz亚洲亚洲女人| 国产免费人成视频尤勿视频| 国产精品亚洲A∨天堂不卡 | 日韩精品免费一线在线观看| 亚洲午夜精品久久久久久浪潮| 久久久受www免费人成| 久久被窝电影亚洲爽爽爽| 69精品免费视频| 亚洲免费福利在线视频| 亚洲一区二区在线视频| 久视频精品免费观看99| 亚洲小说图区综合在线| 又爽又高潮的BB视频免费看| 久久不见久久见免费影院www日本| 亚洲动漫精品无码av天堂| 999国内精品永久免费观看| 亚洲另类无码专区首页| 亚洲人色婷婷成人网站在线观看 | 亚洲av片不卡无码久久| 日韩精品电影一区亚洲| 久久国产精品免费专区| 亚洲另类无码专区丝袜| 亚洲国产精品SSS在线观看AV| 久久久www成人免费毛片|