You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/02/28 15:51:49 UTC
cvs commit: ws-axis/c/src/soap SoapSerializer.cpp
dicka 2005/02/28 06:51:49
Modified: c/src/common ArrayBean.cpp BasicTypeSerializer.cpp
BasicTypeSerializer.h
c/src/soap SoapSerializer.cpp
Log:
Fixing problems with missing namespace declarations within Arrays and simple type elements.
PR: AXISCPP-487, AXISCPP-488, AXISCPP-489
Submitted by: Adrian Dick
Revision Changes Path
1.35 +13 -2 ws-axis/c/src/common/ArrayBean.cpp
Index: ArrayBean.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/ArrayBean.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- ArrayBean.cpp 18 Feb 2005 11:11:17 -0000 1.34
+++ ArrayBean.cpp 28 Feb 2005 14:51:49 -0000 1.35
@@ -188,12 +188,19 @@
// serializer prefix
const AxisChar* pNamespace = pSZ.getNamespace();
const AxisChar* pPrefix = NULL;
+ bool blnIsNewPrefix = false;
if (NULL != pNamespace)
if (strlen(pNamespace) > 0)
- pPrefix = pSZ.getNamespacePrefix(pNamespace);
+ pPrefix = pSZ.getNamespacePrefix(pNamespace, blnIsNewPrefix);
if (pPrefix != NULL)
+ {
pSZ.serialize("<", pPrefix, ":", m_ItemName.c_str(), NULL);
+ if (blnIsNewPrefix)
+ {
+ pSZ.serialize(" xmlns:", pPrefix, "=\"", pNamespace, "\"", NULL);
+ }
+ }
else
pSZ.serialize("<", m_ItemName.c_str(), NULL);
@@ -206,7 +213,11 @@
pSZ.serialize("</", pPrefix, ":", m_ItemName.c_str(), ">", NULL);
else
pSZ.serialize("</", m_ItemName.c_str(), ">", NULL);
-
+
+ if (blnIsNewPrefix)
+ {
+ pSZ.removeNamespacePrefix(pNamespace);
+ }
}
}
else
1.53 +26 -0 ws-axis/c/src/common/BasicTypeSerializer.cpp
Index: BasicTypeSerializer.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/BasicTypeSerializer.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- BasicTypeSerializer.cpp 21 Feb 2005 17:41:57 -0000 1.52
+++ BasicTypeSerializer.cpp 28 Feb 2005 14:51:49 -0000 1.53
@@ -47,12 +47,29 @@
const AxisChar* BasicTypeSerializer::serializeAsElement (const AxisChar* pName,
const AxisChar* pPrefix, const void* pValue, XSDTYPE type)
{
+ return serializeAsElement(pName, pPrefix, NULL, pValue, type);
+}
+
+const AxisChar* BasicTypeSerializer::serializeAsElement (const AxisChar* pName,
+ const AxisChar* pPrefix, const AxisChar* pNamespace, const void* pValue, XSDTYPE type)
+{
m_sSZ = "<";
if (NULL != pPrefix) {
m_sSZ += pPrefix;
m_sSZ += ":";
}
+
m_sSZ += pName;
+
+ if (NULL != pNamespace)
+ {
+ m_sSZ += " xmlns:";
+ m_sSZ += pPrefix;
+ m_sSZ += "=\"";
+ m_sSZ += pNamespace;
+ m_sSZ += "\"";
+ }
+
if (RPC_ENCODED == m_nStyle)
{
m_sSZ += " xsi:type=\"xsd:";
@@ -73,6 +90,15 @@
m_sSZ += ":";
}
m_sSZ += pName;
+
+ if (NULL != pNamespace)
+ {
+ m_sSZ += " xmlns:";
+ m_sSZ += pPrefix;
+ m_sSZ += "\"";
+ m_sSZ += pNamespace;
+ m_sSZ += "\"";
+ }
m_sSZ += " xsi:nil=\"true\">";
}
else
1.33 +36 -0 ws-axis/c/src/common/BasicTypeSerializer.h
Index: BasicTypeSerializer.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/BasicTypeSerializer.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- BasicTypeSerializer.h 27 Jan 2005 08:32:37 -0000 1.32
+++ BasicTypeSerializer.h 28 Feb 2005 14:51:49 -0000 1.33
@@ -86,10 +86,46 @@
BasicTypeSerializer();
virtual ~BasicTypeSerializer();
const AxisString& getEntityReferenced(const AxisString& str);
+
+ /**
+ * Serializes a SOAP Element.
+ *
+ * This is essentially serializeAsElement(const AxisChar* pName, const AxisChar* pPrefix, const void* pValue, XSDTYPE type)
+ * with pPrefix = NULL;
+ *
+ * @param pName the name gives for this element.
+ * @param pValue the value for this element.
+ * @param type the xsd type of the value.
+ */
const AxisChar* serializeAsElement(const AxisChar* pName,
const void* pValue, XSDTYPE type);
+ /**
+ * Serializes a SOAP Element.
+ *
+ * This is essentially serializeAsElement(const AxisChar* pName, const AxisChar* pPrefix, const AxisChar* pNamespace, const void* pValue, XSDTYPE type)
+ * with pNamespace = NULL;
+ *
+ * @param pName the name gives for this element.
+ * @param pPrefix the optional prefix for this element.
+ * @param pValue the value for this element.
+ * @param type the xsd type of the value.
+ */
const AxisChar* serializeAsElement(const AxisChar* pName,
const AxisChar* pPrefix, const void* pValue, XSDTYPE type);
+ /**
+ * Serializes a SOAP Element.
+ * If a namespace is provided, it will be declared, so ensure appropriate
+ * checks have taken place before providing a namespace.
+ *
+ * @param pName the name gives for this element.
+ * @param pPrefix the optional prefix for this element.
+ * @param pNamespace the namespace uri to be used for this element and prefix.
+ * @param pValue the value for this element.
+ * @param type the xsd type of the value.
+ */
+ const AxisChar* serializeAsElement(const AxisChar* pName,
+ const AxisChar* pPrefix, const AxisChar* pNamespace, const void* pValue,
+ XSDTYPE type);
const AxisChar* serializeAsAttribute(const AxisChar* pName,
const AxisChar* pPrefix, const void* pValue, XSDTYPE type);
const AxisChar* encodeToHexBinary(const xsd__hexBinary* pBinary);
1.100 +41 -9 ws-axis/c/src/soap/SoapSerializer.cpp
Index: SoapSerializer.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- SoapSerializer.cpp 23 Feb 2005 15:31:20 -0000 1.99
+++ SoapSerializer.cpp 28 Feb 2005 14:51:49 -0000 1.100
@@ -569,7 +569,12 @@
pParam->m_Type = XSD_ARRAY;
if (pNamespace != NULL)
{
- const AxisChar* np = getNamespacePrefix(pNamespace);
+ bool blnIsNewNamespacePrefix = false;
+ const AxisChar* np = getNamespacePrefix(pNamespace, blnIsNewNamespacePrefix);
+ if (blnIsNewNamespacePrefix)
+ {
+ removeNamespacePrefix(pNamespace);
+ }
const AxisChar* originalNamespace = getNamespace(); // Store original namespace
pParam->setPrefix(np);
setNamespace(pNamespace);
@@ -623,12 +628,27 @@
}
pParam->m_Value.pIArray = pAb;
pParam->m_Type = XSD_ARRAY;
- if (pNamespace != NULL) {
- const AxisChar* np = getNamespacePrefix(pNamespace);
- pParam->setPrefix(np);
- setNamespace(pNamespace);
+
+
+ if (pNamespace != NULL)
+ {
+ bool blnIsNewNamespacePrefix = false;
+ const AxisChar* np = getNamespacePrefix(pNamespace, blnIsNewNamespacePrefix);
+ if (blnIsNewNamespacePrefix)
+ {
+ removeNamespacePrefix(pNamespace);
+ }
+ const AxisChar* originalNamespace = getNamespace(); // Store original namespace
+ pParam->setPrefix(np);
+ setNamespace(pNamespace);
+ pParam->serialize(*this);
+ setNamespace(originalNamespace); // Revert back original namespace
}
- pParam->serialize(*this);
+ else
+ {
+ pParam->serialize(*this);
+ }
+
/* Remove pointer to the array from the ArrayBean to avoid deleting the
* array when ArrayBean is deleted. Array will be deleted when the complex
* type that contains this array is deleted
@@ -743,12 +763,24 @@
XSDTYPE type)
{
const AxisChar* pPrefix = NULL;
+ bool blnIsNewPrefix = false;
if (pNamespace)
{
- pPrefix = getNamespacePrefix(pNamespace);
+ pPrefix = getNamespacePrefix(pNamespace, blnIsNewPrefix);
+ }
+
+ const AxisChar* pSerialized = NULL;
+ if (blnIsNewPrefix)
+ {
+ pSerialized = m_BTSZ.serializeAsElement(pName, pPrefix,
+ pNamespace, pValue, type);
+ removeNamespacePrefix(pNamespace);
+ }
+ else
+ {
+ pSerialized = m_BTSZ.serializeAsElement(pName, pPrefix,
+ pValue, type);
}
- const AxisChar* pSerialized = m_BTSZ.serializeAsElement(pName, pPrefix, pValue,
- type);
if (pSerialized)
{
*this << pSerialized;