简体   繁体   English

WSO2 EI 6.6.0 hal_json 格式问题

[英]WSO2 EI 6.6.0 hal_json Format Issue

6.0 to call a Drupal 8 RESTful web service endpoint which returns the response in hal_json format. 6.0 调用 Drupal 8 RESTful Web 服务端点,该端点以 hal_json 格式返回响应。 I have never come across this format before but this is what the Drupal 8 response is in. The Content-Type is "application/hal+json".我以前从未遇到过这种格式,但这就是 Drupal 8 响应的内容。内容类型是“application/hal+json”。 For more information, this is the Drupal 8 link - https://www.drupal.org/docs/8/core/modules/rest/3-post-for-creating-content-entities有关更多信息,这是 Drupal 8 链接 - https://www.drupal.org/docs/8/core/modules/rest/3-post-for-creating-content-entities

I'm using a property mediator to convert the response from hal_json format to XML but I'm getting the below error:我正在使用属性中介将响应从 hal_json 格式转换为 XML,但出现以下错误:

OMException in getSOAPBuilder org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; getSOAPBuilder org.apache.axiom.om.OMException 中的 OMException:com.ctc.wstx.exc.WstxUnexpectedCharException:序言中的意外字符“{”(代码 123); expected '<'预期'<'

I searched online for this error and found that this type of error usually occurs when the API response is in a format that is not enabled in WSO2 (it needs to be enabled in the axis2.xml file).我在网上搜索了这个错误,发现这种类型的错误通常发生在API响应的格式在WSO2中没有启用的时候(需要在axis2.xml文件中启用)。 Can anyone please tell me what property I need to add to my axis2.xml file?谁能告诉我需要将什么属性添加到我的axis2.xml 文件中? I think is needs to be a message formatter and builder property.我认为需要是消息格式化程序和构建器属性。

I have not worked with the JSON message type specified.我没有使用指定的 JSON 消息类型。 But if it is a valid JSON message you can define a JsonStreamBuilder builder for this message type.但是,如果它是有效的 JSON 消息,您可以为此消息类型定义一个 JsonStreamBuilder 构建器。 The message builder can be defined as follows in the axis2.xml file under messageBuilders in [EI_HOME]/conf/axis2 directory消息生成器可以在[EI_HOME]/conf/axis2目录下messageBuilders下的axis2.xml文件中定义如下

<messageBuilders>
..
<messageBuilder contentType="application/hal+json"                                   
  class="org.wso2.carbon.integrator.core.json.JsonStreamBuilder"/>
..
</messageBuilders>

After modifying the axis2.xml you need to perform a server restart in order for this to take effect.修改axis2.xml 后,您需要重新启动服务器才能使其生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM