1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.spring;
17
18 import java.util.Set;
19
20 import javax.jws.WebService;
21
22 import org.kuali.rice.ksb.api.bus.support.ServiceBusExporter;
23 import org.kuali.rice.ksb.api.bus.support.SoapServiceDefinition;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26 import org.springframework.beans.factory.BeanCreationException;
27 import org.springframework.beans.factory.InitializingBean;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 public class KualiWebServiceExporter extends ServiceBusExporter implements
68 InitializingBean {
69
70 private static Logger log = LoggerFactory
71 .getLogger(KualiWebServiceExporter.class);
72
73 private Object webService;
74
75 private boolean busSecurity = true;
76
77
78
79
80 public KualiWebServiceExporter() {
81 super();
82
83 }
84
85
86
87
88
89 public void setWebService(Object webService) {
90 this.webService = webService;
91 }
92
93
94
95
96
97
98
99
100 @Override
101 public void afterPropertiesSet() {
102
103 if (getServiceDefinition() == null) {
104
105 if (webService == null)
106 throw new BeanCreationException("webService object must be set.");
107
108
109
110 SoapServiceDefinition def = new SoapServiceDefinition();
111
112 def.setJaxWsService(false);
113 def.setBusSecurity(busSecurity);
114
115 Set<Class<?>> webServiceInterfaceSet = AnnotationUtils
116 .extractInterfaceContainingAnnotation(webService,
117 WebService.class);
118
119 if (webServiceInterfaceSet.size() > 1)
120 throw new BeanCreationException(
121 "multiple interfaces exist with an @WebService annotation.");
122 else if (webServiceInterfaceSet.size() == 0)
123 throw new BeanCreationException(
124 "no interfaces exist with an @WebService annotation");
125
126 Class<?> webServiceInterfaceClass = webServiceInterfaceSet
127 .iterator().next();
128
129 WebService serviceAnnotation = webServiceInterfaceClass
130 .getAnnotation(WebService.class);
131
132 def.setService(webService);
133 def.setServiceInterface(webServiceInterfaceClass.getName());
134
135 String serviceName = serviceAnnotation.name();
136
137 if (serviceName == null)
138 throw new BeanCreationException("KualiWebServiceExporter: serviceName is not available for service: "
139 + webServiceInterfaceClass.getName());
140
141 String namespaceUri = serviceAnnotation.targetNamespace();
142
143 if (namespaceUri == null)
144 throw new BeanCreationException("KualiWebServiceExporter: namespaceUri is not availavble for service: "
145 + webServiceInterfaceClass.getName());
146
147 def.setLocalServiceName(serviceName);
148 def.setServiceNameSpaceURI(namespaceUri);
149
150 setServiceDefinition(def);
151
152 }
153
154
155
156 super.afterPropertiesSet();
157 }
158
159
160
161
162
163
164
165
166 public void setBusSecurity(boolean busSecurity) {
167 this.busSecurity = busSecurity;
168 }
169
170
171
172 }