0
votes

I'm trying to set up a flow that involves taking in a JSON payload through an HTTP endpoint, transforming it into an XML payload to be used for a SOAP transaction, then turned back into a JSON payload, much like in this demo here: https://www.youtube.com/watch?v=XyZcI1_MbOo. Now, I'm setting up the flow, and have the Web Service Consumer component up and running. Trying to debug the flow, I'm simply doing the first transformation to XML, sending the message to the Web Service Consumer, and then writing the resultant message to a file. My flow is as follows:

<?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>

(sorry for all the spacing in the DW component). The associated WSDL looks like this:

 <?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>

Finally, when I input my sample JSON file into the flow, and look at the output result, I get this file:

 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                                                   

So clearly, something is getting mucked up -- I don't know why the content type in the resultant file was of text/html, as I certainly didn't configure it that way. Any suggestions as to where I've gone wrong?

3

3 Answers

0
votes

Your config not readable but my guess is that you don't have an endpoint after cxf component (outbound-endpoint) see below as its needed.

<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>
0
votes

You received a 404 looks like the service is not available from Mule.

Are you behind a proxy or firewall, are you able to call this operation from another tool as SOAP UI?

0
votes

I've taken a look at the WSDL and Mule configuration provided and can see that you have configured your web service location at http://www.example.org/Transactions/ but it doesn't look like there's a web service there. Unless your positive this should work, I'd say that's the case.

If you want to try a Web Service that's public and responsive check out http://www.webservicex.net/globalweather.asmx?WSDL

For future reference, it's advisable to enable wire logging to see what's going on when troubleshooting this issues. Just add the following o the log4j2.xml file

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