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