我在自己的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