【发布时间】: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