KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > tools > xmlbeans > SchemaCompiler


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.tools.xmlbeans;
19
20 import java.io.File JavaDoc;
21 import java.util.Collection JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.Set JavaDoc;
25 import java.util.Map JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.net.URI JavaDoc;
30
31 import org.apache.xmlbeans.SchemaTypeSystem;
32 import org.apache.xmlbeans.SchemaTypeLoader;
33 import org.apache.xmlbeans.XmlBeans;
34 import org.apache.xmlbeans.XmlOptions;
35 import org.apache.xmlbeans.XmlObject;
36 import org.apache.xmlbeans.XmlException;
37 import org.apache.xmlbeans.SimpleValue;
38 import org.apache.xmlbeans.impl.schema.ResourceLoader;
39 import org.apache.xmlbeans.impl.schema.StscState;
40 import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
41 import org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler;
42 import org.apache.xmlbeans.impl.schema.PathResourceLoader;
43 import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
44 import org.apache.xmlbeans.impl.common.XmlErrorContext;
45 import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator;
46 import org.apache.xmlbeans.impl.tool.CodeGenUtil;
47 import org.apache.xmlbeans.impl.tool.SchemaCompilerExtension;
48 import org.apache.xmlbeans.impl.tool.Extension;
49 import org.w3.x2001.xmlSchema.SchemaDocument;
50 import org.xml.sax.EntityResolver JavaDoc;
51 import com.bea.x2002.x09.xbean.config.ConfigDocument;
52
53 /**
54  * This is a slightly modified version of the xmlbeans v1 SchemaCompiler, enhanced to allow specification of
55  * an EntityResolver. Some parts not used in the maven plugin have also been removed.
56  *
57  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
58  *
59  * */

