将Http Response转换为对象mule esb

时间:2015-03-03 11:37:02

标签: java mule httpresponse

我正在做一个样本书店。当用户预订了订单时,系统会向他发送一封电子邮件,其中包含订单中的日期。系统发送电子邮件但显示下一个错误:

Root Exception stack trace:
java.lang.IllegalArgumentException: Cannot apply transformer HttpClientMethodResponseToObject{this=6911a11b, name='HttpClientMethodResponseToPedido', ignoreBadInput=false, returnClass=SimpleDataType{type=org.mule.entities.Pedido, mimeType='text/html'}, sourceTypes=[SimpleDataType{type=org.apache.commons.httpclient.HttpMethod, mimeType='*/*'}]} on source payload: class org.mule.transport.http.HttpResponse
at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:1427)
at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1379)
at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1371)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

我的XML是下一个:

<smtp:gmail-connector name="Gmail" validateConnections="true" doc:name="Gmail" contentType="text/html"   />
<flow name="Email" doc:name="Email">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" doc:name="HTTP" path="Email"/>
    <http:static-resource-handler resourceBase="docroot" defaultFile="index.html" doc:name="HTTP Static Resource Handler"/>
</flow>
<flow name="Correo" doc:name="Correo">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="Facturacion" doc:name="HTTP" transformer-refs="Java"/>
    <component doc:name="Generar Pedido" class="org.mule.components.GenerarPedido"/>
    <smtp:outbound-endpoint host="smtp.gmail.com" port="587" user="email%40gmail.com" password="pass" connector-ref="Gmail" to="#[payload.email]" from="BookStore S.A." responseTimeout="10000" doc:name="SMTP" transformer-refs="Java1" mimeType="text/html"/>
    <http:response-builder status="200" contentType="text/html" doc:name="HTTP Response Builder"/>
    <http:http-response-to-object-transformer returnClass="org.mule.entities.Pedido" encoding="UTF-8" mimeType="text/html" doc:name="HTTP Response to Object"/>
</flow>

任何人都可以帮助我?

1 个答案:

答案 0 :(得分:1)

您的有效负载不是HTTP响应,因此您无法使用http-response-to-object-transformer。这是在调用http:outbound-endpoint之后使用的,该端点返回一个&#39; HTTP响应&#39;。