1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
package org.apache.geronimo.ews.jaxrpcmapping;
|
17
|
|
|
18
|
|
import com.sun.java.xml.ns.j2Ee.ExceptionMappingType;
|
19
|
|
import com.sun.java.xml.ns.j2Ee.JavaWsdlMappingDocument;
|
20
|
|
import com.sun.java.xml.ns.j2Ee.JavaWsdlMappingType;
|
21
|
|
import com.sun.java.xml.ns.j2Ee.JavaXmlTypeMappingType;
|
22
|
|
import com.sun.java.xml.ns.j2Ee.MethodParamPartsMappingType;
|
23
|
|
import com.sun.java.xml.ns.j2Ee.PackageMappingType;
|
24
|
|
import com.sun.java.xml.ns.j2Ee.PortMappingType;
|
25
|
|
import com.sun.java.xml.ns.j2Ee.ServiceEndpointInterfaceMappingType;
|
26
|
|
import com.sun.java.xml.ns.j2Ee.ServiceEndpointMethodMappingType;
|
27
|
|
import com.sun.java.xml.ns.j2Ee.ServiceInterfaceMappingType;
|
28
|
|
import com.sun.java.xml.ns.j2Ee.WsdlReturnValueMappingType;
|
29
|
|
import com.sun.java.xml.ns.j2Ee.XsdQNameType;
|
30
|
|
import org.apache.axis.wsdl.symbolTable.BindingEntry;
|
31
|
|
import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
|
32
|
|
import org.apache.axis.wsdl.symbolTable.ServiceEntry;
|
33
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
34
|
|
import org.apache.xmlbeans.XmlException;
|
35
|
|
|
36
|
|
import javax.wsdl.Binding;
|
37
|
|
import javax.wsdl.Operation;
|
38
|
|
import javax.wsdl.Port;
|
39
|
|
import javax.wsdl.PortType;
|
40
|
|
import javax.xml.namespace.QName;
|
41
|
|
import java.io.FileInputStream;
|
42
|
|
import java.io.FileNotFoundException;
|
43
|
|
import java.io.IOException;
|
44
|
|
import java.io.InputStream;
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
|
public class XMLBeansJaxRpcMapper implements JaxRpcMapper {
|
50
|
|
|
51
|
|
private JavaWsdlMappingType mapping;
|
52
|
|
|
53
|
|
private boolean wrappedElement = false;
|
54
|
|
|
55
|
0
|
public void loadMappingFromInputStream(InputStream is) throws GenerationFault {
|
56
|
0
|
try {
|
57
|
0
|
JavaWsdlMappingDocument mappingdoc = JavaWsdlMappingDocument.Factory.parse(is);
|
58
|
0
|
mapping = mappingdoc.getJavaWsdlMapping();
|
59
|
|
} catch (XmlException e) {
|
60
|
0
|
e.printStackTrace();
|
61
|
0
|
throw GenerationFault.createGenerationFault(e);
|
62
|
|
} catch (IOException e) {
|
63
|
0
|
e.printStackTrace();
|
64
|
0
|
throw GenerationFault.createGenerationFault(e);
|
65
|
|
}
|
66
|
0
|
wrappedElement = checkWrappedElemente();
|
67
|
|
}
|
68
|
|
|
69
|
18
|
public void loadMappingFromDir(String path) throws GenerationFault {
|
70
|
18
|
try {
|
71
|
18
|
java.io.InputStream fis = new FileInputStream(path);
|
72
|
18
|
JavaWsdlMappingDocument mappingdoc = JavaWsdlMappingDocument.Factory.parse(fis);
|
73
|
18
|
mapping = mappingdoc.getJavaWsdlMapping();
|
74
|
|
} catch (FileNotFoundException e2) {
|
75
|
0
|
e2.printStackTrace();
|
76
|
0
|
throw GenerationFault.createGenerationFault(e2);
|
77
|
|
} catch (IOException e) {
|
78
|
0
|
e.printStackTrace();
|
79
|
0
|
throw GenerationFault.createGenerationFault(e);
|
80
|
|
} catch (XmlException e2) {
|
81
|
0
|
e2.printStackTrace();
|
82
|
0
|
throw GenerationFault.createGenerationFault(e2);
|
83
|
|
}
|
84
|
18
|
wrappedElement = checkWrappedElemente();
|
85
|
|
}
|
86
|
|
|
87
|
18
|
public int getPackageMappingCount() {
|
88
|
18
|
PackageMappingType[] packagemapping = mapping.getPackageMappingArray();
|
89
|
18
|
return packagemapping.length;
|
90
|
|
}
|
91
|
|
|
92
|
18
|
public String getPackageMappingClassName(int index) {
|
93
|
18
|
PackageMappingType[] packagemapping = mapping.getPackageMappingArray();
|
94
|
18
|
return packagemapping[index].getPackageType().getStringValue();
|
95
|
|
}
|
96
|
|
|
97
|
18
|
public String getPackageMappingURI(int index) {
|
98
|
18
|
PackageMappingType[] packagemapping = mapping.getPackageMappingArray();
|
99
|
18
|
return packagemapping[index].getNamespaceURI().getStringValue();
|
100
|
|
}
|
101
|
|
|
102
|
|
|
103
|
|
|
104
|
|
|
105
|
0
|
public JavaWsdlMappingType getMapping() {
|
106
|
0
|
return mapping;
|
107
|
|
}
|
108
|
|
|
109
|
83
|
public String getJavaType(QName typeQName) {
|
110
|
83
|
if (mapping == null) {
|
111
|
0
|
return null;
|
112
|
|
}
|
113
|
83
|
JavaXmlTypeMappingType[] typeList = mapping.getJavaXmlTypeMappingArray();
|
114
|
83
|
for (int i = 0; i < typeList.length; i++) {
|
115
|
118
|
JavaXmlTypeMappingType typeMapping = typeList[i];
|
116
|
118
|
XsdQNameType rootType = typeMapping.getRootTypeQname();
|
117
|
118
|
if (rootType == null) {
|
118
|
0
|
String mappedAnonymousTypeName = typeMapping.getAnonymousTypeQname().getStringValue();
|
119
|
0
|
String localPart = typeQName.getLocalPart();
|
120
|
0
|
String revisitedTypeQName = typeQName.getNamespaceURI() + ":" + localPart;
|
121
|
0
|
if (mappedAnonymousTypeName.equals(revisitedTypeQName)) {
|
122
|
|
|
123
|
0
|
return J2eeUtils.jni2javaName(typeMapping.getJavaType().getStringValue());
|
124
|
|
}
|
125
|
|
} else {
|
126
|
118
|
QName typeName = rootType.getQNameValue();
|
127
|
118
|
if (typeQName.equals(typeName)) {
|
128
|
11
|
String className = typeMapping.getJavaType().getStringValue();
|
129
|
|
|
130
|
11
|
return J2eeUtils.jni2javaName(className);
|
131
|
|
}
|
132
|
|
}
|
133
|
|
}
|
134
|
72
|
return null;
|
135
|
|
}
|
136
|
|
|
137
|
4
|
public String getExceptionType(QName messageQName) {
|
138
|
4
|
if (mapping == null) {
|
139
|
0
|
return null;
|
140
|
|
}
|
141
|
4
|
ExceptionMappingType[] exceptionMappingList = mapping.getExceptionMappingArray();
|
142
|
4
|
for (int j = 0; j < exceptionMappingList.length; j++) {
|
143
|
4
|
ExceptionMappingType exceptionMapping = exceptionMappingList[j];
|
144
|
4
|
QName name = exceptionMapping.getWsdlMessage().getQNameValue();
|
145
|
4
|
if (messageQName.equals(name)) {
|
146
|
4
|
return exceptionMapping.getExceptionType().getStringValue();
|
147
|
|
}
|
148
|
|
}
|
149
|
0
|
return null;
|
150
|
|
}
|
151
|
|
|
152
|
18
|
public String getPortName(Port port) {
|
153
|
18
|
if (mapping == null) {
|
154
|
0
|
return null;
|
155
|
|
}
|
156
|
18
|
ServiceInterfaceMappingType[] serviceList = mapping.getServiceInterfaceMappingArray();
|
157
|
18
|
String portName = port.getName();
|
158
|
18
|
for (int i = 0; i < serviceList.length; i++) {
|
159
|
14
|
PortMappingType[] portList = serviceList[i].getPortMappingArray();
|
160
|
14
|
for (int j = 0; j < portList.length; j++) {
|
161
|
14
|
PortMappingType portMapping = portList[j];
|
162
|
14
|
String mappedPortName = portMapping.getPortName().getStringValue();
|
163
|
14
|
if (portName.equals(mappedPortName)) {
|
164
|
12
|
String javaPortName = portMapping.getJavaPortName().getStringValue();
|
165
|
12
|
return javaPortName;
|
166
|
|
}
|
167
|
|
}
|
168
|
|
}
|
169
|
6
|
return null;
|
170
|
|
}
|
171
|
|
|
172
|
19
|
public String getServiceInterfaceName(ServiceEntry entry) {
|
173
|
19
|
if (mapping == null) {
|
174
|
0
|
return null;
|
175
|
|
}
|
176
|
19
|
ServiceInterfaceMappingType[] serviceList = mapping.getServiceInterfaceMappingArray();
|
177
|
19
|
QName entryQName = entry.getQName();
|
178
|
19
|
for (int i = 0; i < serviceList.length; i++) {
|
179
|
15
|
QName wsdlServiceName = serviceList[i].getWsdlServiceName().getQNameValue();
|
180
|
15
|
if (entryQName.equals(wsdlServiceName)) {
|
181
|
15
|
String serviceInterfaceName = serviceList[i].getServiceInterface().getStringValue();
|
182
|
15
|
return serviceInterfaceName;
|
183
|
|
}
|
184
|
|
}
|
185
|
4
|
return null;
|
186
|
|
}
|
187
|
|
|
188
|
30
|
public String getServiceEndpointInterfaceName(PortTypeEntry ptEntry, BindingEntry bEntry) {
|
189
|
30
|
if (mapping == null) {
|
190
|
0
|
return null;
|
191
|
|
}
|
192
|
30
|
ServiceEndpointInterfaceMappingType[] serviceList = mapping.getServiceEndpointInterfaceMappingArray();
|
193
|
30
|
Binding binding = bEntry.getBinding();
|
194
|
30
|
PortType portType = ptEntry.getPortType();
|
195
|
30
|
QName bindingQName = binding.getQName();
|
196
|
30
|
QName portTypeQName = portType.getQName();
|
197
|
30
|
for (int i = 0; i < serviceList.length; i++) {
|
198
|
26
|
QName wsdlBinging = serviceList[i].getWsdlBinding().getQNameValue();
|
199
|
26
|
QName wsdlPortType = serviceList[i].getWsdlPortType().getQNameValue();
|
200
|
26
|
if ((bindingQName.equals(wsdlBinging)) && (portTypeQName.equals(wsdlPortType))) {
|
201
|
26
|
String endpointServiceName =
|
202
|
|
serviceList[i].getServiceEndpointInterface().getStringValue();
|
203
|
26
|
return endpointServiceName;
|
204
|
|
}
|
205
|
|
}
|
206
|
4
|
return null;
|
207
|
|
}
|
208
|
|
|
209
|
|
|
210
|
|
|
211
|
|
|
212
|
|
|
213
|
|
|
214
|
|
|
215
|
166
|
public String getJavaMethodParamType(BindingEntry bEntry, Operation operation, int position) {
|
216
|
166
|
if (mapping == null) {
|
217
|
0
|
return null;
|
218
|
|
}
|
219
|
166
|
ServiceEndpointInterfaceMappingType[] serviceList = mapping.getServiceEndpointInterfaceMappingArray();
|
220
|
166
|
Binding binding = bEntry.getBinding();
|
221
|
166
|
QName bindingQName = binding.getQName();
|
222
|
166
|
PortType portType = binding.getPortType();
|
223
|
166
|
QName portTypeQName = portType.getQName();
|
224
|
166
|
for (int i = 0; i < serviceList.length; i++) {
|
225
|
124
|
QName wsdlBinging = serviceList[i].getWsdlBinding().getQNameValue();
|
226
|
124
|
QName wsdlPortType = serviceList[i].getWsdlPortType().getQNameValue();
|
227
|
124
|
if ((bindingQName.equals(wsdlBinging)) && (portTypeQName.equals(wsdlPortType))) {
|
228
|
124
|
ServiceEndpointMethodMappingType[] methodList = serviceList[i].getServiceEndpointMethodMappingArray();
|
229
|
124
|
String operationName = operation.getName();
|
230
|
124
|
for (int k = 0; k < methodList.length; k++) {
|
231
|
683
|
ServiceEndpointMethodMappingType methodMapping = methodList[k];
|
232
|
683
|
String mappedOperationName = methodMapping.getWsdlOperation().getStringValue();
|
233
|
683
|
if (operationName.equals(mappedOperationName)) {
|
234
|
111
|
MethodParamPartsMappingType[] paramList = methodMapping.getMethodParamPartsMappingArray();
|
235
|
111
|
for (int m = 0; m < paramList.length; m++) {
|
236
|
3
|
MethodParamPartsMappingType paramPart = paramList[m];
|
237
|
3
|
if (paramPart.getParamPosition().getBigIntegerValue().intValue() == position) {
|
238
|
|
|
239
|
3
|
return J2eeUtils.jni2javaName(paramPart.getParamType().getStringValue());
|
240
|
|
}
|
241
|
|
}
|
242
|
|
}
|
243
|
|
}
|
244
|
|
}
|
245
|
|
}
|
246
|
163
|
return null;
|
247
|
|
}
|
248
|
|
|
249
|
18
|
public boolean checkWrappedElemente() {
|
250
|
18
|
if (mapping == null) {
|
251
|
0
|
return false;
|
252
|
|
}
|
253
|
18
|
ServiceEndpointInterfaceMappingType[] serviceList = mapping.getServiceEndpointInterfaceMappingArray();
|
254
|
18
|
for (int i = 0; i < serviceList.length; i++) {
|
255
|
14
|
ServiceEndpointMethodMappingType[] methodList = serviceList[i].getServiceEndpointMethodMappingArray();
|
256
|
14
|
for (int k = 0; k < methodList.length; k++) {
|
257
|
42
|
ServiceEndpointMethodMappingType methodMapping = methodList[k];
|
258
|
42
|
if (methodMapping.getWrappedElement() != null) {
|
259
|
|
|
260
|
0
|
return true;
|
261
|
|
}
|
262
|
|
}
|
263
|
|
}
|
264
|
18
|
return false;
|
265
|
|
}
|
266
|
|
|
267
|
|
|
268
|
|
|
269
|
|
|
270
|
|
|
271
|
101
|
public String getJavaMethodReturnType(BindingEntry bEntry, Operation operation) {
|
272
|
101
|
if (mapping == null) {
|
273
|
0
|
return null;
|
274
|
|
}
|
275
|
101
|
ServiceEndpointInterfaceMappingType[] serviceList = mapping.getServiceEndpointInterfaceMappingArray();
|
276
|
101
|
Binding binding = bEntry.getBinding();
|
277
|
101
|
QName bindingQName = binding.getQName();
|
278
|
101
|
PortType portType = binding.getPortType();
|
279
|
101
|
QName portTypeQName = portType.getQName();
|
280
|
101
|
for (int i = 0; i < serviceList.length; i++) {
|
281
|
90
|
QName wsdlBinging = serviceList[i].getWsdlBinding().getQNameValue();
|
282
|
90
|
QName wsdlPortType = serviceList[i].getWsdlPortType().getQNameValue();
|
283
|
90
|
if ((bindingQName.equals(wsdlBinging)) && (portTypeQName.equals(wsdlPortType))) {
|
284
|
90
|
ServiceEndpointMethodMappingType[] methodList = serviceList[i].getServiceEndpointMethodMappingArray();
|
285
|
90
|
String operationName = operation.getName();
|
286
|
90
|
for (int k = 0; k < methodList.length; k++) {
|
287
|
391
|
ServiceEndpointMethodMappingType methodMapping = methodList[k];
|
288
|
391
|
String mappedOperationName = methodMapping.getWsdlOperation().getStringValue();
|
289
|
391
|
if (operationName.equals(mappedOperationName)) {
|
290
|
83
|
WsdlReturnValueMappingType returnValueMapping =
|
291
|
|
methodMapping.getWsdlReturnValueMapping();
|
292
|
83
|
if (returnValueMapping != null) {
|
293
|
|
|
294
|
73
|
return J2eeUtils.jni2javaName(returnValueMapping.getMethodReturnValue().getStringValue());
|
295
|
|
}
|
296
|
|
}
|
297
|
|
}
|
298
|
|
}
|
299
|
|
}
|
300
|
28
|
return null;
|
301
|
|
}
|
302
|
|
|
303
|
|
|
304
|
|
|
305
|
|
|
306
|
|
|
307
|
|
|
308
|
101
|
public String getJavaMethodName(BindingEntry bEntry, Operation operation) {
|
309
|
101
|
if (mapping == null) {
|
310
|
0
|
return null;
|
311
|
|
}
|
312
|
101
|
ServiceEndpointInterfaceMappingType[] serviceList = mapping.getServiceEndpointInterfaceMappingArray();
|
313
|
101
|
Binding binding = bEntry.getBinding();
|
314
|
101
|
QName bindingQName = binding.getQName();
|
315
|
101
|
PortType portType = binding.getPortType();
|
316
|
101
|
QName portTypeQName = portType.getQName();
|
317
|
101
|
for (int i = 0; i < serviceList.length; i++) {
|
318
|
90
|
QName wsdlBinging = serviceList[i].getWsdlBinding().getQNameValue();
|
319
|
90
|
QName wsdlPortType = serviceList[i].getWsdlPortType().getQNameValue();
|
320
|
90
|
if ((bindingQName.equals(wsdlBinging)) && (portTypeQName.equals(wsdlPortType))) {
|
321
|
90
|
ServiceEndpointMethodMappingType[] methodList = serviceList[i].getServiceEndpointMethodMappingArray();
|
322
|
90
|
String operationName = operation.getName();
|
323
|
90
|
for (int k = 0; k < methodList.length; k++) {
|
324
|
353
|
ServiceEndpointMethodMappingType methodMapping = methodList[k];
|
325
|
353
|
String mappedOperationName = methodMapping.getWsdlOperation().getStringValue();
|
326
|
353
|
if (operationName.equals(mappedOperationName)) {
|
327
|
83
|
return methodMapping.getJavaMethodName().getStringValue();
|
328
|
|
}
|
329
|
|
}
|
330
|
|
}
|
331
|
|
}
|
332
|
18
|
return null;
|
333
|
|
}
|
334
|
|
|
335
|
|
|
336
|
|
|
337
|
|
|
338
|
18
|
public boolean hasWrappedElement() {
|
339
|
18
|
return wrappedElement;
|
340
|
|
}
|
341
|
|
}
|
342
|
|
|