我有一个要求,其中我需要使用XML有效负载公开一个restful服务。之后,我需要获取xml有效负载并使用xslt转换器将其转换为不同的xml。
我正在努力解决如何获取xml有效负载,它可以作为xslt转换器的输入。
我想避免marshelling和开销过高。
有人可以帮助我。
此致 拉利特
答案 0 :(得分:1)
当提出这样的问题时,如果你展示你尝试过的和不起作用的东西,那就更好了。
在这种情况下,您只需要HTTP Inbound Gateway。
如果传入的content-type
包含文字;默认情况下,有效负载为String
。如果不是(例如application/xml
),那么您将需要使用您想要的类型配置网关...
request-payload-type="java.lang.String"
否则,有效载荷将为byte[]
。
答案 1 :(得分:0)
基于加里的建议......使用以下代码,它有效......
<int:channel id="inputChannel"></int:channel>
<int-http:inbound-gateway request-channel="inputChannel" path="/test" supported-methods="POST">
<int-http:request-mapping consumes="application/xml" produces="application/xml" />
</int-http:inbound-gateway>
<int:chain input-channel="inputChannel">
<int:service-activator ref="sa1"></int:service-activator>
<int-xml:xslt-transformer
xsl-resource="classpath:/testTransformer.xsl"/>
<int:service-activator ref="sa2"></int:service-activator>
</int:chain>
<!-- input type is byte[] -->
<bean id="sa1" class="com.fidintl.integration.ServiceActivator1">
</bean>
<!-- input type is String -->
<bean id="sa2" class="com.fidintl.integration.ServiceActivator2"></bean>
看起来像post(正如Gary提到的)输出是byte [],我在ServiceActivator1中将其转换为字符串
此致 Lalit Kumar