Skip to content

Commit fc317b0

Browse files
committed
SWS-247 in 1.0 branch
1 parent ba6d9e7 commit fc317b0

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

core/src/main/java/org/springframework/ws/wsdl/wsdl11/builder/XsdBasedSoap11Wsdl4jDefinitionBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@
3737
import javax.xml.parsers.DocumentBuilderFactory;
3838
import javax.xml.parsers.ParserConfigurationException;
3939

40+
import org.w3c.dom.Document;
41+
import org.w3c.dom.Element;
42+
import org.xml.sax.SAXException;
43+
4044
import org.springframework.beans.factory.InitializingBean;
4145
import org.springframework.core.io.Resource;
4246
import org.springframework.util.Assert;
4347
import org.springframework.util.StringUtils;
4448
import org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition;
4549
import org.springframework.xml.namespace.QNameUtils;
46-
import org.w3c.dom.Document;
47-
import org.w3c.dom.Element;
48-
import org.xml.sax.SAXException;
4950

5051
/**
5152
* Builds a <code>WsdlDefinition</code> with a SOAP 1.1 binding based on an XSD schema. This builder iterates over all
@@ -281,7 +282,7 @@ protected void buildMessages(Definition definition) throws WSDLException {
281282
QName elementName = (QName) iterator.next();
282283
if (elementName != null &&
283284
(isRequestMessage(elementName) || isResponseMessage(elementName) || isFaultMessage(elementName))) {
284-
if (!StringUtils.hasLength(definition.getPrefix(elementName.getNamespaceURI()))) {
285+
if (definition.getPrefix(elementName.getNamespaceURI()) == null) {
285286
int i = 0;
286287
while (true) {
287288
String prefix = schemaPrefix + Integer.toString(i);

core/src/test/java/org/springframework/ws/wsdl/wsdl11/builder/XsdBasedSoap11Wsdl4jDefinitionBuilderTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424

2525
import org.custommonkey.xmlunit.XMLTestCase;
2626
import org.custommonkey.xmlunit.XMLUnit;
27+
import org.w3c.dom.Document;
28+
2729
import org.springframework.core.io.ClassPathResource;
2830
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
29-
import org.w3c.dom.Document;
31+
import org.springframework.xml.transform.StringResult;
3032

3133
public class XsdBasedSoap11Wsdl4jDefinitionBuilderTest extends XMLTestCase {
3234

@@ -144,6 +146,20 @@ public void testAirline() throws Exception {
144146
assertXMLEqual("Invalid WSDL built", expected, result);
145147
}
146148

149+
public void testNoSchemaPrefix() throws Exception {
150+
builder.setSchema(new ClassPathResource("single.xsd", getClass()));
151+
builder.setPortTypeName("Order");
152+
builder.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions");
153+
builder.setSchemaPrefix("");
154+
builder.afterPropertiesSet();
155+
156+
buildAll();
157+
158+
Wsdl11Definition definition = builder.getDefinition();
159+
160+
transformer.transform(definition.getSource(), new StringResult());
161+
}
162+
147163
private void buildAll() {
148164
builder.buildDefinition();
149165
builder.buildImports();

0 commit comments

Comments
 (0)