使用WSO2 FHIR连接器

时间:2017-05-05 14:26:36

标签: rest wso2 wso2esb connector hl7-fhir

我正在尝试使用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$1.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$1.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所述?

  3. 提前致谢

    UPDATE :启用messageBuilder和messageFormatter后(由Hariprasath建议),解决了previus错误 但现在我还有一个错误:

    [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
    

2 个答案:

答案 0 :(得分:2)

这是因为响应是一个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"/>

答案 1 :(得分:1)

确保在/repository/conf/axis2/axis2.xml文件中为“text / html”添加/启用构建器和格式化程序。

<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