【问题标题】:Mule Web Service Consumer not adding SOAP wrapper properlyMule Web 服务使用者未正确添加 SOAP 包装器
【发布时间】:2016-04-29 05:54:15
【问题描述】:

我正在尝试设置一个流程,该流程涉及通过 HTTP 端点接收 JSON 有效负载,将其转换为 XML 有效负载以用于 SOAP 事务,然后转回 JSON 有效负载,就像在这个在这里演示:https://www.youtube.com/watch?v=XyZcI1_MbOo。 现在,我正在设置流程,并启动并运行 Web 服务使用者组件。在尝试调试流程时,我只是将第一次转换为 XML,将消息发送到 Web 服务使用者,然后将生成的消息写入文件。我的流程如下:

<?xml version="1.0" encoding="UTF-8"?>
 
 <mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
     xmlns:spring="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
 http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
 http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
 http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
 http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
 http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
 http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
 http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
 http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
 http://www.example.org/Transactions/">
     <http:listener-config name="HTTP_Listener_Configuration" host="10.14.5.211" port="8081" doc:name="HTTP Listener Configuration"/>
     <ws:consumer-config name="Web_Service_Consumer" wsdlLocation="Transactions.wsdl" service="Transactions" port="TransactionsSOAP" serviceAddress="http://www.example.org/Transactions/" doc:name="Web Service Consumer"/>
     <flow name="soapboxFlow">
         <http:listener config-ref="HTTP_Listener_Configuration" path="*" doc:name="HTTP"/>
         <dw:transform-message doc:name="Transform Message" metadata:id="1639d844-c95e-4feb-bda5-6258ec392591">
             <dw:set-payload><![CDATA[%dw 1.0
 %output application/xml
 %namespace ns0 http://www.example.org/Transactions/
 ---
 {
     ns0#makePayment: {

         cId: payload.payments.account_no,

 
         noTrans: 1, 

         payList: {

             (payload.payments map ((payment , indexOfPayment) -> {

                 pay: {

                     aNum: payment.account_no,
 
 
 
 
                     aName: payment.account_no,
 
 
 
                     am: payment.amount,
 
 
 
                     ref: payment.description,
 
 
                     des: payment.description,

                     qu: payment.quantity
                 }

             }))

         }

     }
 }]]></dw:set-payload>
         </dw:transform-message>
         <ws:consumer config-ref="Web_Service_Consumer" doc:name="Web Service Consumer" operation="makePayment"/>
 
     </flow>
 </mule>

(抱歉 DW 组件中的所有间距)。关联的 WSDL 如下所示:

 <?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Transactions" targetNamespace="http://www.example.org/Transactions/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/Transactions/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <wsdl:documentation>
     <wsdl:appinfo source="WMQI_APPINFO">
       <MRWSDLAppInfo imported="true">
         <binding hasEncoding="false" imported="true" name="TransactionsSOAP" originalBindingStyle="document"/>
       </MRWSDLAppInfo>
     </wsdl:appinfo>
   </wsdl:documentation>
   
   
   <wsdl:types>
    <xsd:schema targetNamespace="http://www.example.org/Transactions/" xmlns:testSchExtn="http://www.test.com/schema/extensions/">
     <xsd:include schemaLocation="Transactions_InlineSchema1.xsd"/>
    </xsd:schema>
     </wsdl:types>
   <wsdl:message name="retrieveTransactionsRequest">
     <wsdl:part element="tns:transactionRequest" name="transactionRequest"/>
   </wsdl:message>
   <wsdl:message name="retrieveTransactionsResponse">
     <wsdl:part element="tns:transactionResponse" name="transactionResponse"/>
   </wsdl:message>
   <wsdl:message name="makePaymentRequest">
       <wsdl:part element="tns:makePayment" name="paymentRequest"/>
   </wsdl:message>
   <wsdl:message name="makePaymentResponse">
       <wsdl:part element="tns:makePaymentResponse" name="paymentResponse"/>
   </wsdl:message>
   <wsdl:portType name="Transactions">
     <wsdl:operation name="retrieveTransactions">
       <wsdl:input message="tns:retrieveTransactionsRequest"/>
       <wsdl:output message="tns:retrieveTransactionsResponse"/>
     </wsdl:operation>
     <wsdl:operation name="makePayment">
         <wsdl:input message="tns:makePaymentRequest"/>
         <wsdl:output message="tns:makePaymentResponse"/>
     </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="TransactionsSOAP" type="tns:Transactions">
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
     <wsdl:operation name="retrieveTransactions">
       <soap:operation soapAction="http://www.example.org/Transactions/retrieveTransactions"/>
       <wsdl:input>
         <soap:body use="literal"/>
       </wsdl:input>
       <wsdl:output>
         <soap:body use="literal"/>
       </wsdl:output>
     </wsdl:operation>
     <wsdl:operation name="makePayment">
       <soap:operation soapAction="http://www.example.org/Transactions/makePayment"/>
       <wsdl:input>
         <soap:body use="literal"/>
       </wsdl:input>
       <wsdl:output>
         <soap:body use="literal"/>
       </wsdl:output>
     </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="Transactions">
     <wsdl:port binding="tns:TransactionsSOAP" name="TransactionsSOAP">
       <soap:address location="www.example.com"/>
     </wsdl:port>
   </wsdl:service>
 </wsdl:definitions>

最后,当我将示例 JSON 文件输入到流程中并查看输出结果时,我得到了这个文件:

 Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: <?xml version="1.0" encoding="iso-8859-1"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     <head>
         <title>404 - Not Found</title>
     </head>
     <body>
         <h1>404 - Not Found</h1>
         <script type="text/javascript" src="http://gp1.wpc.edgecastcdn.net/00222B/jtest/tpbeacontest.js"></script>
     </body>
 </html>
 . Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: PushbackInputStream                                                   

很明显,有些事情搞砸了——我不知道为什么结果文件中的内容类型是 text/html,因为我当然没有那样配置它。关于我哪里出错的任何建议?

【问题讨论】:

    标签: json soap mule content-type esb


    【解决方案1】:

    您的配置不可读,但我的猜测是您在 cxf 组件(出站端点)之后没有端点,请参阅下面的需要。

    <mule ...>
       ................ initial flow
            <cxf:jaxws-client operation="yourOperation" clientClass="com.abc.ws.endpoints.XYZService" port="port" enableMuleSoapHeaders="true" doc:name="docName">
                <cxf:jaxb-databinding/>
            </cxf:jaxws-client>
            <outbound-endpoint address="http://localhost:8080/my/url/enpoint" doc:name="documentName" exchange-pattern="request-response"/>**
            <echo-component doc:name="Echo"/>
        </flow>
    </mule>
    

    【讨论】:

    【解决方案2】:

    您收到了 404,看起来 Mule 不提供该服务。

    您是否在代理或防火墙后面,是否可以从另一个工具调用此操作作为 SOAP UI?

    【讨论】:

      【解决方案3】:

      我查看了提供的 WSDL 和 Mule 配置,可以看到您已在 http://www.example.org/Transactions/ 配置了 Web 服务位置,但那里似乎没有 Web 服务。除非你肯定这应该有效,否则我会说是这样。

      如果您想尝试公共和响应式 Web 服务,请查看http://www.webservicex.net/globalweather.asmx?WSDL

      为了将来参考,建议启用线路日志记录以查看在解决此问题时发生了什么。只需在 log4j2.xml 文件中添加以下内容

      <AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="DEBUG" />
      <AsyncLogger name="com.ning.http" level="DEBUG" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多