mule restful代理抛出空指针异常



我正在使用mule构建一个简单的restful代理。虽然大多数rest调用都得到了正确的代理,但其中一个POST调用抛出了一个空指针异常。

这是入站消息:

org.mule.DefaultMuleMessage
{
  id=c856d080-bd55-11e4-8504-6c40089d7cb6
  payload=java.lang.String
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=<not set>
Message properties:
  INVOCATION scoped properties:
  INBOUND scoped properties:
    accept=text/virl+xml,multipart/mixed
    authorization=Basic TmV0U2ltOk5ldFNpbQ==
    connection=keep-alive
    content-length=1000
    content-type=application/xml
    host=localhost:9090
    http.listener.path=/*
    http.method=POST
    http.query.params=org.mule.module.http.internal.ParameterMap@330eee18
    http.query.string=session=0c603343-49e6-452f-bfdf-1e69cf478f65
    http.remote.address=/127.0.0.1:52065
    http.request.path=/ank/rest/process
    http.request.uri=/ank/rest/process?session=0c603343-49e6-452f-bfdf-1e69cf478f65
    http.scheme=http
    http.uri.params=org.mule.module.http.internal.ParameterMap@0
    http.version=HTTP/1.1
    user-agent=Jersey/2.0-rc1 (HttpUrlConnection 1.7.0_71)
  OUTBOUND scoped properties:
    Content-Type=text/plain;charset=UTF-8
    MULE_ENCODING=UTF-8
    http.disable.status.code.exception.check=false
  SESSION scoped properties:
}
ERROR 2015-02-25 19:21:26,894 [[restproxy].VIRL-UWM-Management-APIs.worker.02] org.mule.exception.CatchMessagingExceptionStrategy: 
********************************************************************************
Message               : null (java.lang.NullPointerException). Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
  org.mule.module.http.internal.HttpParser:94 (null)
2. null (java.lang.NullPointerException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
    at org.mule.module.http.internal.HttpParser.parseMultipartContent(HttpParser.java:94)
    at org.mule.module.http.internal.request.HttpResponseToMuleEvent.getInboundAttachments(HttpResponseToMuleEvent.java:139)
    at org.mule.module.http.internal.request.HttpResponseToMuleEvent.convert(HttpResponseToMuleEvent.java:77)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

不知道它为什么会失败。通过传递代理来达到实际的终点可以正常工作。有线索吗?

骡子流量:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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" version="EE-3.6.0"
    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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.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/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <http:listener-config name="VIRL-UWM-Management-APIs" host="0.0.0.0" port="9090" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="Actual-Virl-Enpoint-for-UWM" host="virl03.stic.cisco-services.com" port="19399" doc:name="HTTP Request Configuration"/>
    <http:listener-config name="AutoNetKit-API" host="0.0.0.0" port="19401" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="AutoNetkit-End-Point" host="virl03.stic.cisco-services.com" port="19401" doc:name="HTTP Request Configuration"/>
    <flow name="virl-proxyFlow">
        <http:listener config-ref="AutoNetKit-API" path="*" allowedMethods="GET" doc:name="HTTP"/>
        <set-property propertyName="http.disable.status.code.exception.check" value="false" doc:name="Disable Exception Check"/>
        <logger message=" payload is: #[message.payload], method is: #[message.inboundProperties.'http.method'], Request URI is: #[message.inboundProperties.'http.request.uri'], message is: #[message]" level="INFO" doc:name="Logger"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
        <http:request config-ref="AutoNetkit-End-Point" path="#[message.inboundProperties.'http.request.uri']" method="#[message.inboundProperties.'http.method']" responseTimeout="60000" doc:name="AutoNetKit-EndPoint"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
    </flow>
    <flow name="VIRL-Restful-Proxy">
        <http:listener config-ref="VIRL-UWM-Management-APIs" path="*" doc:name="HTTP"/>
        <choice doc:name="GET-vs-POST">
            <when expression="#[message.inboundProperties.'http.method' == 'POST']">
                <object-to-string-transformer doc:name="Object to String"/>
                <logger message="Set the payload of type string - since it's a post request." level="INFO" doc:name="Logger"/>
            </when>
            <otherwise>
                <logger message="Not setting payload transformation as it's a GET request." level="INFO" doc:name="Logger"/>
            </otherwise>
        </choice>
        <set-property propertyName="http.disable.status.code.exception.check" value="false" doc:name="Disable Exception Check"/>
        <logger message=" payload is: #[message.payload], method is: #[message.inboundProperties.'http.method'], Request URI is: #[message.inboundProperties.'http.request.uri'], message is: #[message]" level="INFO" doc:name="Logger"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
        <http:request config-ref="Actual-Virl-Enpoint-for-UWM" path="#[message.inboundProperties.'http.request.uri']" 
                        method="#[message.inboundProperties.'http.method']" responseTimeout="60000" doc:name="VIRL End Point"/>
        <logger message="response payload: #[message]" level="INFO" doc:name="Logger"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>

        <catch-exception-strategy doc:name="Catch Exception Strategy">
            <logger level="DEBUG" message="#[exception.exceptions]" doc:name="Logger"/>
        </catch-exception-strategy>

    </flow>
        <sub-flow name="copy-headers" >
        <copy-properties propertyName="*" doc:name="Copy All HTTP Headers"/>
        <remove-property propertyName="Content-Length" doc:name="Remove Content Length"/>
        <remove-property propertyName="MULE_*" doc:name="Remove MULE Properties"/>
        <remove-property propertyName="X_MULE*" doc:name="Remove X_MULE Properties"/>
        <remove-property propertyName="X-MULE*" doc:name="Remove X-MULE Properties"/>
    </sub-flow>

</mule>

感谢

这是Mule代码中的一个错误:我已经报告过了,您可以跟踪Mule-8342。

在此期间,您可以尝试以下操作:

  • 如果您可以控制远程服务器,请在其多部分响应中添加Content-Disposition标头
  • 暂时使用http:outbound-endpoint代替http:request,直到修复上述错误为止

相关内容

  • 没有找到相关文章

最新更新