使用Mule esb的主体和身份验证标头配置Restful api

时间:2019-03-18 08:57:50

标签: spring mule

我想将服务导出到Mule esb。 我有以下几种服务。 输入POST http://10.1.3.193:8080/HRMS/remoting/kpidata/login 键入GET http://10.1.3.193:8080/HRMS/remoting/kpiDiemhieuqua/getFileXaydung/124/2019/NAM/GENCO

我在MULE上配置服务登录:

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" basePath="/ESB"/>
<http:request-config name="HTTP_Request_Configuration_outboundWS" host="10.1.3.193" port="8080" doc:name="HTTP Request Configuration" basePath="/HRMS/remoting/kpidata"/>
<flow name="myFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/login" doc:name="Inbound HTTP" allowedMethods="POST"/>
    <json:object-to-json-transformer doc:name="Object to JSON"/><set-property propertyName="Content-Type" value="application/json" doc:name="Set Outbound Header"/>
    <http:request config-ref="HTTP_Request_Configuration_outboundWS" path="/login" method="POST" doc:name="POST WebService"/>

</flow>

Java代码服务

@RequestMapping(value = "/login", method = RequestMethod.POST, headers = { "Content-type=application/json" })
public @ResponseBody KpiCaytochuc postLogin(@RequestBody final UserLogin user, ModelMap model) {
    System.out.println(user);
    KpiCaytochuc kpiCayToChuc = null;
    return kpiCayToChuc;
}

@RequestMapping(value = "/getFileXaydung/{idDonvi}/{nam}/{kybaocao}/{nhom}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<KpiDgCthq> getFileXaydung(@PathVariable("idDonvi") Integer idDonvi,
        @PathVariable("nam") Integer nam, @PathVariable("kybaocao") String kybaocao,
        @PathVariable("nhom") String nhom) {
    KpiDmKyapdung kyapdung = dmServices.getByYear(nam, idDonvi);
    KpiDgCthq ddg = baocaoServices.getHtnhiemvu(idDonvi, nhom, kyapdung.getId());
    ddg.setKpiDgCthqgiaos(null);
    return new ResponseEntity<KpiDgCthq>(ddg, HttpStatus.OK);
}

运行M子 500没有找到类org.glassfish.grizzly.utils.BufferInputStream的序列化程序,也没有发现创建BeanSerializer的属性(为避免异常,请禁用SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS))(org.codehaus.jackson.map.JsonMappingException)。 (org.mule.api.transformer.TransformerMessagingException)。

Run restlet client

Run Mule

请帮助我

1 个答案:

答案 0 :(得分:0)

根据我的经验,当RAML中定义的响应类型与实际响应类型之间存在响应类型不匹配时,我会看到此错误发生。