xml – 强制Spring Web服务将xsd命名空间添加到响应中
发布时间:2020-12-16 22:53:43 所属栏目:百科 来源:网络整理
导读:我正在使用 Spring WS 1.5.8版.我的回答如下: SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:Header/ SOAP-ENV:Body ... /SOAP-ENV:Body /SOAP-ENV:Envelope 但是,我的客户端(我与之集成)要求我添加更多的命名空
我正在使用
Spring WS 1.5.8版.我的回答如下:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> ... </SOAP-ENV:Body> </SOAP-ENV:Envelope> 但是,我的客户端(我与之集成)要求我添加更多的命名空间declerations以便解析成功: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> ... </soapenv:Body> </soapenv:Envelope> 我该怎么做? 解决方法
您可能不需要我告诉您任何需要某些命名空间声明的SOAP客户端,当文档中未使用这些命名空间时,会被破坏.所以我不会提到这一点.
但是,如果您确实希望改变响应,可以使用EndpointInterceptor,特别是SoapEndpointInterceptor.您可以连接端点拦截器as described here. 您的自定义拦截器可以实现handleResponse方法,将messageContext.getResponse()转换为SoapMessage并添加您需要的任何内容: public class MyInterceptor implements SoapEndpointInterceptor { public boolean handleResponse(MessageContext messageContext,Object endpoint) throws Exception { SoapMessage message = (SoapMessage) messageContext.getResponse(); message.getEnvelope().addNamespaceDeclaration(....); return true; } // ... other methods here } 但是,添加这样的低级命名空间声明可能会产生副作用,因此请谨慎行事. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- objective-c – 用于检测iPad的预处理器指令
- Cocos2d-x源码阅读1 UI树1(第一次系统而有成效的阅读源码的
- 使用COALESCE来处理PostgreSQL中的NULL值
- 使用记事本编写xml文件保存出现异常原因
- 在C#中等效的Ajax帖子
- XML(3)XDocument与XmlDocument递归读取xml文件
- objective-c – 缺少标识符IBFilesOwner的代理
- xml文件不能被正确解析/The processing instruction target
- SSDB:一个高性能的支持丰富数据结构的 NoSQL 数据库, 用于
- react-native – 如何使用react本机应用程序将数据发送到服