2013-05-01 66 views
1

我有这个代理服务将两个xml消息聚合成一个。WSO2聚合器 - xpath无法遍历

  1. 我已经配置我的聚合器类使用XPath
  2. 我不知道我的命名空间的XPath是否有效。我无法跟踪日志。

我的代理服务器配置:

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="prescription" 
     transports="https http jms" 
     startOnLoad="true" 
     trace="disable"> 
    <description/> 
    <target> 
     <inSequence> 
     <aggregate> 
      <completeCondition> 
       <messageCount min="2" max="2"/> 
      </completeCondition> 
      <onComplete expression="//soapenv:Envelope//f:Prescription//f:identifier//f:id//@value"> 

       <send> 
        <endpoint> 
        <address uri="jms:/report?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616"/> 
        </endpoint> 
       </send> 

      </onComplete> 
     </aggregate> 

     </inSequence> 
     <outSequence> 
     <drop/> 
     </outSequence> 
     <faultSequence/> 
    </target> 
    <parameter name="transport.jms.ContentType"> 
     <rules> 
     <jmsProperty>contentType</jmsProperty> 
     <default>application/xml</default> 
     </rules> 
    </parameter> 
</proxy> 

我输入消息是这样的:(我要根据病人ID汇总)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://isova.wipro.com/"> 


<Prescription xmlns="http://hl7.org/fhir"> 
    <identifier> 
    <id value="A0001"/> 
    </identifier> 
    <status value="active"/> 
    <patient> 
    <type value="Patient"/> 
    <url value="Bhavani"/> 
    </patient> 
    <prescriber> 
    <type value="Provider"/> 
    <url value="Dr.Mathews"/> 
    </prescriber> 
    <medicine> 
    <identification> 
     <text value="Zintac"/> 
    </identification> 
    </medicine> 
</Prescription></soapenv:Envelope> 

有什么建议?

问候 大师 @gnanagurus


我不能帮助解决这个问题。这是我最新的WSO2代理。

这些是'处方'队列中存在的两条消息。

消息1:

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://isova.wipro.com/"> 


<Prescription xmlns="http://hl7.org/fhir"> 
    <identifier> 
    <id value="A0001"/> 
    </identifier> 
    <status value="active"/> 
    <patient> 
    <type value="Patient"/> 
    <url value="Bhavani"/> 
    </patient> 
    <prescriber> 
    <type value="Provider"/> 
    <url value="Dr.Mathews"/> 
    </prescriber> 
    <medicine> 
    <identification> 
     <text value="Zintac"/> 
    </identification> 
    </medicine> 
</Prescription></soapenv:Envelope></soapenv:Body></soapenv:Envelope> 

消息2:

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://isova.wipro.com/"> 


<Prescription xmlns="http://hl7.org/fhir"> 
    <identifier> 
    <id value="A0001"/> 
    </identifier> 
    <status value="active"/> 
    <patient> 
    <type value="Patient"/> 
    <url value="Bhavani"/> 
    </patient> 
    <prescriber> 
    <type value="Provider"/> 
    <url value="Dr.John"/> 
    </prescriber> 
    <medicine> 
    <identification> 
     <text value="tintac"/> 
    </identification> 
    </medicine> 
</Prescription></soapenv:Envelope></soapenv:Body></soapenv:Envelope> 

代理:

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="prescription" 
     transports="https http jms" 
     startOnLoad="true" 
     trace="disable"> 
    <description/> 
    <target> 
     <inSequence> 


     <aggregate> 
       <completeCondition> 
        <messageCount min="2"/> 
       </completeCondition> 
       <onComplete expression="/Prescription"> 
       <send> 
        <endpoint> 
        <address uri="jms:/report?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616"/> 
        </endpoint> 
       </send> 
       </onComplete> 
      </aggregate> 
     </inSequence> 
     <outSequence> 
     <drop/> 
     </outSequence> 
     <faultSequence/> 
    </target> 
    <parameter name="transport.jms.ContentType"> 
     <rules> 
     <jmsProperty>contentType</jmsProperty> 
     <default>application/xml</default> 
     </rules> 
    </parameter> 
</proxy> 

这不是解决我的聚集。这两条消息没有得到聚合器。我尝试使用名称空间的多个xpath。 Anyhelp非常需要。

是否有任何WSO2聚合器自定义Java类,我可以使用,而不是聚合中介?

问候 大师

+0

作为一个提示,也许不要在xpath表达式中使用太多//因为您知道结构 - one /就足够了。 – FiveO 2013-05-01 14:40:54

回答

1

你XPATH是错误的,因为你没有定义你的命名空间。

我相信你正在处理SOAP消息。如果是的话,你复制上面的确切消息。我看不到SOAP身体?你应该做的是将你的xml有效载荷充实到SOAP主体中,并从aggrgate mediator中聚合它们。在那里你只需要考虑以SOAP身体为根的XPATH。在你的情况下,它应该是

<onComplete xmlns:f="http://hl7.org/fhir" expression="//f:Prescription/f:identifier/f:id/text()"> 
3

是的,你需要定义命名空间f。你可以在一开始做的是直接:

<proxy xmlns="http://ws.apache.org/ns/synapse" xmlns:f="http://hl7.org/fhir" 

那么你当然可以使日志输出,以验证您的XPath表达式(非常有用):

<log level="custom"> 
    <property name="yourXPathTest" expression="$body/f:Prescription/f:identifier/f:id/@value"/> 
</log> 
1

你在做什么逻辑上不是正确。如果没有在inSequence中放置迭代介体,则无法在inSequence中聚合消息。 克隆/迭代和聚合介体之间有相关性。您只能聚合在同一个代理服务中分割或克隆的消息。