自最近以来,我一直在使用wso2 esb 5.0,我遵循wso2网站上有关医疗示例的教程。
我实际上是在“将多个服务作为一个服务公开”教程,在信中我一直在关注它。
问题是,当我使用curl将请求发送到后端时,我在日志和控制台中看到了一些我不理解的错误消息。
请参阅日志中的以下错误消息:
INFO - LogMediator To: /healthcare/categories/surgery/reserve, MessageID: urn:uuid:caca8c20-03db-4632-9f34-0b53f40d5950, Direction: request, message = Routing to grand oak community hospital
[2018-09-14 17:22:28,616] ERROR - SynapseJsonPath #stringValueOf. Error evaluating JSON Path <$.actualFee>. Returning empty result. Error>>> invalid path
[2018-09-14 17:22:35,025] INFO - LogMediator To: /healthcare/categories/surgery/reserve, MessageID: urn:uuid:605abc38-6543-44f3-963e-0412b0e7ad12, Direction: request, message = Routing to grand oak community hospital
[2018-09-14 17:22:35,629] ERROR - SynapseJsonPath #stringValueOf. Error evaluating JSON Path <$.actualFee>. Returning empty result. Error>>> invalid path
在控制台中:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8280 (#0)
> POST /healthcare/categories/surgery/reserve HTTP/1.1
> Host: localhost:8280
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Type:application/json
> Content-Length: 234
>
* upload completely sent off: 234 out of 234 bytes
< HTTP/1.1 500 Internal Server Error
< Set-Cookie: SERVERID=s0; path=/
< Content-Type: application/octet-stream
< Date: Fri, 14 Sep 2018 15:22:35 GMT
< Transfer-Encoding: chunked
<
Error in executing request: POST /healthcare/payments* Connection #0 to host localhost left intact
通常,后端将发送JSON文件,其中包含有关费用,医生和患者的一些信息。
我不理解错误消息;显然,该错误将出现在$ .actualfee的JSON路径中,但我没有发现任何问题。 也许该错误是可见的,但我是wso2的新手,并且我不理解esb中的所有内容。
亚瑟
PS:我的HealthCareAPI.xml文件的XML源代码:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/healthcare" name="HealthcareAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/querydoctor/{category}">
<inSequence>
<log description="Request Log" level="custom">
<property name="message" value=""Welcome to HealthcareService""/>
</log>
<send>
<endpoint key="QueryDoctorEP"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
<resource uri-template="/categories/{category}/reserve">
<inSequence>
<property description="Get Hospital" expression="json-eval($.hospital)" name="Hospital" scope="default" type="STRING"/>
<property description="Get Card Number" expression="json-eval($.cardNo)" name="card_number" scope="default" type="STRING"/>
<datamapper config="gov:datamapper/RequestMapping.dmc" description="DataMapper" inputSchema="gov:datamapper/RequestMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/RequestMapping_outputSchema.json" outputType="JSON"/>
<switch source="get-property('Hospital')">
<case regex="grand oak community hospital">
<log description="Grand Oak Log">
<property expression="fn:concat('Routing to ', get-property('Hospital'))" name="message"/>
</log>
<property description="Set Hospital Variable" name="uri.var.hospital" scope="default" type="STRING" value="grandoaks"/>
<call>
<endpoint key="GrandOakEP"/>
</call>
</case>
<case regex="clemency medical center">
<log description="Clemency Log">
<property expression="fn:concat('Routing to ', get-property('Hospital'))" name="message"/>
</log>
<property description="Set Hospital Variable" name="uri.var.hospital" scope="default" type="STRING" value="clemency"/>
<call>
<endpoint key="ClemencyEP"/>
</call>
</case>
<case regex="pine valley community hospital ">
<log description="Pine Valley Log" level="custom">
<property expression="fn:concat('Routing to ', get-property('Hospital'))" name="message"/>
</log>
<property description="Set Hospital Variable" name="uri.var.hospital" scope="default" type="STRING" value="pinevalley"/>
<call>
<endpoint key="PineValleyEP"/>
</call>
</case>
<default>
<log description="Fault Log" level="custom">
<property expression="fn:concat('Invalid hospital - ', get-property('Hospital'))" name="message"/>
</log>
<respond description="Respond"/>
</default>
</switch>
<property description="Get Appointment Number" expression="json-eval($.appointmentNumber)" name="uri.var.appointment_id" scope="default" type="STRING"/>
<property description="Get Doctor Details" expression="json-eval($.doctor)" name="doctor_details" scope="default" type="STRING"/>
<property description="Get Patient Details" expression="json-eval($.patient)" name="patient_details" scope="default" type="STRING"/>
<call>
<endpoint key="ChannelingFeeEP"/>
</call>
<property description="Get Actual Fee" expression="json-eval($.actualFee)" name="actual_fee" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>{
"appointmentNumber":$1,
"doctor":$2,
"patient":$3,
"fee":$4,
"confirmed":"false",
"card_number":"$5"
}</format>
<args>
<arg evaluator="xml" expression="$ctx:uri.var.appointment_id"/>
<arg evaluator="xml" expression="$ctx:doctor_details"/>
<arg evaluator="xml" expression="$ctx:patient_details"/>
<arg evaluator="xml" expression="$ctx:actual_fee"/>
<arg evaluator="xml" expression="$ctx:card_number"/>
</args>
</payloadFactory>
<call>
<endpoint key="SettlePaymentEP"/>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
答案 0 :(得分:-1)
在致电中介后,尝试使用Property中介,如下所示。
<call>
<endpoint key="ChannelingFeeEP"/>
</call>
<property description="messageType" value="application/json" scope="default" type="STRING"/>
<property description="contentType" value="application/json" scope="default" type="STRING"/>
<property description="Get Actual Fee" expression="json-eval($.actualFee)" name="actual_fee" scope="default" type="STRING"/>