Skip to content

Commit c6f3df5

Browse files
author
Arjen Poutsma
committed
Merge pull request #2 from veithen/master
* axiom_attribute: Prevent invalid Axiom attributes
2 parents f9a0bf2 + 35be612 commit c6f3df5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

core/src/main/java/org/springframework/ws/soap/axiom/AxiomSoapElement.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2010 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,17 +22,17 @@
2222
import javax.xml.namespace.QName;
2323
import javax.xml.transform.Source;
2424

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-
3025
import org.apache.axiom.om.OMAttribute;
3126
import org.apache.axiom.om.OMElement;
3227
import org.apache.axiom.om.OMException;
3328
import org.apache.axiom.om.OMNamespace;
3429
import org.apache.axiom.soap.SOAPFactory;
3530

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+
3636
/**
3737
* Axiom-specific version of {@link SoapElement}.
3838
*
@@ -72,8 +72,14 @@ public final Source getSource() {
7272

7373
public final void addAttribute(QName name, String value) {
7474
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);
7783
getAxiomElement().addAttribute(attribute);
7884
}
7985
catch (OMException ex) {

0 commit comments

Comments
 (0)