1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ksb.messaging.serviceconnectors; |
17 | |
|
18 | |
import java.net.URL; |
19 | |
|
20 | |
import org.apache.cxf.aegis.databinding.AegisDatabinding; |
21 | |
import org.apache.cxf.frontend.ClientProxyFactoryBean; |
22 | |
import org.apache.cxf.interceptor.LoggingInInterceptor; |
23 | |
import org.apache.cxf.interceptor.LoggingOutInterceptor; |
24 | |
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; |
25 | |
import org.kuali.rice.core.api.exception.RiceRuntimeException; |
26 | |
import org.kuali.rice.core.cxf.interceptors.ImmutableCollectionsInInterceptor; |
27 | |
import org.kuali.rice.ksb.api.bus.support.SoapServiceConfiguration; |
28 | |
import org.kuali.rice.ksb.security.soap.CXFWSS4JInInterceptor; |
29 | |
import org.kuali.rice.ksb.security.soap.CXFWSS4JOutInterceptor; |
30 | |
import org.kuali.rice.ksb.security.soap.CredentialsOutHandler; |
31 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class SOAPConnector extends AbstractServiceConnector { |
40 | |
|
41 | |
public SOAPConnector(final SoapServiceConfiguration serviceConfiguration, final URL alternateEndpointUrl) { |
42 | 0 | super(serviceConfiguration, alternateEndpointUrl); |
43 | 0 | } |
44 | |
|
45 | |
@Override |
46 | |
public SoapServiceConfiguration getServiceConfiguration() { |
47 | 0 | return (SoapServiceConfiguration) super.getServiceConfiguration(); |
48 | |
} |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
public Object getService() { |
56 | |
ClientProxyFactoryBean clientFactory; |
57 | |
|
58 | |
|
59 | 0 | if (getServiceConfiguration().isJaxWsService()){ |
60 | 0 | clientFactory = new JaxWsProxyFactoryBean(); |
61 | |
} else { |
62 | 0 | clientFactory = new ClientProxyFactoryBean(); |
63 | 0 | clientFactory.getServiceFactory().setDataBinding(new AegisDatabinding()); |
64 | |
} |
65 | |
|
66 | |
try { |
67 | 0 | clientFactory.setServiceClass(Class.forName(getServiceConfiguration().getServiceInterface())); |
68 | 0 | } catch (ClassNotFoundException e) { |
69 | 0 | throw new RiceRuntimeException("Failed to connect to soap service " + getServiceConfiguration().getServiceName() + " because failed to load interface class: " + getServiceConfiguration().getServiceInterface(), e); |
70 | 0 | } |
71 | 0 | clientFactory.setBus(KSBServiceLocator.getCXFBus()); |
72 | 0 | clientFactory.setServiceName(getServiceConfiguration().getServiceName()); |
73 | 0 | clientFactory.setAddress(getActualEndpointUrl().toExternalForm()); |
74 | |
|
75 | |
|
76 | 0 | clientFactory.getOutInterceptors().add(new LoggingOutInterceptor()); |
77 | 0 | clientFactory.getOutInterceptors().add(new CXFWSS4JOutInterceptor(getServiceConfiguration().getBusSecurity())); |
78 | 0 | if (getCredentialsSource() != null) { |
79 | 0 | clientFactory.getOutInterceptors().add(new CredentialsOutHandler(getCredentialsSource(), getServiceConfiguration())); |
80 | |
} |
81 | |
|
82 | 0 | clientFactory.getInInterceptors().add(new LoggingInInterceptor()); |
83 | 0 | clientFactory.getInInterceptors().add(new CXFWSS4JInInterceptor(getServiceConfiguration().getBusSecurity())); |
84 | 0 | clientFactory.getInInterceptors().add(new ImmutableCollectionsInInterceptor()); |
85 | |
|
86 | |
|
87 | 0 | Object service = clientFactory.create(); |
88 | 0 | return getServiceProxyWithFailureMode(service, getServiceConfiguration()); |
89 | |
} |
90 | |
} |