我在自己的wso2代理服务中有一个自定义介体,它将传入的xml转换为另一种格式,并转而由代理将其转发给jms队列。但是xml格式不正确。它是这个样子的控制台和队列:WSO2自定义介体未以正确的xml格式返回
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Envelope xmlns:ws="http://isova.wipro.com/">
<arg0><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></arg0>
</soapenv:Envelope>
</soapenv:Body>
</soapenv:Envelope>
我的代理服务:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="risresult"
transports="https,http,jms" statistics="disable" trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="ContentType" value="text/plain" scope="default"
type="STRING" />
<class name="com.test.guru.HL7RISPrescription" />
<property name="RESPONSE" value="true" />
<header name="To" action="remove" />
<send>
<endpoint>
<address
uri="jms:/prescription?
transport.jms.ConnectionFactoryJNDIName
=QueueConnectionFactory&java.naming.
factory.initial=org.apache.activemq.jndi.
ActiveMQInitialContextFactory&java.
naming.provider.url=tcp://localhost:61616" />
</endpoint>
</send>
</inSequence>
<outSequence>
<drop />
</outSequence>
<faultSequence />
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<description></description>
</proxy>
可能是什么原因呢?是因为axis2元素的问题吗?
我的中介类有这些最后陈述:
OMFactory factoryOM = OMAbstractFactory.getOMFactory();
OMElement code = factoryOM.createOMElement("arg0","","");
code.setText(pdoc.toString());
axis2Element.addChild(code);
谢谢Shelan。我删除它,现在尝试,它没有帮助。它仍然给出同样的问题。对我有其他建议吗? – gnanagurus 2013-04-29 18:27:48
只是注意到在调解器中你使用的是code.setText(pdoc.toString());使用该字符串构建OMelement(未设置文本),然后添加为arg0的子元素。您将它设置为文本而不是xml元素。 – 2013-04-29 18:34:31
参考此转换。 http://www.keith-chapman.org/2008/10/axiom-how-to-crate-omelement-from.html – 2013-04-29 18:36:06