WSO2 esb验证介体失败

时间:2018-11-22 11:41:28

标签: wso2esb

我一直在关注如何验证JSON请求的WSO2文档。我已经实现了它的解释,当我使用错误的json主体进行尝试时,应用崩溃并显示以下错误,而不是执行我的有效负载工厂代码。 我想念什么?

错误:

ERROR - StkPushAPI Error creating a new schema objects for schemas : [Value {name ='null', keyValue ='conf:schema/processCheckoutSchema.json'}]
org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at org.apache.xerces.jaxp.validation.Util.toSAXParseException(Unknown Source)
    at org.apache.xerces.jaxp.validation.Util.toSAXException(Unknown Source)
    at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
    at org.apache.synapse.mediators.builtin.ValidateMediator.mediate(ValidateMediator.java:428)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
    at org.apache.synapse.rest.Resource.process(Resource.java:351)
    at org.apache.synapse.rest.API.process(API.java:399)
    at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:135)
    at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:113)
    at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
    at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:92)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:383)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

这是我的配置:

> <validate cache-schema="true">
>                 <schema key="conf:schema/processCheckoutSchema.json"/>
>                 <resource key="conf:schema/processCheckoutSchema.json" location="default_location"/>
>                 <on-fail>
>                     <payloadFactory description="failureResponse" media-type="json">
>                         <format>{"message":"JSON validation failed"}</format>
>                         <args/>
>                     </payloadFactory>
>                     <respond description="failureResponse"/>
>                 </on-fail>
>             </validate>

1 个答案:

答案 0 :(得分:0)

我快速尝试了一下您的代码,并且进行了一些修改后似乎可以正常工作

  • 您不需要<resource key=../>。仅在架构引用另一个架构时才需要。
  • 确保json模式的类型为“ application / json”。