1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.ws.cxf;
17
18 import org.apache.cxf.binding.soap.Soap12;
19 import org.apache.cxf.binding.soap.SoapMessage;
20 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
21 import org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor;
22 import org.apache.cxf.interceptor.Fault;
23 import org.apache.cxf.message.Message;
24 import org.apache.cxf.phase.Phase;
25
26 import java.util.regex.Pattern;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class Cxf3791WorkaroundInterceptor extends AbstractSoapInterceptor {
42 static final Pattern PATTERN = Pattern.compile(";\\s*action\\s*=\\s*(\"?)[\\S&&[^\"]]+(\\1)\\s*");
43
44 public Cxf3791WorkaroundInterceptor() {
45 super(Phase.READ);
46 addBefore(SoapActionInInterceptor.class.getName());
47 }
48
49 @Override
50 public void handleMessage(SoapMessage message) throws Fault {
51 if (message.getVersion() instanceof Soap12) {
52 String s = (String) message.get(Message.CONTENT_TYPE);
53 if (s != null) {
54 s = PATTERN.matcher(s).replaceFirst("");
55 message.put(Message.CONTENT_TYPE, s);
56 }
57 }
58 }
59 }