|
1 | 1 | /*
|
2 |
| - * Copyright 2005-2010 the original author or authors. |
| 2 | + * Copyright 2002-2013 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 | import javax.xml.namespace.QName;
|
23 | 23 | import javax.xml.transform.Source;
|
24 | 24 |
|
25 |
| -import org.springframework.util.Assert; |
26 |
| -import org.springframework.util.StringUtils; |
27 |
| -import org.springframework.util.xml.StaxUtils; |
28 |
| -import org.springframework.ws.soap.SoapElement; |
29 |
| - |
30 | 25 | import org.apache.axiom.om.OMAttribute;
|
31 | 26 | import org.apache.axiom.om.OMElement;
|
32 | 27 | import org.apache.axiom.om.OMException;
|
33 | 28 | import org.apache.axiom.om.OMNamespace;
|
34 | 29 | import org.apache.axiom.soap.SOAPFactory;
|
35 | 30 |
|
| 31 | +import org.springframework.util.Assert; |
| 32 | +import org.springframework.util.StringUtils; |
| 33 | +import org.springframework.util.xml.StaxUtils; |
| 34 | +import org.springframework.ws.soap.SoapElement; |
| 35 | + |
36 | 36 | /**
|
37 | 37 | * Axiom-specific version of {@link SoapElement}.
|
38 | 38 | *
|
@@ -72,8 +72,14 @@ public final Source getSource() {
|
72 | 72 |
|
73 | 73 | public final void addAttribute(QName name, String value) {
|
74 | 74 | try {
|
75 |
| - OMNamespace namespace = getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix()); |
76 |
| - OMAttribute attribute = getAxiomFactory().createOMAttribute(name.getLocalPart(), namespace, value); |
| 75 | + String namespaceUri = name.getNamespaceURI(); |
| 76 | + String prefix = name.getPrefix(); |
| 77 | + if (StringUtils.hasLength(namespaceUri) && !StringUtils.hasLength(prefix)) { |
| 78 | + prefix = null; |
| 79 | + } |
| 80 | + OMNamespace namespace = |
| 81 | + getAxiomFactory().createOMNamespace(namespaceUri, prefix); |
| 82 | + OMAttribute attribute = getAxiomFactory().createOMAttribute(name.getLocalPart(), namespace, value); |
77 | 83 | getAxiomElement().addAttribute(attribute);
|
78 | 84 | }
|
79 | 85 | catch (OMException ex) {
|
|
0 commit comments