我想在身份验证失败后返回 401 HTTP_response。我试图通过使用具有以下配置的 http:response-builder 组件来做到这一点。我不关心流程中之前的任何事情,一旦达到这一点,它需要做的就是这个。
<flow name="main" doc:name="main">
<http:inbound-endpoint exchange-pattern="request-response"
address="http://localhost:8081/example" doc:name="HTTP" />
<byte-array-to-string-transformer
doc:name="Byte Array to String" />
<cxf:proxy-service namespace=""
service="" payload="envelope"
wsdlLocation=""
enableMuleSoapHeaders="false" doc:name="ProxyService"/>
<cxf:proxy-client payload="envelope" enableMuleSoapHeaders="true" doc:name="ProxyClient" />
<http:outbound-endpoint exchange-pattern="request-response"
address=""
doc:name="request" />
<byte-array-to-string-transformer
doc:name="Byte Array to String" />
<logger message="The payload after the request is:#[payload]"
level="INFO" doc:name="Logger" />
<choice doc:name="Choice">
...
<otherwise>
<processor-chain>
<logger message="Failed authentication is:#[payload]" level="INFO"
doc:name="Logger" />
<http:response-builder status="401"
doc:name="HTTP Response Builder">
<set-payload value="Authentication Failed" />
</http:response-builder>
</processor-chain>
</otherwise>
我通过soapUI收到的错误
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Could not find a transformer to transform "SimpleDataType{type=org.mule.transport.http.HttpResponse, mimeType='text/xml'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}". (org.mule.api.transformer.TransformerException). Message payload is of type: PostMethod</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>.
对我来说,这说明我当前的消息是 text/xml,它正试图返回一个未知类型。我尝试将构建器的内容类型设置为 text/xml,结果相同
编辑:当前状态是 HTTP/1.1 500 Internal Server Error
非常感谢您花时间阅读和任何回复。