This project has retired. For details please refer to its
        
        Attic page.
      
 
ReadWSDL xref
1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  package org.apache.juddi.v3.client.mapping.wsdl;
16  
17  import java.net.URI;
18  import java.net.URISyntaxException;
19  import java.net.URL;
20  
21  import javax.wsdl.Definition;
22  import javax.wsdl.WSDLException;
23  import javax.wsdl.factory.WSDLFactory;
24  import javax.wsdl.xml.WSDLLocator;
25  import javax.wsdl.xml.WSDLReader;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  import org.apache.juddi.v3.client.ClassUtil;
30  
31  import com.ibm.wsdl.factory.WSDLFactoryImpl;
32  import java.io.File;
33  import java.net.MalformedURLException;
34  
35  
36  
37  
38  
39  
40  public class ReadWSDL {
41  	
42          private boolean IgnoreSSLErrors = false;
43  	private final Log log = LogFactory.getLog(this.getClass());
44  	
45  	public Definition readWSDL(String fileName) throws WSDLException  {
46                  Definition wsdlDefinition = null;
47                  WSDLFactory factory = WSDLFactoryImpl.newInstance();
48                  WSDLReader reader = factory.newWSDLReader();
49  
50                  try {
51                          File f = new File(fileName);
52                          URL url = null;
53                          if (f.exists()) {
54                                  log.info(fileName + " as a local file doesn't exist.");
55                                  url = f.toURI().toURL();
56                          } else {
57                                  url = ClassUtil.getResource(fileName, this.getClass());
58                          }
59                          if (url==null){
60                                  log.info(fileName + " as a class path resource doesn't exist.");
61                                  throw new WSDLException("null input", fileName);
62                          }
63                          URI uri = url.toURI();
64                          WSDLLocator locator = new WSDLLocatorImpl(uri);
65                          wsdlDefinition = reader.readWSDL(locator);
66                  } catch (URISyntaxException e) {
67                          log.error(e.getMessage(), e);
68                  } catch (MalformedURLException ex) {
69                          log.error(ex.getMessage(), ex);
70                  }
71                  return wsdlDefinition;
72  	}
73  	
74          
75  
76  
77  
78  
79  
80  
81  
82  
83          public Definition readWSDL(URL wsdlUrl, String username, String password) throws WSDLException, Exception {
84  	
85  		Definition wsdlDefinition = null;
86  		WSDLFactory factory = WSDLFactoryImpl.newInstance();
87  		WSDLReader reader = factory.newWSDLReader();
88                  URI uri=null;
89  		try {
90                          uri = wsdlUrl.toURI();
91                  } catch (Exception e) {
92  			log.error(e.getMessage(),e);
93                          throw new WSDLException("Unable to parse the URL", null, e);
94  		}
95  		WSDLLocatorImpl locator = new WSDLLocatorImpl(uri, username, password, IgnoreSSLErrors );
96                  try{
97  			wsdlDefinition = reader.readWSDL(locator);
98  		} catch (Exception e) {
99                          log.error(e.getMessage(),e);
100                         if (locator.getLastException()!=null)
101                         {
102                             log.error(e.getMessage(),locator.getLastException());
103                             throw locator.getLastException();
104                         }
105                         throw e;
106                         
107 		}
108 		return wsdlDefinition;
109 	}
110         
111         
112 
113 
114 
115 
116 
117 
118 	public Definition readWSDL(URL wsdlUrl) throws Exception {
119 		return readWSDL(wsdlUrl, null, null);
120 	}
121 
122         
123 
124 
125 
126     public boolean isIgnoreSSLErrors() {
127         return IgnoreSSLErrors;
128     }
129 
130     
131 
132 
133 
134     public void setIgnoreSSLErrors(boolean IgnoreSSLErrors) {
135         this.IgnoreSSLErrors = IgnoreSSLErrors;
136     }
137 	
138 	
139 	
140 	
141 }