Soap 使用拦截器更改CXF中的前缀

Soap 使用拦截器更改CXF中的前缀,soap,cxf,mule,mule-studio,Soap,Cxf,Mule,Mule Studio,我正在努力改变 到 我正在使用Mule和CXF。我们公开了一个SOAP服务,wsdl来自一个遗留系统(我们导入了它并生成了类)。有必要将前缀从“soap”更改为“s”。我认为这是有可能的拦截器,但由于某些原因,我不能使它工作。以下是我的拦截器的代码: 包se.comaround.interceptors; 导入java.util.HashMap; 导入java.util.Map; 导入org.apache.cxf.binding.soap.SoapMessage; 导入org.apac

我正在努力改变



我正在使用Mule和CXF。我们公开了一个SOAP服务,wsdl来自一个遗留系统(我们导入了它并生成了类)。有必要将前缀从“soap”更改为“s”。我认为这是有可能的拦截器,但由于某些原因,我不能使它工作。以下是我的拦截器的代码:

包se.comaround.interceptors;
导入java.util.HashMap;
导入java.util.Map;
导入org.apache.cxf.binding.soap.SoapMessage;
导入org.apache.cxf.phase.AbstractPhaseInterceptor;
导入org.apache.cxf.phase.phase;
公共类ComAroundSoapResponceInterceptor扩展
相位接收器{
公共ComAroundSoapResponceInterceptor(){
超级(阶段准备发送);
}
公共无效handleMessage(SoapMessage消息){
Map hmap=newhashmap();
hmap.put(“s”)http://schemas.xmlsoap.org/soap/envelope/");
message.setContextualProperty(“soap.env.ns.map”,hmap);
message.setContextualProperty(“disable.outputstream.optimization”,true);
System.out.println(“设置”);
}

}
经过一些测试,它成功了。这可能看起来非常愚蠢,我的下巴被咬了好几次,我重新启动,清除了所有现金,重新构建,当我添加一条额外的线时,拦截器似乎工作了,这是难以置信的,我知道:

包se.comaround.interceptors;
导入java.util.HashMap;
导入java.util.Map;
导入org.apache.cxf.binding.soap.SoapMessage;
导入org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
导入org.apache.cxf.phase.phase;
公共类ComAroundSoapResponceInterceptor
扩展抽象SOAPInterceptor{
公共ComAroundSoapResponceInterceptor(){
超级(阶段准备发送);
}
公共无效handleMessage(SoapMessage消息){
Map hmap=newhashmap();
hmap.put(“s”)http://schemas.xmlsoap.org/soap/envelope/");
message.put(“soap.env.ns.map”,hmap);
message.put(“disable.outputstream.optimization”,true);
}
}
我喝了一些咖啡,花了一些时间才明白它实际上是这样工作的。因此,他们在这里或多或少地建议:


您好,事实上,如果将message.setContextualProperty替换为message.put,则不需要调用message.getEnvelopeNs()。事实上,SoapMessage扩展了java映射,如果直接调用put,则不会检查现有键。