1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.ws.beans; |
17 | |
|
18 | |
import java.net.URL; |
19 | |
|
20 | |
import javax.xml.namespace.QName; |
21 | |
import javax.xml.ws.BindingProvider; |
22 | |
import javax.xml.ws.Service; |
23 | |
|
24 | |
import org.springframework.core.io.ClassPathResource; |
25 | |
|
26 | 0 | public class JaxWsClientFactoryBean implements JaxWsClientFactory { |
27 | 0 | private Class<?> serviceEndpointInterface = null; |
28 | 0 | private String wsdlDocumentLocation = ""; |
29 | 0 | private QName serviceQName = null; |
30 | 0 | private String serviceUrl = ""; |
31 | |
private static final String CLASSPATH_PREFIX = "classpath:"; |
32 | |
private Object client; |
33 | |
|
34 | |
@Override |
35 | |
public synchronized Object getObject() throws Exception { |
36 | 0 | if(client==null){ |
37 | |
URL url; |
38 | 0 | if (wsdlDocumentLocation.startsWith(CLASSPATH_PREFIX)) { |
39 | 0 | ClassPathResource cpr = new ClassPathResource(wsdlDocumentLocation.substring(CLASSPATH_PREFIX.length())); |
40 | 0 | url = cpr.getURL(); |
41 | 0 | } else { |
42 | 0 | url = new URL(wsdlDocumentLocation); |
43 | |
} |
44 | 0 | Service service = Service.create(url, serviceQName); |
45 | 0 | client = service.getPort(serviceEndpointInterface); |
46 | |
|
47 | 0 | if (this.serviceUrl != null && !"".equals(this.serviceUrl)) { |
48 | 0 | ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.serviceUrl); |
49 | |
} |
50 | |
} |
51 | |
|
52 | 0 | return client; |
53 | |
} |
54 | |
|
55 | |
@Override |
56 | |
public Class<?> getObjectType() { |
57 | 0 | return serviceEndpointInterface; |
58 | |
} |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public Class<?> getServiceEndpointInterface() { |
64 | 0 | return serviceEndpointInterface; |
65 | |
} |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
public void setServiceEndpointInterface(Class<?> serviceEndpointInterface) { |
72 | 0 | this.serviceEndpointInterface = serviceEndpointInterface; |
73 | 0 | } |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
public void setServiceQNameString(String serviceName) { |
81 | 0 | this.serviceQName = QName.valueOf(serviceName); |
82 | 0 | } |
83 | |
|
84 | |
@Override |
85 | |
public boolean isSingleton() { |
86 | 0 | return true; |
87 | |
} |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public String getWsdlLocation() { |
93 | 0 | return wsdlDocumentLocation; |
94 | |
} |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public void setWsdlLocation(String wsdlDocumentLocation) { |
101 | 0 | this.wsdlDocumentLocation = wsdlDocumentLocation; |
102 | 0 | } |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public String getAddress() { |
108 | 0 | return serviceUrl; |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public void setAddress(String add) { |
116 | 0 | this.serviceUrl = add; |
117 | 0 | } |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public QName getServiceQName() { |
123 | 0 | return serviceQName; |
124 | |
} |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public void setServiceQName(QName serviceQName) { |
130 | 0 | this.serviceQName = serviceQName; |
131 | 0 | } |
132 | |
|
133 | |
@Override |
134 | |
public QName getServiceName() { |
135 | 0 | return serviceQName; |
136 | |
} |
137 | |
|
138 | |
@Override |
139 | |
public void setServiceName(QName serviceName) { |
140 | 0 | this.serviceQName = serviceName; |
141 | 0 | } |
142 | |
|
143 | |
} |