如何在Mule Flow中使用SOAP Web服务? [英] How to consume a SOAP web service in a Mule Flow?

查看:79
本文介绍了如何在Mule Flow中使用SOAP Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Mule流程开始,已经看过我已经看过此页面 http://www.mulesoft.org/documentation/display/MULE3CONCEPTS/使用+ Mule + with + Web +服务

I am beginning with Mule flows and have seen the I have seen this page http://www.mulesoft.org/documentation/display/MULE3CONCEPTS/Using+Mule+with+Web+Services and http://www.mulesoft.org/documentation/display/MULEWS/Consuming+SOAP+Web+Services+in+Mule this oe too. They were not of much help. Currently, I have a simple mule flow as shown below.

流定义

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <flow name="EchoFlow" doc:name="EchoFlow">
        <http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8081" path="service/echoflow" doc:name="HTTP" />
        <cxf:jaxws-client operation="" serviceClass="com.myapp.demo.ServiceAImplService" 
            doc:name="SOAP"/>
        <outbound-endpoint address="http://localhost:8080/ServiceA/services/" doc:name="Generic"/>
    </flow>
</mule>

我正在使用Mule studio.有一个HTTP入站终结点,它期望得到响应.我尝试配置一个jax-ws客户端,它将调用实际的Web服务.该服务的WSDL为:

I am using Mule studio. There is an HTTP inbound endpoint that expects a response. I tried configuring a jax-ws client which will call the actual web service. The WSDL for the service is:

wsdl文件

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="ServiceAImplService" targetNamespace="http://service.demo.myapp.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import namespace="http://service.demo.myapp.com/" schemaLocation="http://localhost:8080/ServiceA/services/ServiceAImplPort?xsd=serviceaimpl_schema1.xsd"/>
</schema>
  </wsdl:types>
  <wsdl:message name="helloResponse">
    <wsdl:part element="tns:helloResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="hello">
    <wsdl:part element="tns:hello" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IServiceA">
    <wsdl:operation name="hello">
      <wsdl:input message="tns:hello" name="hello">
    </wsdl:input>
      <wsdl:output message="tns:helloResponse" name="helloResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ServiceAImplServiceSoapBinding" type="tns:IServiceA">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="hello">
      <soap:operation soapAction="urn:Hello" style="document"/>
      <wsdl:input name="hello">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="helloResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ServiceAImplService">
    <wsdl:port binding="tns:ServiceAImplServiceSoapBinding" name="ServiceAImplPort">
      <soap:address location="http://localhost:8080/ServiceA/services/ServiceAImplPort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

如您所见,我不太确定要配置jax-ws客户端.因此,在此流程中我究竟如何使用SOAP Web服务.

I am not too sure about configuring a jax-ws client as you can see. So, how exactly do I consume a SOAP web service in this flow.

我的第二个问题:如何转换有效载荷以从一个Web服务调用到另一个Web服务(均为SOAP).会怎样?

My second question: How do I transform the payload to make a call from one web-service to another web-service (both SOAP). What will be the flow?

最后,如何合并有效载荷?说,我有三个并行调用的Web服务,它们的响应都一起返回.如何合并有效负载,以便可以在另一个服务中读取它(合并来自并行调用的多个服务的响应之后)?

And finally, how do I merge payloads? Say, I have three web services called in parallel and their responses all return together. How do I merge the payloads so that I can read it in another service (after combining the responses from multiple services called in parallel)?

什么是

       <pattern:web-service-proxy name="ex-proxy"
        inboundAddress="http://localhost:8081/xxx"
        outboundAddress="http://xx.xx.com/XXX_WS/xxxWService.asmx" /> 

使用CXF代理服务/客户端?这给我带来了另一个问题,何时使用CXF服务以及何时使用CXF客户端?最后,是否有关于Mule Flow Orchestration的详细文档或示例/教程?

using CXF proxy service/client? And that brings me to another question, when to use CXF-service and when to use CXF-client? And lastly, is there a detailed documentation or example/tutorial for Mule Flow Orchestration?

推荐答案

尝试使用CXF代理(服务和客户端).在这种情况下,您将把原始XML放入流中.当然,如果需要,您可以将其反序列化为Java,例如通过XML到对象转换器(XStream).

Try using a CXF proxy (service and client). In this case, you will get the raw XML into the flow. Of course you can deserialize it to java if you need to, for instance via XML-To-Object transformer (XStream).

http://www.mulesoft.org/文档/显示/MULE3USER/Proxying + Web + Services + with + CXF

从那里开始,有几种方法可以在中间转换有效负载.通过Java(如上所述)转换Java层对象或编写执行转换的XSLT工作表,或者使用Java和/或Mule提供的其他工具(脚本,xpath等)转换XML.

From there, there are several ways to do transform the payload in the middle. Either go through java (as mentioned above) and transform java layer objects or write an XSLT sheet that does the transformation.Or transform the XML using Java and/or the other tools Mule provides (scripting, xpath etc).

您可能想再次详细说明聚合情况.您要合并响应以供将来使用还是要进行一个Web服务调用->扇出->汇总->响应?

You might want to explain the aggregation case once more in details. Do you want to merge the responses for future use or have one web service call -> fan out -> aggregate -> response?

这篇关于如何在Mule Flow中使用SOAP Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