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