1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.wsdl.wsdl11;
18
19 import java.io.IOException;
20 import javax.xml.transform.Source;
21
22 import org.xml.sax.SAXException;
23 import org.xml.sax.XMLReader;
24 import org.xml.sax.helpers.XMLReaderFactory;
25
26 import org.springframework.beans.factory.InitializingBean;
27 import org.springframework.core.io.Resource;
28 import org.springframework.util.Assert;
29 import org.springframework.ws.wsdl.WsdlDefinitionException;
30 import org.springframework.xml.transform.ResourceSource;
31
32
33
34
35
36
37
38
39
40
41 public class SimpleWsdl11Definition implements Wsdl11Definition, InitializingBean {
42
43 private Resource wsdlResource;
44
45
46
47
48
49
50 public SimpleWsdl11Definition() {
51 }
52
53
54
55
56
57
58
59 public SimpleWsdl11Definition(Resource wsdlResource) {
60 Assert.notNull(wsdlResource, "wsdlResource must not be null");
61 this.wsdlResource = wsdlResource;
62 }
63
64 public void afterPropertiesSet() throws Exception {
65 Assert.notNull(this.wsdlResource, "wsdl is required");
66 Assert.isTrue(this.wsdlResource.exists(), "wsdl '" + this.wsdlResource + "' does not exit");
67 }
68
69 public Source getSource() {
70 try {
71 XMLReader xmlReader = XMLReaderFactory.createXMLReader();
72 xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
73 return new ResourceSource(xmlReader, wsdlResource);
74 }
75 catch (SAXException ex) {
76 throw new WsdlDefinitionException("Could not create XMLReader", ex);
77 }
78 catch (IOException ex) {
79 throw new WsdlDefinitionException("Could not create source from " + this.wsdlResource, ex);
80 }
81 }
82
83
84
85
86
87
88 public void setWsdl(Resource wsdlResource) {
89 this.wsdlResource = wsdlResource;
90 }
91
92 public String toString() {
93 return "SimpleWsdl11Definition " + wsdlResource;
94 }
95
96
97 }