Reputation: 1
I am working on spring boot soap-ws project with contract last approach using CXF. I have xml request from a client as below.
<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>
The service is not accepting the above request. I would like to change the xml request to below(service accepts below message). The arg0 should have an added empty namespace.
<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>
Can someone help me on how I can achieve this?
Upvotes: 0
Views: 805
Reputation: 1
I did some research and here is the answer. I have created a below class and implemented the handlemethod of extended class. The handlemethod does all the xml modification.
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 {
}
}
And, then I added the new interceptor class in my webserviceconfig class.
EndpointImpl endpoint = new EndpointImpl(bus, "service-class-name");
endpoint.getInInterceptors().add(new InvalidCharInterceptor());
FYI..Apache cxf has detailed explanation on interceptors. https://cxf.apache.org/docs/interceptors.html
Upvotes: 0