60 public class SchemaCompiler {
61     public static class Parameters
62     {
63         private File JavaDoc baseDir;
64         private File JavaDoc[] xsdFiles;
65         private File JavaDoc[] wsdlFiles;
66         private File JavaDoc[] javaFiles;
67         private File JavaDoc[] configFiles;
68         private File JavaDoc[] classpath;
69         private File JavaDoc outputJar;
70         private String JavaDoc name;
71         private File JavaDoc srcDir;
72         private File JavaDoc classesDir;
73         private String JavaDoc memoryInitialSize;
74         private String JavaDoc memoryMaximumSize;
75         private String JavaDoc compiler;
76         private String JavaDoc jar;
77         private boolean nojavac;
78         private boolean quiet;
79         private boolean verbose;
80         private boolean download;
81         private Collection JavaDoc errorListener;
82         private boolean noUpa;
83         private boolean noPvr;
84         private boolean debug;
85         private String JavaDoc repackage;
86         private List JavaDoc extensions = Collections.EMPTY_LIST;
87         private boolean jaxb;
88         private Set JavaDoc mdefNamespaces = Collections.EMPTY_SET;
89         private EntityResolver JavaDoc entityResolver;
90
91         public File JavaDoc getBaseDir()
92         {
93             return baseDir;
94         }
95
96         public void setBaseDir(File JavaDoc baseDir)
97         {
98             this.baseDir = baseDir;
99         }
100
101         public File JavaDoc[] getXsdFiles()
102         {
103             return xsdFiles;
104         }
105
106         public void setXsdFiles(File JavaDoc[] xsdFiles)
107         {
108             this.xsdFiles = xsdFiles;
109         }
110
111         public File JavaDoc[] getWsdlFiles()
112         {
113             return wsdlFiles;
114         }
115
116         public void setWsdlFiles(File JavaDoc[] wsdlFiles)
117         {
118             this.wsdlFiles = wsdlFiles;
119         }
120
121         public File JavaDoc[] getJavaFiles()
122         {
123             return javaFiles;
124         }
125
126         public void setJavaFiles(File JavaDoc[] javaFiles)
127         {
128             this.javaFiles = javaFiles;
129         }
130
131         public File JavaDoc[] getConfigFiles()
132         {
133             return configFiles;
134         }
135
136         public void setConfigFiles(File JavaDoc[] configFiles)
137         {
138             this.configFiles = configFiles;
139         }
140
141         public File JavaDoc[] getClasspath()
142         {
143             return classpath;
144         }
145
146         public void setClasspath(File JavaDoc[] classpath)
147         {
148             this.classpath = classpath;
149         }
150
151         public File JavaDoc getOutputJar()
152         {
153             return outputJar;
154         }
155
156         public void setOutputJar(File JavaDoc outputJar)
157         {
158             this.outputJar = outputJar;
159         }
160
161         public String JavaDoc getName()
162         {
163             return name;
164         }
165
166         public void setName(String JavaDoc name)
167         {
168             this.name = name;
169         }
170
171         public File JavaDoc getSrcDir()
172         {
173             return srcDir;
174         }
175
176         public void setSrcDir(File JavaDoc srcDir)
177         {
178             this.srcDir = srcDir;
179         }
180
181         public File JavaDoc getClassesDir()
182         {
183             return classesDir;
184         }
185
186         public void setClassesDir(File JavaDoc classesDir)
187         {
188             this.classesDir = classesDir;
189         }
190
191         public boolean isNojavac()
192         {
193             return nojavac;
194         }
195
196         public void setNojavac(boolean nojavac)
197         {
198             this.nojavac = nojavac;
199         }
200
201         public boolean isQuiet()
202         {
203             return quiet;
204         }
205
206         public void setQuiet(boolean quiet)
207         {
208             this.quiet = quiet;
209         }
210
211         public boolean isVerbose()
212         {
213             return verbose;
214         }
215
216         public void setVerbose(boolean verbose)
217         {
218             this.verbose = verbose;
219         }
220
221         public boolean isDownload()
222         {
223             return download;
224         }
225
226         public void setDownload(boolean download)
227         {
228             this.download = download;
229         }
230
231         public boolean isNoUpa()
232         {
233             return noUpa;
234         }
235
236         public void setNoUpa(boolean noUpa)
237         {
238             this.noUpa = noUpa;
239         }
240
241         public boolean isNoPvr()
242         {
243             return noPvr;
244         }
245
246         public void setNoPvr(boolean noPvr)
247         {
248             this.noPvr = noPvr;
249         }
250
251         public boolean isDebug()
252         {
253             return debug;
254         }
255
256         public void setDebug(boolean debug)
257         {
258             this.debug = debug;
259         }
260
261         public String JavaDoc getMemoryInitialSize()
262         {
263             return memoryInitialSize;
264         }
265
266         public void setMemoryInitialSize(String JavaDoc memoryInitialSize)
267         {
268             this.memoryInitialSize = memoryInitialSize;
269         }
270
271         public String JavaDoc getMemoryMaximumSize()
272         {
273             return memoryMaximumSize;
274         }
275
276         public void setMemoryMaximumSize(String JavaDoc memoryMaximumSize)
277         {
278             this.memoryMaximumSize = memoryMaximumSize;
279         }
280
281         public String JavaDoc getCompiler()
282         {
283             return compiler;
284         }
285
286         public void setCompiler(String JavaDoc compiler)
287         {
288             this.compiler = compiler;
289         }
290
291         public String JavaDoc getJar()
292         {
293             return jar;
294         }
295
296         public void setJar(String JavaDoc jar)
297         {
298             this.jar = jar;
299         }
300
301
302         public void setJaxb(boolean jaxb)
303         {
304             this.jaxb = jaxb;
305         }
306
307         public boolean getJaxb()
308         {
309             return this.jaxb;
310         }
311
312         public Collection JavaDoc getErrorListener()
313         {
314             return errorListener;
315         }
316
317         public void setErrorListener(Collection JavaDoc errorListener)
318         {
319             this.errorListener = errorListener;
320         }
321
322         public String JavaDoc getRepackage()
323         {
324             return repackage;
325         }
326
327         public void setRepackage(String JavaDoc newRepackage)
328         {
329             repackage = newRepackage;
330         }
331
332         public List JavaDoc getExtensions() {
333             return extensions;
334         }
335
336         public void setExtensions(List JavaDoc extensions) {
337             this.extensions = extensions;
338         }
339
340         public Set JavaDoc getMdefNamespaces()
341         {
342             return mdefNamespaces;
343         }
344
345         public void setMdefNamespaces(Set JavaDoc mdefNamespaces)
346         {
347             this.mdefNamespaces = mdefNamespaces;
348         }
349
350         public EntityResolver JavaDoc getEntityResolver() {
351             return entityResolver;
352         }
353
354         public void setEntityResolver(EntityResolver JavaDoc entityResolver) {
355             this.entityResolver = entityResolver;
356         }
357
358     }
359
360     private static SchemaTypeSystem loadTypeSystem(
361         String JavaDoc name, File JavaDoc[] xsdFiles,
362         File JavaDoc[] wsdlFiles, File JavaDoc[] configFiles, ResourceLoader cpResourceLoader,
363         boolean download, boolean noUpa, boolean noPvr, Set JavaDoc mdefNamespaces,
364         File JavaDoc baseDir, Map JavaDoc sourcesToCopyMap, Collection JavaDoc outerErrorListener,
365         EntityResolver JavaDoc entityResolver)
366     {
367         XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
368
369         // For parsing XSD and WSDL files, we should use the SchemaDocument
370
// classloader rather than the thread context classloader. This is
371
// because in some situations (such as when being invoked by ant
372
// underneath the ide) the context classloader is potentially weird
373
// (because of the design of ant).
374

375         SchemaTypeLoader loader = XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClassLoader());
376
377         // step 1, parse all the XSD files.
378
ArrayList JavaDoc scontentlist = new ArrayList JavaDoc();
379         if (xsdFiles != null)
380         {
381             for (int i = 0; i < xsdFiles.length; i++)
382             {
383                 try
384                 {
385                     XmlOptions options = new XmlOptions();
386                     options.setLoadLineNumbers();
387                     options.setLoadMessageDigest();
388                     options.setEntityResolver(entityResolver);
389
390                     XmlObject schemadoc = loader.parse(xsdFiles[i], null, options);
391                     if (!(schemadoc instanceof SchemaDocument))
392                     {
393                         StscState.addError(errorListener, "Document " + xsdFiles[i] + " is not a schema file", XmlErrorContext.CANNOT_LOAD_XSD_FILE, schemadoc);
394                     }
395                     else
396                     {
397                         StscState.addInfo(errorListener, "Loading schema file " + xsdFiles[i]);
398                         XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
399                         if (schemadoc.validate(opts))
400                             scontentlist.add(((SchemaDocument)schemadoc).getSchema());
401                     }
402                 }
403                 catch (XmlException e)
404                 {
405                     errorListener.add(e.getError());
406                 }
407                 catch (Exception JavaDoc e)
408                 {
409                     StscState.addError(errorListener, "Cannot load file " + xsdFiles[i] + ": " + e, XmlErrorContext.CANNOT_LOAD_XSD_FILE, xsdFiles[i]);
410                 }
411             }
412         }
413
414         // step 2, parse all WSDL files
415
if (wsdlFiles != null)
416         {
417             for (int i = 0; i < wsdlFiles.length; i++)
418             {
419                 try
420                 {
421                     XmlOptions options = new XmlOptions();
422                     options.setLoadLineNumbers();
423                     options.setEntityResolver(entityResolver);
424                     options.setLoadSubstituteNamespaces(Collections.singletonMap(
425                             "http://schemas.xmlsoap.org/wsdl/", "http://www.apache.org/internal/xmlbeans/wsdlsubst"
426                     ));
427
428
429                     XmlObject wsdldoc = loader.parse(wsdlFiles[i], null, options);
430
431                     if (!(wsdldoc instanceof org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument))
432                         StscState.addError(errorListener, "Document " + wsdlFiles[i] + " is not a wsdl file", XmlErrorContext.CANNOT_LOAD_XSD_FILE, wsdldoc);
433                     else
434                     {
435                         if (wsdlContainsEncoded(wsdldoc))
436                             StscState.addWarning(errorListener, "The WSDL " + wsdlFiles[i] + " uses SOAP encoding. SOAP encoding is not compatible with literal XML Schema.", XmlErrorContext.CANNOT_LOAD_XSD_FILE, wsdldoc);
437                         StscState.addInfo(errorListener, "Loading wsdl file " + wsdlFiles[i]);
438                         XmlObject[] types = ((org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument)wsdldoc).getDefinitions().getTypesArray();
439                         int count = 0;
440                         for (int j = 0; j < types.length; j++)
441                         {
442                             // explicit cast for paranoia
443
SchemaDocument.Schema[] schemas = (SchemaDocument.Schema[])types[j].selectPath("declare namespace xs=\"http://www.w3.org/2001/XMLSchema\" xs:schema");
444                             for (int k = 0; k < schemas.length; k++)
445                             {
446                                 if (schemas[k].validate(new XmlOptions().setErrorListener(errorListener)))
447                                     scontentlist.add(schemas[k]);
448                             }
449                             count += schemas.length;
450                         }
451                         StscState.addInfo(errorListener, "Processing " + count + " schema(s) in " + wsdlFiles[i].toString());
452                     }
453                 }
454                 catch (XmlException e)
455                 {
456                     errorListener.add(e.getError());
457                 }
458                 catch (Exception JavaDoc e)
459                 {
460                     StscState.addError(errorListener, "Cannot load file " + wsdlFiles[i] + ": " + e, XmlErrorContext.CANNOT_LOAD_XSD_FILE, wsdlFiles[i]);
461                 }
462             }
463         }
464
465         SchemaDocument.Schema[] sdocs = (SchemaDocument.Schema[])scontentlist.toArray(new SchemaDocument.Schema[scontentlist.size()]);
466
467         // now the config files.
468
ArrayList JavaDoc cdoclist = new ArrayList JavaDoc();
469         if (configFiles != null)
470         {
471             for (int i = 0; i < configFiles.length; i++)
472             {
473                 try
474                 {
475                     XmlOptions options = new XmlOptions();
476                     options.put( XmlOptions.LOAD_LINE_NUMBERS );
477                     options.setEntityResolver(entityResolver);
478
479                     XmlObject configdoc = loader.parse(configFiles[i], null, options);
480                     if (!(configdoc instanceof ConfigDocument))
481                         StscState.addError(errorListener, "Document " + configFiles[i] + " is not an xsd config file", XmlErrorContext.CANNOT_LOAD_XSD_FILE, configdoc);
482                     else
483                     {
484                         StscState.addInfo(errorListener, "Loading config file " + configFiles[i]);
485                         if (configdoc.validate(new XmlOptions().setErrorListener(errorListener)))
486                             cdoclist.add(((ConfigDocument)configdoc).getConfig());
487                     }
488                 }
489                 catch (XmlException e)
490                 {
491                     errorListener.add(e.getError());
492                 }
493                 catch (Exception JavaDoc e)
494                 {
495                     StscState.addError(errorListener, "Cannot load xsd config file " + configFiles[i] + ": " + e, XmlErrorContext.CANNOT_LOAD_XSD_CONFIG_FILE, configFiles[i]);
496                 }
497             }
498         }
499         ConfigDocument.Config[] cdocs = (ConfigDocument.Config[])cdoclist.toArray(new ConfigDocument.Config[cdoclist.size()]);
500
501         SchemaTypeLoader linkTo = SchemaTypeLoaderImpl.build(null, cpResourceLoader, null);
502
503         URI JavaDoc baseURI = null;
504         if (baseDir != null)
505             baseURI = baseDir.toURI();
506
507         XmlOptions opts = new XmlOptions();
508         if (download)
509             opts.setCompileDownloadUrls();
510         if (noUpa)
511             opts.setCompileNoUpaRule();
512         if (noPvr)
513             opts.setCompileNoPvrRule();
514         if (mdefNamespaces != null)
515             opts.setCompileMdefNamespaces(mdefNamespaces);
516         opts.setCompileNoValidation(); // already validated here
517
opts.setEntityResolver(entityResolver);
518
519         // now pass it to the main compile function
520
SchemaTypeSystemCompiler.Parameters params = new SchemaTypeSystemCompiler.Parameters();
521         params.setName(name);
522         params.setSchemas(sdocs);
523         params.setConfigs(cdocs);
524         params.setLinkTo(linkTo);
525         params.setOptions(opts);
526         params.setErrorListener(errorListener);
527         params.setJavaize(true);
528         params.setBaseURI(baseURI);
529         params.setSourcesToCopyMap(sourcesToCopyMap);
530         return SchemaTypeSystemCompiler.compile(params);
531     }
532
533     public static boolean compile(SchemaCompiler.Parameters params)
534     {
535         File JavaDoc baseDir = params.getBaseDir();
536         File JavaDoc[] xsdFiles = params.getXsdFiles();
537         File JavaDoc[] wsdlFiles = params.getWsdlFiles();
538         File JavaDoc[] javaFiles = params.getJavaFiles();
539         File JavaDoc[] configFiles = params.getConfigFiles();
540         File JavaDoc[] classpath = params.getClasspath();
541         File JavaDoc outputJar = params.getOutputJar();
542         String JavaDoc name = params.getName();
543         File JavaDoc srcDir = params.getSrcDir();
544         File JavaDoc classesDir = params.getClassesDir();
545         String JavaDoc compiler = params.getCompiler();
546         String JavaDoc jar = params.getJar();
547         String JavaDoc memoryInitialSize = params.getMemoryInitialSize();
548         String JavaDoc memoryMaximumSize = params.getMemoryMaximumSize();
549         boolean nojavac = params.isNojavac();
550         boolean debug = params.isDebug();
551         boolean verbose = params.isVerbose();
552         boolean quiet = params.isQuiet();
553         boolean download = params.isDownload();
554         boolean noUpa = params.isNoUpa();
555         boolean noPvr = params.isNoPvr();
556         Collection JavaDoc outerErrorListener = params.getErrorListener();
557         String JavaDoc repackage = params.getRepackage();
558         List JavaDoc extensions = params.getExtensions();
559         boolean jaxb = params.getJaxb();
560         Set JavaDoc mdefNamespaces = params.getMdefNamespaces();
561         EntityResolver JavaDoc entityResolver = params.getEntityResolver();
562
563         if (srcDir == null || classesDir == null)
564             throw new IllegalArgumentException JavaDoc("src and class gen directories may not be null.");
565
566         long start = System.currentTimeMillis();
567
568         // Calculate the usenames based on the relativized filenames on the filesystem
569
if (baseDir == null)
570             baseDir = new File JavaDoc(System.getProperty("user.dir"));
571
572         ResourceLoader cpResourceLoader = null;
573
574         Map JavaDoc sourcesToCopyMap = new HashMap JavaDoc();
575
576         if (classpath != null)
577             cpResourceLoader = new PathResourceLoader(classpath);
578
579         boolean result = true;
580
581         // build the in-memory type system
582
XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
583         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr, mdefNamespaces, baseDir, sourcesToCopyMap, errorListener, entityResolver);
584         if (errorListener.hasError())
585             result = false;
586         long finish = System.currentTimeMillis();
587         if (!quiet)
588             System.out.println("Time to build schema type system: " + ((double)(finish - start) / 1000.0) + " seconds" );
589
590         // now code generate and compile the JAR
591
if (result && system != null) // todo: don't check "result" here if we want to compile anyway, ignoring invalid schemas
592
{
593             start = System.currentTimeMillis();
594
595             // generate source and .xsb
596
List JavaDoc sourcefiles = new ArrayList JavaDoc();
597             result &= SchemaCodeGenerator.compileTypeSystem(system, srcDir, javaFiles, sourcesToCopyMap, classpath, classesDir, outputJar, nojavac, jaxb, errorListener, repackage, verbose, sourcefiles);
598             result &= !errorListener.hasError();
599
600             if (result)
601             {
602                 finish = System.currentTimeMillis();
603                 if (!quiet)
604                     System.out.println("Time to generate code: " + ((double)(finish - start) / 1000.0) + " seconds" );
605             }
606
607             // compile source
608
if (result && !nojavac)
609             {
610                 start = System.currentTimeMillis();
611
612                 if (javaFiles != null)
613                     sourcefiles.addAll(java.util.Arrays.asList(javaFiles));
614                 if (!CodeGenUtil.externalCompile(sourcefiles, classesDir, classpath, debug, compiler, memoryInitialSize, memoryMaximumSize, quiet, verbose))
615                     result = false;
616
617                 finish = System.currentTimeMillis();
618                 if (result && !params.isQuiet())
619                     System.out.println("Time to compile code: " + ((double)(finish - start) / 1000.0) + " seconds" );
620
621                 // jar classes and .xsb
622
if (result && outputJar != null)
623                 {
624                     if (!CodeGenUtil.externalJar(classesDir, outputJar, jar, quiet, verbose))
625                         result = false;
626
627                     if (result && !params.isQuiet())
628                         System.out.println("Compiled types to: " + outputJar);
629                 }
630             }
631         }
632
633         if (!result && !quiet)
634         {
635             System.out.println("BUILD FAILED");
636         }
637         else {
638             // call schema compiler extension if registered
639
runExtensions(extensions, system, classesDir);
640         }
641
642         if (cpResourceLoader != null)
643             cpResourceLoader.close();
644         return result;
645     }
646
647     private static void runExtensions(List JavaDoc extensions, SchemaTypeSystem system, File JavaDoc classesDir)
648     {
649         if (extensions != null && extensions.size() > 0)
650         {
651             SchemaCompilerExtension sce = null;
652             Iterator JavaDoc i = extensions.iterator();
653             Map JavaDoc extensionParms = null;
654             String JavaDoc classesDirName = null;
655             try
656             {
657                 classesDirName = classesDir.getCanonicalPath();
658             }
659             catch(java.io.IOException JavaDoc e)
660             {
661                 System.out.println("WARNING: Unable to get the path for schema jar file");
662                 classesDirName = classesDir.getAbsolutePath();
663             }
664
665             while (i.hasNext())
666             {
667                 Extension extension = (Extension) i.next();
668                 try
669                 {
670                     sce = (SchemaCompilerExtension) extension.getClassName().newInstance();
671                 }
672                 catch (InstantiationException JavaDoc e)
673                 {
674                     System.out.println("UNABLE to instantiate schema compiler extension:" + extension.getClassName().getName());
675                     System.out.println("EXTENSION Class was not run");
676                     break;
677                 }
678                 catch (IllegalAccessException JavaDoc e)
679                 {
680                     System.out.println("ILLEGAL ACCESS Exception when attempting to instantiate schema compiler extension: " + extension.getClassName().getName());
681                     System.out.println("EXTENSION Class was not run");
682                     break;
683                 }
684
685                 System.out.println("Running Extension: " + sce.getExtensionName());
686                 extensionParms = new HashMap JavaDoc();
687                 Iterator JavaDoc parmsi = extension.getParams().iterator();
688                 while (parmsi.hasNext())
689                 {
690                     Extension.Param p = (Extension.Param) parmsi.next();
691                     extensionParms.put(p.getName(), p.getValue());
692                 }
693                 extensionParms.put("classesDir", classesDirName);
694                 sce.schemaCompilerExtension(system, extensionParms);
695             }
696         }
697     }
698
699
700     private static boolean wsdlContainsEncoded(XmlObject wsdldoc)
701     {
702         // search for any <soap:body use="encoded"/> etc.
703
XmlObject[] useAttrs = wsdldoc.selectPath(
704                 "declare namespace soap='http://schemas.xmlsoap.org/wsdl/soap/' " +
705                 ".//soap:body/@use|.//soap:header/@use|.//soap:fault/@use");
706         for (int i = 0; i < useAttrs.length; i++)
707         {
708             if ("encoded".equals(((SimpleValue)useAttrs[i]).getStringValue()))
709                 return true;
710         }
711         return false;
712     }
713
714
715 }
716
717
Popular Tags