AXISCPP-843 Serialiser is using namespaces without first assigning them in the XML
diff --git a/src/engine/client/Call.cpp b/src/engine/client/Call.cpp
index 3a4d1cd..0991df8 100644
--- a/src/engine/client/Call.cpp
+++ b/src/engine/client/Call.cpp
@@ -1160,7 +1160,7 @@
else
pAttribute = new Attribute( attributeList, pLocalname, pPrefix, pValue);
- m_pIWSSZ->setSOAPMethodAttribute( ((Attribute *) pAttribute)->clone());
+ m_pIWSSZ->setSOAPMethodAttribute((Attribute *) pAttribute);
}
void Call::clearSOAPMethodAttributes()
diff --git a/src/soap/Attribute.cpp b/src/soap/Attribute.cpp
index 831de57..b508b43 100644
--- a/src/soap/Attribute.cpp
+++ b/src/soap/Attribute.cpp
@@ -280,37 +280,45 @@
{
int intStatus= AXIS_FAIL;
- if (isSerializable()
- && (!pSZ.getNamespaceURL( m_prefix).empty() || NULL!=uri))
- {
+ if (isSerializable())
+ {
pSZ.serialize(" ", NULL);
- /*
- * If User has provided the prefix we just have to serialize. We will
- * not worry to declare the namespace at all. Because it is the users
- * responsibility to add namespace declaration separately.
- * However, if user hasn't provided the prefix. So we have to do the following.
- * - get the prefix from the Serializer
- * - if this is a new namespace, then also declare the namespace.
- */
- if(!m_prefix.empty() || NULL!=uri)
- pSZ.serialize(m_prefix.c_str(), ":", NULL);
- else if (!m_uri.empty())
+ if (m_prefix.compare("xmlns") == 0)
{
- bool blnIsNewNamespace = false;
- m_prefix = pSZ.getNamespacePrefix(m_uri.c_str(), blnIsNewNamespace);
- if (blnIsNewNamespace)
+ // Namespace declaration...
+ pSZ.serialize("xmlns:", m_localname.c_str(), "=", PLATFORM_DOUBLE_QUOTE_S, m_value.c_str(), PLATFORM_DOUBLE_QUOTE_S, NULL);
+ intStatus= AXIS_SUCCESS;
+ }
+ else if ((!pSZ.getNamespaceURL( m_prefix).empty() || NULL!=uri))
+ {
+ /*
+ * If User has provided the prefix we just have to serialize. We will
+ * not worry to declare the namespace at all. Because it is the users
+ * responsibility to add namespace declaration separately.
+ * However, if user hasn't provided the prefix. So we have to do the following.
+ * - get the prefix from the Serializer
+ * - if this is a new namespace, then also declare the namespace.
+ */
+ if(!m_prefix.empty() || NULL!=uri)
+ pSZ.serialize(m_prefix.c_str(), ":", NULL);
+ else if (!m_uri.empty())
{
- lstTmpNameSpaceStack.push_back((AxisChar*)m_uri.c_str());
- pSZ.serialize("xmlns:", m_prefix.c_str(), "=", PLATFORM_DOUBLE_QUOTE_S, m_uri.c_str(), PLATFORM_DOUBLE_QUOTE_S, " ", NULL);
+ bool blnIsNewNamespace = false;
+ m_prefix = pSZ.getNamespacePrefix(m_uri.c_str(), blnIsNewNamespace);
+ if (blnIsNewNamespace)
+ {
+ lstTmpNameSpaceStack.push_back((AxisChar*)m_uri.c_str());
+ pSZ.serialize("xmlns:", m_prefix.c_str(), "=", PLATFORM_DOUBLE_QUOTE_S, m_uri.c_str(), PLATFORM_DOUBLE_QUOTE_S, " ", NULL);
+ }
+
+ pSZ.serialize(m_prefix.c_str(), ":", NULL);
}
- pSZ.serialize(m_prefix.c_str(), ":", NULL);
+ pSZ.serialize(m_localname.c_str(), "=", PLATFORM_DOUBLE_QUOTE_S, m_value.c_str(), PLATFORM_DOUBLE_QUOTE_S, NULL);
+
+ intStatus= AXIS_SUCCESS;
}
-
- pSZ.serialize(m_localname.c_str(), "=", PLATFORM_DOUBLE_QUOTE_S, m_value.c_str(), PLATFORM_DOUBLE_QUOTE_S, NULL);
-
- intStatus= AXIS_SUCCESS;
}
return intStatus;
diff --git a/src/soap/SoapSerializer.cpp b/src/soap/SoapSerializer.cpp
index 25aeff2..6af7eef 100644
--- a/src/soap/SoapSerializer.cpp
+++ b/src/soap/SoapSerializer.cpp
@@ -1590,7 +1590,9 @@
{
logEntryEngine("SoapSerializer::reset")
- m_nCounter = 0; // reset namespace prefix counter
+ // reset namespace prefix counter and stack
+ m_nCounter = 0;
+ m_NsStack.clear();
if( m_pSoapEnvelope )
m_pSoapEnvelope->reset();
diff --git a/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java b/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
index d7292d7..7749248 100644
--- a/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
+++ b/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
@@ -278,7 +278,10 @@
// Generate global variables
//=============================================================================
- c_writer.write("\tAXISCHANDLE call = axiscStubGetCall(stub);\n");
+ c_writer.write ("\tAxiscBool blnIsNewPrefix;\n");
+ c_writer.write ("\tconst AxiscChar *pcNSPrefix;\n");
+ c_writer.write ("\tAXISCHANDLE pSZ;\n");
+ c_writer.write ("\tAXISCHANDLE call = axiscStubGetCall(stub);\n");
if (returntype != null)
{
@@ -417,6 +420,7 @@
{
commentIssued = true;
CUtils.printBlockComment(c_writer, "Process parameters.");
+ c_writer.write ("\tpSZ = axiscCallGetSOAPSerializer(call);\n\n");
}
else
c_writer.write ("\n");
@@ -467,9 +471,11 @@
{
int stringLength = 8 + 1 + parameterName.length () + 1;
c_writer.write ("\t\tchar cPrefixAndParamName" + i + "[" + stringLength + "];\n");
- c_writer.write ("\t\tsprintf( cPrefixAndParamName" + i +
- ", \"%s:" + parameterName +
- "\", axiscCallGetNamespacePrefix(call,\"" + namespace + "\"));\n");
+
+ c_writer.write("\t\tpcNSPrefix = axiscSoapSerializerGetNamespacePrefix(pSZ, \"" + namespace + "\", &blnIsNewPrefix);\n");
+ c_writer.write("\t\tif (blnIsNewPrefix)\n");
+ c_writer.write("\t\t\taxiscCallSetSOAPMethodAttribute(call, pcNSPrefix, \"xmlns\", NULL, \"" + namespace + "\");\n");
+ c_writer.write("\t\tsprintf( cPrefixAndParamName" + i + ", \"%s:" + parameterName + "\", pcNSPrefix);\n");
}
if (param.getType().isAttachment())
diff --git a/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java b/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
index 47e5744..69d4c53 100644
--- a/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
+++ b/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
@@ -160,7 +160,8 @@
c_writer.write("#include \"" + c_classname + CUtils.getHeaderFileExtension() + "\"\n\n");
c_writer.write("#include <axis/AxisWrapperAPI.hpp>\n");
- c_writer.write ("#include <axis/Axis.hpp>\n\n");
+ c_writer.write ("#include <axis/Axis.hpp>\n");
+ c_writer.write ("#include <axis/IWrapperSoapSerializer.hpp>\n\n");
}
catch (IOException e)
{
diff --git a/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java b/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
index e1ee85c..6947f24 100644
--- a/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
+++ b/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
@@ -322,7 +322,10 @@
}
}
- c_writer.write ("\tconst char* pcCmplxFaultName = NULL;\n\n");
+ c_writer.write ("\tconst char* pcCmplxFaultName = NULL;\n");
+ c_writer.write ("\tbool blnIsNewPrefix;\n");
+ c_writer.write ("\tconst AxisChar *pcNSPrefix;\n");
+ c_writer.write ("\tIWrapperSoapSerializer * pSZ;\n\n");
//=============================================================================
// Generate try block and method logic
@@ -412,6 +415,8 @@
{
commentIssued = true;
CUtils.printBlockComment(c_writer, "Process parameters.");
+
+ c_writer.write ("\t\tpSZ = (IWrapperSoapSerializer *)m_pCall->getSOAPSerializer();\n\n");
}
else
c_writer.write ("\n");
@@ -462,11 +467,12 @@
}
else
{
- int stringLength = 8 + 1 + parameterName.length () + 1;
- c_writer.write (tab2 + "\t\tchar cPrefixAndParamName" + i + "[" + stringLength + "];\n");
- c_writer.write (tab2 + "\t\tsprintf( cPrefixAndParamName" + i +
- ", \"%s:" + parameterName +
- "\", m_pCall->getNamespacePrefix(\"" + namespace + "\"));\n");
+ int stringLength = 8 + 1 + parameterName.length () + 1;
+ c_writer.write(tab2 + "\t\tchar cPrefixAndParamName" + i + "[" + stringLength + "];\n");
+ c_writer.write(tab2 + "\t\tpcNSPrefix = pSZ->getNamespacePrefix(\"" + namespace + "\", blnIsNewPrefix);\n");
+ c_writer.write(tab2 + "\t\tif (blnIsNewPrefix)\n");
+ c_writer.write(tab2 + "\t\t\tm_pCall->setSOAPMethodAttribute(pcNSPrefix, \"xmlns\",\"" + namespace + "\");\n");
+ c_writer.write(tab2 + "\t\tsprintf( cPrefixAndParamName" + i + ", \"%s:" + parameterName + "\", pcNSPrefix);\n");
}
if (param.getType().isAttachment())