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 public class SOAPConnector extends AbstractServiceConnector {
40
41 public SOAPConnector(final SoapServiceConfiguration serviceConfiguration, final URL alternateEndpointUrl) {
42 super(serviceConfiguration, alternateEndpointUrl);
43 }
44
45 @Override
46 public SoapServiceConfiguration getServiceConfiguration() {
47 return (SoapServiceConfiguration) super.getServiceConfiguration();
48 }
49
50
51
52
53
54
55 public Object getService() {
56 ClientProxyFactoryBean clientFactory;
57
58
59 if (getServiceConfiguration().isJaxWsService()){
60 clientFactory = new JaxWsProxyFactoryBean();
61 } else {
62 clientFactory = new ClientProxyFactoryBean();
63 clientFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
64 }
65
66 try {
67 clientFactory.setServiceClass(Class.forName(getServiceConfiguration().getServiceInterface()));
68 } catch (ClassNotFoundException e) {
69 throw new RiceRuntimeException("Failed to connect to soap service " + getServiceConfiguration().getServiceName() + " because failed to load interface class: " + getServiceConfiguration().getServiceInterface(), e);
70 }
71 clientFactory.setBus(KSBServiceLocator.getCXFBus());
72 clientFactory.setServiceName(getServiceConfiguration().getServiceName());
73 clientFactory.setAddress(getActualEndpointUrl().toExternalForm());
74
75
76 clientFactory.getOutInterceptors().add(new LoggingOutInterceptor());
77 clientFactory.getOutInterceptors().add(new CXFWSS4JOutInterceptor(getServiceConfiguration().getBusSecurity()));
78 if (getCredentialsSource() != null) {
79 clientFactory.getOutInterceptors().add(new CredentialsOutHandler(getCredentialsSource(), getServiceConfiguration()));
80 }
81
82 clientFactory.getInInterceptors().add(new LoggingInInterceptor());
83 clientFactory.getInInterceptors().add(new CXFWSS4JInInterceptor(getServiceConfiguration().getBusSecurity()));
84 clientFactory.getInInterceptors().add(new ImmutableCollectionsInInterceptor());
85
86
87 Object service = clientFactory.create();
88 return getServiceProxyWithFailureMode(service, getServiceConfiguration());
89 }
90 }