1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support.wsdl;
14
15 import com.eviware.soapui.impl.support.definition.DefinitionCache;
16 import com.eviware.soapui.impl.support.definition.export.WsdlDefinitionExporter;
17 import com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext;
18 import com.eviware.soapui.impl.support.definition.support.InterfaceCacheDefinitionLoader;
19 import com.eviware.soapui.impl.wsdl.WsdlInterface;
20 import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
21
22 import javax.wsdl.Definition;
23
24 /***
25 * Holder for WSDL4J Definitions and related SchemaTypeLoader types
26 *
27 * @author Ole.Matzura
28 */
29
30 public class WsdlContext extends AbstractDefinitionContext<WsdlInterface, WsdlDefinitionLoader, WsdlInterfaceDefinition>
31 {
32 private SoapVersion soapVersion = SoapVersion.Soap11;
33
34 public WsdlContext( String url, WsdlInterface iface )
35 {
36 super( url, iface );
37 }
38
39 public WsdlContext( String wsdlUrl )
40 {
41 this( wsdlUrl, (WsdlInterface) null );
42 }
43
44 public WsdlContext( String wsdlUrl, SoapVersion soapVersion )
45 {
46 this( wsdlUrl );
47 if( soapVersion != null )
48 {
49 this.soapVersion = soapVersion;
50 }
51 }
52
53 protected WsdlDefinitionLoader createDefinitionLoader( DefinitionCache wsdlInterfaceDefinitionCache )
54 {
55 return new InterfaceCacheDefinitionLoader( wsdlInterfaceDefinitionCache );
56 }
57
58 protected WsdlDefinitionLoader createDefinitionLoader( String url )
59 {
60 return new UrlWsdlLoader( url, getInterface() );
61 }
62
63 protected WsdlInterfaceDefinition loadDefinition( WsdlDefinitionLoader loader ) throws Exception
64 {
65 return new WsdlInterfaceDefinition( getInterface() ).load( loader );
66 }
67
68 public Definition getDefinition() throws Exception
69 {
70 return getInterfaceDefinition().getWsdlDefinition();
71 }
72
73 public SoapVersion getSoapVersion()
74 {
75 return getInterface() == null ? soapVersion : getInterface().getSoapVersion();
76 }
77
78 public String export( String path ) throws Exception
79 {
80 return new WsdlDefinitionExporter( getInterface() ).export( path );
81 }
82 }