5.2 請求-響應方式
請求-響應方式即請求方調用服務後,服務立即處理並返回響應結果,不需將消息再次傳遞。
圖 Request-Response
請求-響應方式通過input endpoint的exchange-pattern=”request-response”實現,相應配置如下:
<model name="services">
<service name="echoService">
<inbound>
<inbound-endpoint address="http://localhost:7007/services/Echo"
exchange-pattern="request-response">
<cxf:jaxws-service />
</inbound-endpoint>
</inbound>
<component>
<singleton-object class="demo.mule.umo.Echo" />
</component>
</service>
</model>
上邊是通過service配置的,通過flow配置如下:
<flow name="EchoFlow"> <inbound-endpoint address="http://localhost:7007/services/Echo" exchange-pattern="request-response" /> <cxf:jaxws-service serviceClass="demo.mule.umo.Echo" /> <component> <singleton-object class="demo.mule.umo.Echo" /> </component> </flow>
在瀏覽器中輸入“http://localhost:7007/services/Echo/echo/text/hello,world”,瀏覽器中會顯示“hello,world”的輸出信息。
請求-響應方式適用於單次服務調用的場景。