3
我正在使用Java和Spring-ws构建Web服务。它工作正常,除了一件事。在WS SOAP体中不能转义字符
当我将有效载荷组装到SOAP Body中时,我想包含CDATA转义字符串。这就是我想要的结果看起来像:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:_0="http://example.com/ns">
<soapenv:Header/>
<soapenv:Body>
<_0:Message>
<_0:StringPayload><![CDATA[<myxml>stuff</myxml>]]></_0:StringPayload>
</_0:Message>
</soapenv:Body>
</soapenv:Envelope>
然而,春天-WS似乎与有效载荷篡改时,增加了SOAP信封。这是我得到的结果:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:_0="http://example.com/ns">
<soapenv:Header/>
<soapenv:Body>
<_0:Message>
<_0:StringPayload><myxml>stuff</myxml></StringPayload>
</_0:Message>
</soapenv:Body>
</soapenv:Envelope>
有没有办法确保Spring WS不会转义XML字符并尊重CDATA标记?
我正在使用Spring WS和Apache Camel,所以我不需要改变/扩展spring-ws类的解决方案。
你使用了什么'org.springframework.ws.soap.SoapMessageFactory'实现(axiom?saaj?)?你使用了什么'org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler'(marshalling,jaxb,castor,'AbstractPayloadSourceMethodProcessor')? – 2012-04-13 08:23:21
为什么?对于XML解析器和Web服务堆栈,这两者是等效的。 – 2012-04-13 08:38:04
@GrzegorzGrzybek该消息属于SAAJ类型。我不确定哪个MethodReturnValueHandler正在使用,但我认为这将是JAXB。 – 2012-04-13 09:37:53