使用 WSO2 FHIR 连接器

Using WSO2 FHIR Connector

我正在尝试使用 WSO2 EI 6.1.0 的 FHIR 连接器 我正在关注这个 documentation

创建操作的请求是:

{
  "body": {
       "base": "https://sqlonfhir-stu3.azurewebsites.net",
      "type": "Patient",
      "format": "json"
      }
} 

我的代理是:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="fhirTest"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <property expression="json-eval($.body.base)"
                   name="base"
                   scope="default"
                   type="STRING"/>
         <property expression="json-eval($.body.type)"
                   name="type"
                   scope="default"
                   type="STRING"/>
         <property expression="json-eval($.body.format)"
                   name="format"
                   scope="default"
                   type="STRING"/>

         <fhir.init>
            <base>{$ctx:base}</base>
         </fhir.init>
         <fhir.create>
            <type>{$ctx:type}</type>
            <format>{$ctx:format}</format>
         </fhir.create>
         <send/>
      </inSequence>
      <outSequence/>
      <faultSequence/>
   </target>
   <parameter name="ApplicationXMLBuilder.allowDTD">true</parameter>
   <description/>
</proxy>

请求后响应为(正文为空):

HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: text/html;charset=UTF-8
Content-Length: 0
Date: Fri, 05 May 2017 14:09:01 GMT
Server: WSO2 Carbon Server

但我得到以下异常:不允许 DOCTYPE

日志:

[2017-05-05 16:09:01,192] []  INFO - LogMediator To: /services/fhirTest,From: 192.168.81.118,Direction: request,base1 = https://sqlonfhir-stu3.azurewebsites.net
,type1 = Patient,format1 = json,Payload: {
  "body": {
       "base": "https://sqlonfhir-stu3.azurewebsites.net",
          "type": "Patient",
          "format": "json"
      }
}
[2017-05-05 16:09:01,704] [] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: DOCTYPE is not allowed
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
        at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
        at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:160)
        at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:136)
        at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:99)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.buildMessage(Axis2SynapseEnvironment.java:817)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:546)
        at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:118)
        at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
        at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:281)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:775)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:262)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: DOCTYPE is not allowed
        at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:36)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
        ... 21 more
[2017-05-05 16:09:01,709] [] ERROR - Axis2SynapseEnvironment Error while building message
org.apache.axis2.AxisFault: Error while building Passthrough stream
        at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:283)
        at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:142)
        at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:99)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.buildMessage(Axis2SynapseEnvironment.java:817)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:546)
        at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:118)
        at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
        at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:281)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:775)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:262)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: DOCTYPE is not allowed
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
        at ...
[2017-05-05 16:11:03,952] []  WARN - SynapseCallbackReceiver Synapse received a response for the request with message Id : urn:uuid:c14afbec-7e12-4c9a-be5e-0746
53fed0e6 But a callback is not registered (anymore) to process this response

我的问题是:

  1. 有没有人能够按照指南进行正确的测试?

  2. 如何传递其他数据以创建资源 fhir(进一步的基础、类型和格式),如here所述?

提前致谢

UPDATE:在我启用 messageBuilder 和 messageFormatter(如 Hariprasath 所建议的)之后,之前的错误得到解决 但现在我有另一个错误:

[2017-05-10 16:42:20,891] [] DEBUG - RelayUtils Content Type is application/fhir+json; charset=utf-8
[2017-05-10 16:42:20,893] [] ERROR - Axis2Sender Unexpected error during sending message out
java.lang.NullPointerException
        at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:211

确保 add/enable 构建器和格式化程序 "text/html" 在 /repository/conf/axis2/axis2.xml 文件中。

<messageFormatter contentType="text/html"
        class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

[1] https://github.com/wso2-extensions/esb-connector-fhir/blob/master/src/test/INTEGRATION-TEST.txt

这是因为响应是 HTML 页面(内容类型为 text/html 格式)。通常,我们需要启用以下格式化程序和构建器来避免此错误并支持 text/html 格式。请将以下消息生成器和格式化程序添加到 /repository/conf/axis2/axis2.xml.

中的部分
<messageBuilder contentType="text/html"
    class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageFormatter contentType="text/html"
    class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>