综合一区自拍亚洲综合图区,久久久久亚洲AV无码专区体验,亚洲热线99精品视频http://www.tkk7.com/libin2722/category/41751.html虛其心,可解天下之問;專其心,可治天下之學;靜其心,可悟天下之理;恒其心,可成天下之業。zh-cnThu, 24 Sep 2009 03:41:03 GMTThu, 24 Sep 2009 03:41:03 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 發表評論
]]>
主站蜘蛛池模板: 免费国产叼嘿视频大全网站| kk4kk免费视频毛片| 最近免费中文在线视频| 亚洲国产精品无码久久SM| 中文字幕不卡高清免费| 在线播放亚洲第一字幕| 国产免费人成视频尤勿视频| 亚洲一区二区精品视频| jizz免费观看| 在线观看亚洲成人| 中文字幕版免费电影网站| 亚洲日韩中文字幕在线播放| a级片免费在线播放| 亚洲AV无码一区东京热久久| 美女内射无套日韩免费播放| 亚洲精品高清国产麻豆专区| 国产麻豆视频免费观看| 亚洲国产精品ⅴa在线观看| 亚洲成a人无码av波多野按摩| 九九综合VA免费看| 国产亚洲精品a在线无码| 久久A级毛片免费观看| 亚洲一区二区免费视频| 国产大片91精品免费观看男同| 羞羞的视频在线免费观看| 亚洲啪啪AV无码片| 日本人的色道免费网站| 亚洲av第一网站久章草| 最新国产AV无码专区亚洲| 亚洲电影在线免费观看| 亚洲AV无码专区亚洲AV桃| 亚洲永久精品ww47| 4399好看日本在线电影免费| 成人精品国产亚洲欧洲| 亚洲AV无码日韩AV无码导航| 成全高清视频免费观看| 怡红院免费全部视频在线视频| 亚洲欧洲久久精品| 久久久久亚洲?V成人无码| 午夜性色一区二区三区免费不卡视频| 福利片免费一区二区三区|