加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

mule发布调用webservice

发布时间:2020-12-16 21:40:52 所属栏目:安全 来源:网络整理
导读:????????????????????????????????????????????????????????????????????????????????????????????????????????????????????mule发布webservice ????????使用mule esb消息总线发布和调用webservice都非常精简,mule包装了所有操作,你只需要拖控件配置就可以
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????mule发布webservice

????????使用mule esb消息总线发布和调用webservice都非常精简,mule包装了所有操作,你只需要拖控件配置就可以,下面讲解mule发布:

????????????????1.下面是flow,http监听接口,CXF发布webservice,java用来引用webservice的方法。

????????????????

????????????????2.xml代码如下:

????<flow?name="webService">
????	<http:listener?config-ref="HTTP_Listener_Configuration"?path="hello"?doc:name="HTTP"/>
????	<cxf:jaxws-service?serviceClass="com.test.HelloWorld"?doc:name="CXF"/>
????	<component?class="com.test.HelloWorldImpl"?doc:name="Java"/>
????</flow>

?????????????????3.java代码如下:

????????????????????①Impl实现类

package?com.test;

import?javax.jws.WebService;

@WebService(endpointInterface?=?"com.test.HelloWorld",??
serviceName?=?"HelloWorld")
public?class?HelloWorldImpl?implements?HelloWorld{

	@Override
	public?String?sayHi(String?text)?{
		//?TODO?Auto-generated?method?stub
		return?"Hello?"?+?text;??
	}

}

????????????????????? ②Impl实现类

package?com.test;

import?javax.jws.WebService;

@WebService(endpointInterface?=?"com.test.HelloWorld",??
serviceName?=?"HelloWorld")
public?class?HelloWorldImpl?implements?HelloWorld{

	@Override
	public?String?sayHi(String?text)?{
		//?TODO?Auto-generated?method?stub
		return?"Hello?"?+?text;??
	}

}

????????????????4.Java控件引用Class Name: com.test.HelloWorldImpl。


启用mule服务,访问http://localhost:8080/api/hello?wsdl?结果如下:

????至此,发布成功。


????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????mule请求webservice

????????????使用mule esb请求webservice非常简单,只需要使用Web Service Consumer控件就可以,下面讲解请求webservice:

????????????????1.下面是flow,http请求监听接口,Web Service Consumer调用接口,Set Payload传递参数。

????????????????????

?????????????????2.请求webservice需要使用一个工具来拼装请求的body:SoapUI-5.2.1.exe,下载链接在附件,使用方法如下:

????????????????????????

????????????????????我们只需要<soap:Body>里面的参数,需要把xmlns:web="http://Mozi.com/Webservices/"? 粘贴到<web:PostPatientRequest> 请求里,如下:

????????????????????<web:PostPatientRequest xmlns:web="http://Mozi.com/Webservices/">

????????????????? ? ? ? ?<!--Optional:?里面是你的参数-->

????????????????? ? ? ? ?<web:requestContent>?</web:requestContent>

????????????????? ?</web:PostPatientRequest>

?????????????????3.xml代码如下:

??<http:listener-config?name="HTTP_Listener_Configuration8081"?host="localhost"?port="8081"?doc:name="HTTP?Listener?Configuration"/>
????<ws:consumer-config?name="Web_Service_Consumer"?wsdlLocation="http://localhost:8080/api/hello?wsdl"?service="HelloWorldService"?port="HelloWorldPort"?serviceAddress="http://localhost:8080/api/hello"?doc:name="Web?Service?Consumer"/>
????<flow?name="customerFlow">
????????<http:listener?config-ref="HTTP_Listener_Configuration8081"?path="/webService"?doc:name="HTTP"/>
????????<set-payload?value="??????&lt;web:PostPatientRequest??xmlns:web=&quot;http://Mozi.com/Webservices/&quot;&gt;
?????????&lt;web:requestContent&gt;#[json:]&lt;/web:requestContent&gt;
??????&lt;/web:PostPatientRequest&gt;"?doc:name="Set?Payload"?encoding="UTF-8"?mimeType="application/xml"/>
????????<ws:consumer?config-ref="Web_Service_Consumer"?operation="sayHi"?doc:name="Web?Service?Consumer"/>
????????<json:xml-to-json-transformer?doc:name="XML?to?JSON"/>
????</flow>

?????????????????至此,请求webservice发布成功!? ?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读