用脚本调解员致电调解人
我正在寻找带有呼叫调解员的API。然后,我想与脚本Medieor一起处理数据,并与响应生成输出。如果我不使用脚本调解员,我的流将起作用。但是,当我想使用脚本Medieor时,我会收到以下错误。
序言中的意外字符'{'(代码123);预期的'<' 在[row,col {col {unknown源}]中:[1,1]
<?xml version="1.0" encoding="UTF-8"?>
<api context="/x" name="x" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<call>
<endpoint>
<http method="get" uri-template="https://jsonplaceholder.typicode.com/users">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<script language="js"><![CDATA[var x = mc.getPayloadJSON();
if (x.id == "1")
mc.setPayloadJSON('{"s":"success"}');
else
mc.setPayloadJSON('{"s":"error"}');]]></script>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
预先感谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
脚本中介器
是 content-ware 调解器,当您在中介流中添加内容感知的中介器时,将构建消息(二进制消息转换为可读格式)并将其带入该消息中调解流。这通过消息构建者。从您共享的错误片段中,您似乎正在收到JSON消息作为响应。因此,此错误可能有两个原因。如果采用第二种情况,请首先确保为默认的JSON Content-Type
Application/json
设置消息构建器,&lt; server_home&gt; /conf/axis2/axis2/axis2.xml << /代码>。如果在那里,请检查您的后端是否正在发送默认内容类型的JSON变体。例如,“应用程序/LD+JSON”等。如果是这种情况,则需要为此内容类型添加新的消息构建器。您可以参考如果您在Mi上,则此文档。如果您在EI上,请参考。
更新
检查您的评论后,它看起来像是直接的集成。除上述两个原因外,这可能是后端完全发送错误的响应。您是否正在使用浏览器来测试此API?如果是这样,由于浏览器添加了其他标头,您可能会得到不同的响应。因此,请在呼叫中介之前尝试卸下所有运输标头。请参阅下面。注意
&lt; property Action =“ remove” name =“ Transport_headers” scope =“ axis2”/&gt;
The
Script Mediator
is a content-aware mediator and when you add a content-aware mediator to the mediation flow the message will be built(Binary message converted into a readable format) and brought into the mediation flow. This happens through message builders. From the error snippet you shared, it seems you are receiving a JSON message as a response. So there can be two reasons for this error.If you take the second case, first make sure a message builder is set for the default JSON content-type
application/json
in the<SERVER_HOME>/conf/axis2/axis2.xml
. If it's there check if your backend is sending a JSON variation of a default content-type. For example "application/ld+json" etc. If that's the case you need to add a new message builder for this content type. You can refer to this document if you are on MI. If you are on EI refer to this.Update
After checking your comments, it looks like a straightforward integration. Other than the above two reasons this can be the backend altogether sending a wrong response. Are you using the browser to test this API? If so you may be getting a different response due to additional headers added by the browser. Hence please try removing all the transport headers before the call mediator. Refer to the below. Note the
<property action="remove" name="TRANSPORT_HEADERS" scope="axis2"/>