spring-boot cxf-soap-ws-modify命名空间



我正在使用CXF进行spring-boot-soap-ws项目,该项目采用合同最后一种方法。我有一个客户端的xml请求,如下所示。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<teen xmlns="some url">
<!--Optional:-->
<arg0>
//DATA
</arg0>
</teen>
</soapenv:Body>
</soapenv:Envelope>

该服务不接受上述请求。我想将xml请求更改为下面的(服务接受下面的消息(。arg0应添加一个空命名空间。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:se>
<soapenv:Header/>
<soapenv:Body>
<teen xmlns="some url">
<!--Optional:-->
<arg0 xmlns="">
//DATA
</arg0>
</teen>
</soapenv:Body>
</soapenv:Envelope>

有人能帮助我如何做到这一点吗?

我做了一些研究,下面是答案。我创建了一个下面的类,并实现了扩展类的句柄方法。handlemethod完成所有xml修改。

public class InvalidCharInterceptor extends AbstractPhaseInterceptor<Message> {

public InvalidCharInterceptor() {
super(Phase.RECEIVE); // This is important which determines at what point are we modifying the xml.
}
public void handleMessage(Message message) throws Fault {
}
}

然后,我在我的webserviceconfig类中添加了新的拦截器类。

EndpointImpl endpoint = new EndpointImpl(bus, "service-class-name");
endpoint.getInInterceptors().add(new InvalidCharInterceptor());

FYI。。Apache cxf有关于拦截器的详细解释。https://cxf.apache.org/docs/interceptors.html

最新更新