You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2008/07/21 22:27:49 UTC
svn commit: r678552 - in /webservices/axis/trunk/c: include/axis/
include/axis/client/ src/cbindings/ src/cbindings/client/
src/engine/client/ src/wsdl/org/apache/axis/wsdl/wsdl2ws/
src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ src/wsdl/org/apache/axis/wsdl...
Author: nadiramra
Date: Mon Jul 21 13:27:48 2008
New Revision: 678552
URL: http://svn.apache.org/viewvc?rev=678552&view=rev
Log:
Fixes for AXISCPP-888 (no indication of error when tags not in the WSDL are encountered) and AXISCPP-623 (Support for the WSDL construct "all").
Added:
webservices/axis/trunk/c/include/axis/ElementMissingException.hpp
webservices/axis/trunk/c/include/axis/RedundantElementException.hpp
webservices/axis/trunk/c/include/axis/UnknownElementException.hpp
Modified:
webservices/axis/trunk/c/include/axis/Axis.h
webservices/axis/trunk/c/include/axis/client/Stub.h
webservices/axis/trunk/c/include/axis/client/Stub.hpp
webservices/axis/trunk/c/src/cbindings/AxisC.cpp
webservices/axis/trunk/c/src/cbindings/client/StubC.cpp
webservices/axis/trunk/c/src/cbindings/client/StubC.h
webservices/axis/trunk/c/src/engine/client/Stub.cpp
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
Modified: webservices/axis/trunk/c/include/axis/Axis.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/Axis.h?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/Axis.h (original)
+++ webservices/axis/trunk/c/include/axis/Axis.h Mon Jul 21 13:27:48 2008
@@ -144,6 +144,15 @@
AXISCHANDLE pSoapFault,
void *faultDetail);
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisGenerateElementMissingException(const char *s);
+
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisGenerateRedundantElementException(const char *s);
+
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisGenerateUnknownElementException(const char *s);
+
#ifdef __cplusplus
}
#endif
Added: webservices/axis/trunk/c/include/axis/ElementMissingException.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/ElementMissingException.hpp?rev=678552&view=auto
==============================================================================
--- webservices/axis/trunk/c/include/axis/ElementMissingException.hpp (added)
+++ webservices/axis/trunk/c/include/axis/ElementMissingException.hpp Mon Jul 21 13:27:48 2008
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ *
+ */
+
+/**
+ * @file ElementMissingException.hpp
+ *
+ */
+
+#ifndef __ELEMENTMISSINGEXCEPTION_H_OF_AXIS_INCLUDED_
+#define __ELEMENTMISSINGEXCEPTION_H_OF_AXIS_INCLUDED_
+
+#include <axis/AxisException.hpp>
+
+AXIS_CPP_NAMESPACE_START
+using namespace std;
+
+
+/**
+ * @class ElementMissingException
+ * @brief Exception class for missing elements.
+ *
+ * This exception class is thrown when an expected element is not found, for
+ * example, when processing xsd:all or xsd:choice elements. It is also thrown
+ * during serialization, when an element that is expected to be set is not set.
+ */
+class STORAGE_CLASS_INFO ElementMissingException : public AxisException
+{
+public:
+ /**
+ * Constructor.
+ *
+ * @param elem The name of the missing element.
+ */
+ ElementMissingException(const char *elem): AxisException()
+ {
+ if (!elem) elem = (const char *)"";
+ std::string msg = "Expected element (" + std::string(elem) + std::string(") is missing.");
+ setMessage(CLIENT_SOAP_SOAP_CONTENT_ERROR, "", msg.c_str());
+ }
+};
+
+
+AXIS_CPP_NAMESPACE_END
+
+#endif
+
+
+
Added: webservices/axis/trunk/c/include/axis/RedundantElementException.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/RedundantElementException.hpp?rev=678552&view=auto
==============================================================================
--- webservices/axis/trunk/c/include/axis/RedundantElementException.hpp (added)
+++ webservices/axis/trunk/c/include/axis/RedundantElementException.hpp Mon Jul 21 13:27:48 2008
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ *
+ */
+
+/**
+ * @file RedundantElementException.hpp
+ *
+ */
+
+
+#ifndef __REDUNDANTELEMENTEXCEPTION_H_OF_AXIS_INCLUDED_
+#define __REDUNDANTELEMENTEXCEPTION_H_OF_AXIS_INCLUDED_
+
+#include <axis/AxisException.hpp>
+
+AXIS_CPP_NAMESPACE_START
+using namespace std;
+
+/**
+ * @class RedundantElementException
+ * @brief Exception class for duplicate elements.
+ *
+ * This exception class is thrown when a duplicate element is found when
+ * processing xsd:all elements.
+ */
+class STORAGE_CLASS_INFO RedundantElementException : public AxisException
+{
+public:
+ /**
+ * Constructor.
+ *
+ * @param elem The name of the redundant element.
+ */
+ RedundantElementException(const char *elem): AxisException()
+ {
+ if (!elem) elem = (const char *)"";
+ std::string msg = "Redundant element (" + std::string(elem) + std::string(") encountered.");
+ setMessage(CLIENT_SOAP_SOAP_CONTENT_ERROR, "", msg.c_str());
+ }
+};
+
+
+AXIS_CPP_NAMESPACE_END
+
+#endif
+
+
+
Added: webservices/axis/trunk/c/include/axis/UnknownElementException.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/UnknownElementException.hpp?rev=678552&view=auto
==============================================================================
--- webservices/axis/trunk/c/include/axis/UnknownElementException.hpp (added)
+++ webservices/axis/trunk/c/include/axis/UnknownElementException.hpp Mon Jul 21 13:27:48 2008
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ *
+ */
+
+/**
+ * @file UnknownElementException.hpp
+ *
+ *
+ */
+
+#ifndef __UNKNOWNELEMENTEXCEPTION_H_OF_AXIS_INCLUDED_
+#define __UNKNOWNELEMENTEXCEPTION_H_OF_AXIS_INCLUDED_
+
+#include <axis/AxisException.hpp>
+
+AXIS_CPP_NAMESPACE_START
+using namespace std;
+
+
+/**
+ * @class UnknownElementException
+ * @brief Exception class for unknown elements.
+ *
+ * This exception class is thrown when an unknown or unexpected element is
+ * encountered.
+ */
+class STORAGE_CLASS_INFO UnknownElementException : public AxisException
+{
+public:
+ /**
+ * Constructor.
+ *
+ * @param elem The name of the unexpected element.
+ */
+ UnknownElementException(const char *elem): AxisException()
+ {
+ if (!elem) elem = (const char *)"";
+ std::string msg = "Unexpected or extraneous element (" + std::string(elem) + std::string(") encountered.");
+ setMessage(CLIENT_SOAP_SOAP_CONTENT_ERROR, "", msg.c_str());
+ }
+};
+
+
+AXIS_CPP_NAMESPACE_END
+
+#endif
+
+
+
Modified: webservices/axis/trunk/c/include/axis/client/Stub.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/client/Stub.h?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/client/Stub.h (original)
+++ webservices/axis/trunk/c/include/axis/client/Stub.h Mon Jul 21 13:27:48 2008
@@ -542,6 +542,15 @@
AXISC_STORAGE_CLASS_INFO
void axiscStubSetSOAPHeaders(AXISCHANDLE stub);
+/**
+ * Check for extraneous elements. Called at the end of SOAP processing
+ * to ensure that there are no extraneous elements. Will throw an
+ * exception if extraneous elements are detected.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubCheckForExtraneousElements(AXISCHANDLE stub);
+
+
#ifdef __cplusplus
}
#endif
Modified: webservices/axis/trunk/c/include/axis/client/Stub.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/client/Stub.hpp?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/client/Stub.hpp (original)
+++ webservices/axis/trunk/c/include/axis/client/Stub.hpp Mon Jul 21 13:27:48 2008
@@ -611,12 +611,17 @@
*/
void setSOAPHeaders();
-
/**
* Set Authorization header for Proxy authentication
*/
void setProxyAuthorizationHeader();
-
+
+ /**
+ * Check for extraneous elements. Called at the end of SOAP processing
+ * to ensure that there are no extraneous elements. Will throw an
+ * exception if extraneous elements are detected.
+ */
+ void checkForExtraneousElements();
/**
* Call object
Modified: webservices/axis/trunk/c/src/cbindings/AxisC.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/cbindings/AxisC.cpp?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/AxisC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/AxisC.cpp Mon Jul 21 13:27:48 2008
@@ -17,6 +17,10 @@
#include <iostream>
+#include <axis/ElementMissingException.hpp>
+#include <axis/RedundantElementException.hpp>
+#include <axis/UnknownElementException.hpp>
+
#include <axis/Axis.hpp>
#include <axis/AxisException.hpp>
#include <axis/AxisUserAPI.hpp>
@@ -459,4 +463,23 @@
std::cerr << "AXIS EXCEPTION: (" << errorCode << ") " << errorString << std::endl;
}
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisGenerateElementMissingException(const char *s)
+{
+ throw ElementMissingException(s);
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisGenerateRedundantElementException(const char *s)
+{
+ throw RedundantElementException(s);
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisGenerateUnknownElementException(const char *s)
+{
+ throw UnknownElementException(s);
+}
+
+
}
\ No newline at end of file
Modified: webservices/axis/trunk/c/src/cbindings/client/StubC.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/cbindings/client/StubC.cpp?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/client/StubC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/client/StubC.cpp Mon Jul 21 13:27:48 2008
@@ -17,6 +17,8 @@
#include <stdarg.h>
+#include <axis/UnknownElementException.hpp>
+
#include <axis/client/Stub.hpp>
#include <axis/AxisException.hpp>
@@ -833,6 +835,30 @@
}
}
+AXISC_STORAGE_CLASS_INFO
+void axiscStubCheckForExtraneousElements(AXISCHANDLE stub)
+{
+
+
+ StubC *s = (StubC*)stub;
+
+ try
+ {
+ s->checkForExtraneousElementsStubC();
+ }
+ catch ( AxisException& e )
+ {
+
+ processException(s, e.getExceptionCode(), e.what());
+ s->doNotPerformClientRequest = true;
+ }
+ catch ( ... )
+ {
+ processException(s, -1, "Unrecognized exception thrown.");
+ s->doNotPerformClientRequest = true;
+ }
+}
+
}
Modified: webservices/axis/trunk/c/src/cbindings/client/StubC.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/cbindings/client/StubC.h?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/client/StubC.h (original)
+++ webservices/axis/trunk/c/src/cbindings/client/StubC.h Mon Jul 21 13:27:48 2008
@@ -39,6 +39,7 @@
void applyUserPreferencesStubC() { applyUserPreferences(); }
void includeSecureStubC() { includeSecure(); }
void setSOAPHeadersStubC() { setSOAPHeaders(); }
+ void checkForExtraneousElementsStubC() { checkForExtraneousElements(); }
// flag to indicate invocations should fail without actually trying to perform
// client request due to errors prior to the invocation. When set to true, it
Modified: webservices/axis/trunk/c/src/engine/client/Stub.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/engine/client/Stub.cpp?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/engine/client/Stub.cpp (original)
+++ webservices/axis/trunk/c/src/engine/client/Stub.cpp Mon Jul 21 13:27:48 2008
@@ -18,6 +18,7 @@
* @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
*/
+#include <axis/UnknownElementException.hpp>
#include <axis/client/Stub.hpp>
#include <stdio.h>
#include "../../transport/SOAPTransport.h"
@@ -481,3 +482,15 @@
{
m_pCall->setTransportProperty( SECURE_PROPERTIES, (const char *) &m_sArguments);
}
+
+void
+Stub::checkForExtraneousElements ()
+{
+ IWrapperSoapDeSerializer *pDeSerializer = m_pCall->getSOAPDeSerializer();
+ if (!pDeSerializer)
+ return;
+
+ const char *peekedElementName = pDeSerializer->peekNextElementName();
+ if (0x00 != *peekedElementName)
+ throw UnknownElementException(peekedElementName);
+}
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/ParamWriter.java Mon Jul 21 13:27:48 2008
@@ -210,13 +210,7 @@
if (attrib.isArray())
{
if (attrib.isSimpleType())
- {
- // if the element is a choice or all element, define as ptr to array
- if(attrib.getChoiceElement() || attrib.getAllElement())
- return CUtils.getBasicArrayNameforType(attrib.getTypeName())+"*";
- else
- return CUtils.getBasicArrayNameforType(attrib.getTypeName());
- }
+ return CUtils.getBasicArrayNameforType(attrib.getTypeName());
else
return CUtils.getCmplxArrayNameforType(attrib.getSchemaName());
}
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java Mon Jul 21 13:27:48 2008
@@ -482,15 +482,8 @@
return;
}
- // Determine whether to print variable used for peaking ahead
- for (int i = 0; i < attribs.length; i++)
- {
- if (!attribs[i].isAttribute() && attribs[i].isOptional() && !attribs[i].isArray() && !attribs[i].isAnyType())
- {
- writer.write("\tconst char* peekedElementName;\n");
- break;
- }
- }
+ // Declare variables we use
+ writer.write("\tconst char* peekedElementName;\n");
//=============================================================================
// Deserialize attributes.
@@ -506,75 +499,105 @@
//=============================================================================
String arrayType = null;
- boolean peekCalled = false;
boolean firstIfWritten = false;
- boolean foundAll = false;
int anyCounter = 0; //counter for any types.
int arrayCount = 0;
-
+
+ boolean handleAll = false;
+ boolean handleChoice = false;
+
// Tabs to ensure code alignment
String tab1 = "\t";
- String tab2Default = "";
- String tab2;
+ String tab2 = "\t";
+
+ int startingGroup=0;
+ int endingGroup=0;
for (int i = 0; i < attribs.length; i++)
{
- // Reset tabs
- tab2 = tab2Default + "\t";
-
if (i == attributeParamCount)
CUtils.printBlockComment(writer, "Deserialize elements.");
- //if the attribute is a 'choice' construct we have to peek and make
- // the choice
-
- if (attribs[i].getChoiceElement())
+ // If All, then the element order is arbitrary, so we need a loop. For both
+ // 'choice' and 'all', we need to do a peek.
+ if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
{
- if (!peekCalled)
- {
- writer.write("\tconst char* choiceName=axiscSoapDeSerializerPeekNextElementName(pDZ);\n");
- peekCalled = true;
- }
+ endingGroup = i;
if (!firstIfWritten)
{
- writer.write("\tif");
+ startingGroup = i;
+
+ handleChoice = attribs[i].getChoiceElement();
+ handleAll = attribs[i].getAllElement();
+
+ // Flag for us to know when we found element for 'choice'.
+ if (handleChoice)
+ CUtils.printComment(writer, "Deserialize \"choice\" group of elements.");
+ else
+ {
+ CUtils.printComment(writer, "Deserialize \"all\" group of elements.");
+
+ writer.write("\twhile (1)\n\t{\n");
+
+ // Need to adjust tabs since we will be in a loop
+ tab1 = "\t\t";
+ tab2 = "\t\t";
+ }
+
+ // for choice and all, we need to do a peek.
+ writer.write(tab1 + "peekedElementName=axiscSoapDeSerializerPeekNextElementName(pDZ);\n");
+
+ if (handleAll)
+ {
+ writer.write(tab1 + "if (0x00 == *peekedElementName)\n");
+ writer.write(tab1 + "\tbreak;\n");
+ }
+
+ writer.write("\n");
+
+ writer.write(tab1 + "if ");
firstIfWritten = true;
}
else
- writer.write("\telse if");
+ {
+ writer.write(tab1 + "else if ");
+ if (handleAll)
+ tab2 = "\t\t";
+ else if (handleChoice)
+ tab2 = "\t";
+ }
+
+ writer.write("(strcmp(peekedElementName,\""
+ + attribs[i].getElementNameAsSOAPString() + "\")==0)\n");
+ writer.write(tab1 + "{\n");
- writer.write("(strcmp(choiceName,\""
- + attribs[i].getElementNameAsSOAPString() + "\")==0)\n\t{\n\t");
+ if (handleAll)
+ {
+ writer.write(tab1 + "\tif (param->" + attribs[i].getParamNameAsMember() + ")\n");
+ writer.write(tab1 + "\t\taxiscAxisGenerateRedundantElementException(peekedElementName);\n\n");
+ }
}
else
+ {
+ if (firstIfWritten)
+ endChoiceOrAll(handleAll, handleChoice, tab1, startingGroup, endingGroup);
+
+ tab1 = "\t";
+ tab2 = "\t";
+
firstIfWritten = false;
-
- //if the attribute is a 'all' construct we have to check Min
- // occures
- if (attribs[i].getAllElement())
- if (attribs[i].getMinOccurs() == 0)
- {
- if (!foundAll)
- {
- writer.write("\tconst char* allName = NULL;\n");
- writer.write("\tAxiscBool peekCalled = xsdc_boolean_false;\n");
- foundAll = true;
- }
+ handleAll = false;
+ handleChoice = false;
+ }
- writer.write("\n\tif(!peekCalled)\n\t{\n\t");
- writer.write("\tallName=axiscSoapDeSerializerPeekNextElementName(pDZ);\n");
- writer.write("\t\tpeekCalled = xsdc_boolean_true;\n");
- writer.write("\t}\n");
- writer.write("\tif(strcmp(allName,\""
- + attribs[i].getParamNameAsMember() + "\")==0)\n\t{\n\t");
- writer.write("\tpeekCalled = xsdc_boolean_false;\n\t");
- }
+ if (handleAll || handleChoice)
+ tab2 += "\t";
if (attribs[i].isAnyType())
{
anyCounter +=1;
- writer.write(tab1 + "param->any" + anyCounter + " = axiscSoapDeSerializerGetAnyObject(pDZ);\n");
+ writer.write(tab2 + "param->any" + anyCounter + " = axiscSoapDeSerializerGetAnyObject(pDZ);\n");
}
else if (attribs[i].isArray())
{
@@ -588,20 +611,18 @@
else
baseTypeName = attribs[i].getTypeName();
- writer.write(tab1 + "if (param->" + attribs[i].getParamNameAsMember() + " != NULL)\n");
- writer.write(tab1 + "{\n");
- writer.write(tab1 + "\taxiscAxisDelete(param->" + attribs[i].getParamNameAsMember() + ", XSDC_ARRAY);\n");
- writer.write(tab1 + "\tparam->" + attribs[i].getParamNameAsMember() + "= NULL;\n");
- writer.write(tab1 + "}\n");
+ writer.write(tab2 + "if (param->" + attribs[i].getParamNameAsMember() + " != NULL)\n");
+ writer.write(tab2 + "{\n");
+ writer.write(tab2 + "\taxiscAxisDelete(param->" + attribs[i].getParamNameAsMember() + ", XSDC_ARRAY);\n");
+ writer.write(tab2 + "\tparam->" + attribs[i].getParamNameAsMember() + "= NULL;\n");
+ writer.write(tab2 + "}\n");
writer.write("\n");
- writer.write(tab1 + "param->" + attribs[i].getParamNameAsMember()
+ writer.write(tab2 + "param->" + attribs[i].getParamNameAsMember()
+ " = (" + baseTypeName + "_Array *)"
+ "axiscSoapDeSerializerGetBasicArray(pDZ, "
+ CUtils.getXSDTypeForBasicType(baseTypeName) + ", \""
+ attribs[i].getParamNameAsSOAPString() + "\",0);\n");
-
- writer.write("\n");
}
else
{
@@ -618,11 +639,12 @@
String soapTagName = (attribs[i].isAttribute() ? attribs[i].getParamNameAsSOAPString() : attribs[i].getElementNameAsSOAPString());
// We only peek for elements, not element attributes!
- if (attribs[i].isOptional() && !attribs[i].isAttribute())
+ if (attribs[i].isOptional() && !attribs[i].isAttribute() && !handleAll && !handleChoice)
{
writer.write(tab1 + "peekedElementName = axiscSoapDeSerializerPeekNextElementName(pDZ);\n");
writer.write(tab1 + "if (strcmp(peekedElementName, \"" + soapTagName + "\") == 0)\n");
writer.write(tab1 + "{\n");
+
tab2 += "\t";
}
@@ -678,7 +700,7 @@
writer.write(tab2 + "}\n"); // end local scope
}
- if (attribs[i].isOptional() && !attribs[i].isAttribute())
+ if (attribs[i].isOptional() && !attribs[i].isAttribute() && !handleAll && !handleChoice)
{
writer.write("\t\t\t}\n");
writer.write("\t\telse\n");
@@ -690,10 +712,11 @@
//if complex type
String soapTagName = attribs[i].getParamNameAsSOAPString();
- if (attribs[i].isOptional())
+ if (attribs[i].isOptional() && !handleAll && !handleChoice)
{
writer.write(tab1 + "peekedElementName = axiscSoapDeSerializerPeekNextElementName(pDZ);\n");
writer.write(tab1 + "if (strcmp(peekedElementName, \"" + soapTagName + "\") == 0)\n");
+
tab2 += "\t";
}
@@ -704,33 +727,78 @@
+ ", (void*)Axis_Delete_" + attribs[i].getTypeName()
+ ", \"" + soapTagName + "\", Axis_URI_" + attribs[i].getTypeName() + ");\n");
- if (attribs[i].isOptional())
+ if (attribs[i].isOptional() && !handleAll && !handleChoice)
{
writer.write(tab1 + "else\n");
writer.write(tab1 + "\tparam->" + attribs[i].getParamNameAsMember() + " = NULL;\n");
}
}
- if (attribs[i].getChoiceElement())
+ if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
writer.write(tab1 + "}\n");
- if (attribs[i].getAllElement())
- if (attribs[i].getMinOccurs() == 0)
- writer.write("\t}\n");
-
writer.write("\n");
}
-
+
+ if (firstIfWritten)
+ endChoiceOrAll(handleAll, handleChoice, tab1, startingGroup, endingGroup);
+
//=============================================================================
// Deserialize extension, if any, and return status
//=============================================================================
writeDeSerializeExtensionCode();
+ //=============================================================================
+ // Ensure there are no more elements - there should not be!
+ //=============================================================================
+ writer.write("\n");
+
+ CUtils.printBlockComment(writer, "Ensure no extraneous elements.");
+ writer.write("\tpeekedElementName = axiscSoapDeSerializerPeekNextElementName(pDZ);\n");
+ writer.write("\tif (0x00 != *peekedElementName)\n");
+ writer.write("\t\taxiscAxisGenerateUnknownElementException(peekedElementName);\n");
+
+ writer.write("\n");
writer.write("\treturn axiscSoapDeSerializerGetStatus(pDZ);\n");
writer.write("}\n");
}
-
+
+ private void endChoiceOrAll(boolean handleAll,
+ boolean handleChoice,
+ String tab1,
+ int startGroup, int endGroup) throws IOException
+ {
+ // If xsd:all xsd:choice - an unknown element check - throw exception.
+
+ if (handleAll)
+ {
+ writer.write(tab1 + "else\n");
+ writer.write(tab1 + "\taxiscAxisGenerateUnknownElementException(peekedElementName);\n");
+
+ // Closes for loop
+ writer.write("\t}\n");
+
+ // Verify all fields set if possible.
+ boolean commentPrinted = false;
+ for (int j = startGroup; j <= endGroup; j++)
+ if (attribs[j].getAllElement() && !attribs[j].isArray()
+ && !attribs[j].isOptional() && !attribs[j].isNillable()
+ && attribs[j].getMinOccurs() != 0)
+ {
+ if (!commentPrinted)
+ {
+ CUtils.printComment(writer, "Ensure no missing elements in \"all\" groups.");
+ commentPrinted = true;
+ }
+
+ writer.write("\tif (param->" + attribs[j].getParamNameAsMember() + " == NULL)");
+ writer.write(" axiscAxisGenerateElementMissingException(\"" + attribs[j].getParamNameAsMember() + "\");\n");
+ }
+ }
+
+ writer.write("\n");
+ }
/**
* @throws IOException
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java Mon Jul 21 13:27:48 2008
@@ -585,6 +585,12 @@
writer.write("\tif (AXISC_SUCCESS == axiscCallSend(call))\n\t{\n");
}
+ //=============================================================================
+ // Process output parameters
+ //=============================================================================
+
+ String returnStatement = "";
+
if (isAllTreatedAsOutParams)
{
String currentParamName;
@@ -779,16 +785,11 @@
}
writer.write ("\t\t}\n");
- writer.write ("\t}\n");
- writer.write ("\taxiscCallUnInitialize(call);\n");
}
else if (returntype == null)
{
if (minfo.getOutputMessage () != null)
- writer.write ("\t\t\t/*not successful*/\n\t\t}\n");
-
- writer.write ("\t}\n");
- writer.write ("\taxiscCallUnInitialize(call);\n");
+ writer.write ("\t\t\t// no output?\n\t\t}\n");
}
else if (returntypeisarray)
{
@@ -818,9 +819,8 @@
}
writer.write ("\t\t}\n");
- writer.write ("\t}\n");
- writer.write ("\taxiscCallUnInitialize(call);\n");
- writer.write ("\treturn RetArray;\n");
+
+ returnStatement = "\treturn RetArray;\n";
}
else if (returntypeissimple)
{
@@ -856,16 +856,14 @@
writer.write ("\t\t}\n");
}
- writer.write ("\t}\n");
- writer.write ("\taxiscCallUnInitialize(call);\n");
- writer.write ("\treturn Ret;\n");
+
+ returnStatement = "\treturn Ret;\n";
}
else if (returntype.isAnyType ())
{
writer.write ("\t\t\tpReturn = (" + outparamType + "*)axiscCallGetAnyObject(call);\n\t\t}\n");
- writer.write ("\t}\n");
- writer.write ("\taxiscCallUnInitialize(call);\n");
- writer.write ("\treturn pReturn;\n");
+
+ returnStatement = "\treturn pReturn;\n";
}
else
{
@@ -887,11 +885,15 @@
returntype.getElementNameAsSOAPString () + "\", 0);\n\t\t}\n");
}
- writer.write ("\t}\n");
- writer.write ("\taxiscCallUnInitialize(call);\n");
- writer.write ("\treturn pReturn;\n");
+ returnStatement = "\treturn pReturn;\n";
}
+ if (minfo.getOutputMessage () != null)
+ writer.write ("\n\t\taxiscStubCheckForExtraneousElements(stub);\n");
+ writer.write ("\t}\n");
+ writer.write ("\taxiscCallUnInitialize(call);\n");
+ writer.write(returnStatement);
+
//=============================================================================
// End of method
//=============================================================================
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java Mon Jul 21 13:27:48 2008
@@ -145,21 +145,15 @@
{
writer.write("void " + classname + "::\nset"
+ methodName + "(" + properParamType + asterisk + "pInValue)\n{\n");
-
- writer.write("\tif(" + parameterName + " == NULL)\n");
- if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
+ if (attribs[i].getChoiceElement())
{
- // TODO: for choice, we need to ensure any other set element is deleted.
- writer.write("\t{\n");
- writer.write("\t\t// For 'choice' need to ensure that any\n");
- writer.write("\t\t// other objects belonging to this union of elements are empty.\n");
- writer.write("\t\t// NB: Hasn't been implemented yet!\n");
- writer.write("\t\t" + parameterName + " = new " + type + "_Array();\n");
- writer.write("\t}\n");
+ writer.write("\t// For 'choice' you need to ensure that any\n");
+ writer.write("\t// other objects belonging to this union of elements are empty.\n");
}
- else
- writer.write("\t\t" + parameterName + " = new " + properParamType + "();\n");
+
+ writer.write("\tif(" + parameterName + " == NULL)\n");
+ writer.write("\t\t" + parameterName + " = new " + properParamType + "();\n");
writer.write("\t" + parameterName + "->clone( *pInValue);\n");
writer.write("}\n");
@@ -170,6 +164,12 @@
writer.write("void " + classname + "::\nset"
+ methodName + "(" + properParamType
+ " pInValue, bool deep, bool makeCopy)\n{\n");
+
+ if (attribs[i].getChoiceElement())
+ {
+ writer.write("\t// For 'choice' you need to ensure that any\n");
+ writer.write("\t// other objects belonging to this union of elements are NULL.\n");
+ }
writer.write("\tif (__axis_deepcopy_" + parameterName + ")\n");
writer.write("\t\tdelete " + parameterName + ";\n");
@@ -190,19 +190,13 @@
writer.write("\t__axis_deepcopy_" + parameterName + " = deep;\n");
- // TODO: wrong! We need to delete the object if deep copy, otherwise NULL it out.
- if (attribs[i].getChoiceElement())
- for (int j = 0; j < attribs.length; j++)
- if ((attribs[j].getChoiceElement()) && (j != i))
- writer.write("\t" + attribs[j].getParamNameAsMember() + " = NULL; \n");
-
writer.write("}\n");
}
else
{
writer.write("void " + classname + "::\nset"
+ methodName + "(" + properParamType + " InValue");
-
+
Type attributeType = attribs[i].getType();
boolean isPointerType = false;
@@ -217,6 +211,12 @@
writer.write(")\n{\n");
+ if (attribs[i].getChoiceElement())
+ {
+ writer.write("\t// For 'choice' you need to ensure that any\n");
+ writer.write("\t// other objects belonging to this union of elements are NULL.\n");
+ }
+
if(isPointerType)
{
writer.write("\tif (__axis_deepcopy_" + parameterName + ")\n");
@@ -259,12 +259,6 @@
else
writer.write("\t" + parameterName + " = InValue ; \n");
- // TODO: wrong! We need to delete the object if deep copy, otherwise NULL it out.
- if (attribs[i].getChoiceElement())
- for (int j = 0; j < attribs.length; j++)
- if ((attribs[j].getChoiceElement()) && (j != i))
- writer.write("\t" + attribs[j].getParamNameAsMember() + " = NULL ; \n");
-
writer.write("}\n");
}
} // for loop
@@ -714,16 +708,9 @@
}
- // Determine whether to print variable used for peaking ahead
- for (int i = 0; i < attribs.length; i++)
- {
- if (!attribs[i].isAttribute() && attribs[i].isOptional() && !attribs[i].isArray() && !attribs[i].isAnyType())
- {
- writer.write("\tconst char* peekedElementName;\n");
- break;
- }
- }
-
+ // Declare variables we use
+ writer.write("\tconst char* peekedElementName;\n");
+
//=============================================================================
// Deserialize attributes.
// Actually, attribute deserialization takes place in same loop as elements
@@ -738,75 +725,105 @@
//=============================================================================
String arrayType = null;
- boolean peekCalled = false;
boolean firstIfWritten = false;
- boolean foundAll = false;
int anyCounter = 0; //counter for any types.
int arrayCount = 0;
+
+ boolean handleAll = false;
+ boolean handleChoice = false;
// Tabs to ensure code alignment
String tab1 = "\t";
- String tab2Default = "";
- String tab2;
+ String tab2 = "\t";
+
+ int startingGroup=0;
+ int endingGroup=0;
for (int i = 0; i < attribs.length; i++)
{
- // Reset tabs
- tab2 = tab2Default + "\t";
-
if (i == attributeParamCount)
CUtils.printBlockComment(writer, "Deserialize elements.");
- //if the attribute is a 'choice' construct we have to peek and make
- // the choice
-
- if (attribs[i].getChoiceElement())
+ // If All, then the element order is arbitrary, so we need a loop. For both
+ // 'choice' and 'all', we need to do a peek.
+ if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
{
- if (!peekCalled)
- {
- writer.write("\tconst char* choiceName=pIWSDZ->peekNextElementName();\n");
- peekCalled = true;
- }
+ endingGroup = i;
if (!firstIfWritten)
{
- writer.write("\tif");
+ startingGroup = i;
+
+ handleChoice = attribs[i].getChoiceElement();
+ handleAll = attribs[i].getAllElement();
+
+ // Flag for us to know when we found element for 'choice'.
+ if (handleChoice)
+ CUtils.printComment(writer, "Deserialize \"choice\" group of elements.");
+ else if (handleAll)
+ {
+ CUtils.printComment(writer, "Deserialize \"all\" group of elements.");
+
+ writer.write("\twhile (true)\n\t{\n");
+
+ // Need to adjust tabs since we will be in a loop
+ tab1 = "\t\t";
+ tab2 = "\t\t";
+ }
+
+ // for choice and all, we need to do a peek.
+ writer.write(tab1 + "peekedElementName=pIWSDZ->peekNextElementName();\n");
+
+ if (handleAll)
+ {
+ writer.write(tab1 + "if (0x00 == *peekedElementName)\n");
+ writer.write(tab1 + "\tbreak;\n");
+ }
+
+ writer.write("\n");
+
+ writer.write(tab1 + "if ");
firstIfWritten = true;
}
else
- writer.write("\telse if");
+ {
+ writer.write(tab1 + "else if ");
+ if (handleAll)
+ tab2 = "\t\t";
+ else if (handleChoice)
+ tab2 = "\t";
+ }
- writer.write("(strcmp(choiceName,\""
- + attribs[i].getElementNameAsSOAPString() + "\")==0)\n\t{\n\t");
- }
- else
- firstIfWritten = false;
+ writer.write("(strcmp(peekedElementName,\""
+ + attribs[i].getElementNameAsSOAPString() + "\")==0)\n");
+ writer.write(tab1 + "{\n");
- //if the attribute is a 'all' construct we have to check Min
- // occures
- if (attribs[i].getAllElement())
- if (attribs[i].getMinOccurs() == 0)
+ if (handleAll)
{
- if (!foundAll)
- {
- writer.write("\tconst char* allName = NULL;\n");
- writer.write("\tbool peekCalled = false;\n");
- foundAll = true;
- }
-
- writer.write("\n\tif(!peekCalled)\n\t{\n\t");
- writer.write("\tallName=pIWSDZ->peekNextElementName();\n");
- writer.write("\t\tpeekCalled = true;\n");
- writer.write("\t}\n");
- writer.write("\tif(strcmp(allName,\""
- + attribs[i].getParamNameAsMember() + "\")==0)\n\t{\n\t");
- writer.write("\tpeekCalled = false;\n\t");
+ writer.write(tab1 + "\tif (param->" + attribs[i].getParamNameAsMember() + ")\n");
+ writer.write(tab1 + "\t\tthrow RedundantElementException(peekedElementName);\n\n");
}
+ }
+ else
+ {
+ if (firstIfWritten)
+ endChoiceOrAll(handleAll, handleChoice, tab1, startingGroup, endingGroup);
+
+ tab1 = "\t";
+ tab2 = "\t";
+
+ firstIfWritten = false;
+ handleAll = false;
+ handleChoice = false;
+ }
+
+ if (handleAll || handleChoice)
+ tab2 += "\t";
if (attribs[i].isAnyType())
{
anyCounter +=1;
- writer.write(tab1 + "param->any" + Integer.toString(anyCounter)+ " = pIWSDZ->getAnyObject();\n");
+ writer.write(tab2 + "param->any" + Integer.toString(anyCounter)+ " = pIWSDZ->getAnyObject();\n");
}
else if (attribs[i].isArray())
{
@@ -819,20 +836,20 @@
baseTypeName = CUtils.getclass4qname(attribs[i].getType().getBaseType());
else
baseTypeName = attribs[i].getTypeName();
-
- writer.write(tab1 + "Axis_Array * array" + arrayCount + " = pIWSDZ->getBasicArray("
+
+ writer.write(tab2 + "Axis_Array * array" + arrayCount + " = pIWSDZ->getBasicArray("
+ CUtils.getXSDTypeForBasicType(baseTypeName) + ", \""
+ attribs[i].getParamNameAsSOAPString()
+ "\",0);\n");
- writer.write(tab1 + "if(param->" + attribs[i].getParamNameAsMember() + " == NULL)\n");
- writer.write(tab1 + "\tparam->" + attribs[i].getParamNameAsMember() + " = new " + attribs[i].getTypeName() + "_Array();\n");
- writer.write(tab1 + "param->" + attribs[i].getParamNameAsMember() + "->clone( *array" + arrayCount + ");\n");
- writer.write(tab1 + "Axis::AxisDelete((void*) array" + arrayCount + ", XSD_ARRAY);\n\n");
+ writer.write(tab2 + "if(param->" + attribs[i].getParamNameAsMember() + " == NULL)\n");
+ writer.write(tab2 + "\tparam->" + attribs[i].getParamNameAsMember() + " = new " + attribs[i].getTypeName() + "_Array();\n");
+ writer.write(tab2 + "param->" + attribs[i].getParamNameAsMember() + "->clone( *array" + arrayCount + ");\n");
+ writer.write(tab2 + "Axis::AxisDelete((void*) array" + arrayCount + ", XSD_ARRAY);\n\n");
}
else
{
arrayType = attribs[i].getTypeName();
- writer.write(tab1 + "pIWSDZ->getCmplxArray(param->" + attribs[i].getParamNameAsMember()
+ writer.write(tab2 + "pIWSDZ->getCmplxArray(param->" + attribs[i].getParamNameAsMember()
+ ", (void*)Axis_DeSerialize_" + arrayType
+ ", (void*)Axis_Create_" + arrayType
+ ", (void*)Axis_Delete_" + arrayType
@@ -844,11 +861,12 @@
String soapTagName = (attribs[i].isAttribute() ? attribs[i].getParamNameAsSOAPString() : attribs[i].getElementNameAsSOAPString());
// We only peek for elements, not element attributes!
- if (attribs[i].isOptional() && !attribs[i].isAttribute())
+ if (attribs[i].isOptional() && !attribs[i].isAttribute() && !handleAll && !handleChoice)
{
writer.write(tab1 + "peekedElementName = pIWSDZ->peekNextElementName();\n");
writer.write(tab1 + "if (strcmp(peekedElementName, \"" + soapTagName + "\") == 0)\n");
writer.write(tab1 + "{\n");
+
tab2 += "\t";
}
@@ -902,7 +920,8 @@
writer.write(tab2 + "}\n");
}
- if (attribs[i].isOptional() && !attribs[i].isAttribute())
+ // TODO - remove this chunk of code...?
+ if (attribs[i].isOptional() && !attribs[i].isAttribute() && !handleAll && !handleChoice)
{
writer.write(tab1 + "}\n");
writer.write(tab1 + "else\n");
@@ -914,10 +933,11 @@
//if complex type
String soapTagName = attribs[i].getParamNameAsSOAPString();
- if (attribs[i].isOptional())
+ if (attribs[i].isOptional() && !handleAll && !handleChoice)
{
writer.write(tab1 + "peekedElementName = pIWSDZ->peekNextElementName();\n");
writer.write(tab1 + "if (strcmp(peekedElementName, \"" + soapTagName + "\") == 0)\n");
+
tab2 += "\t";
}
@@ -928,32 +948,77 @@
+ ", (void*)Axis_Delete_" + attribs[i].getTypeName()
+ ", \"" + soapTagName + "\", Axis_URI_" + attribs[i].getTypeName() + ");\n");
- if (attribs[i].isOptional())
+ // TODO remove following chunk of code...?
+ if (attribs[i].isOptional() && !handleAll && !handleChoice)
{
writer.write(tab1 + "else\n");
writer.write(tab1 + "\tparam->" + attribs[i].getParamNameAsMember() + " = NULL;\n");
}
}
- if (attribs[i].getChoiceElement())
+ if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
writer.write(tab1 + "}\n");
-
- if (attribs[i].getAllElement())
- if (attribs[i].getMinOccurs() == 0)
- writer.write("\t}\n");
-
- writer.write("\n");
- }
+ } // end for-loop
+
+ if (firstIfWritten)
+ endChoiceOrAll(handleAll, handleChoice, tab1, startingGroup, endingGroup);
//=============================================================================
// Deserialize extension, if any, and return status
//=============================================================================
writeDeSerializeExtensionCode();
-
+
+ //=============================================================================
+ // Ensure there are no more elements - there should not be!
+ //=============================================================================
+ writer.write("\n");
+
+ CUtils.printBlockComment(writer, "Ensure no extraneous elements.");
+ writer.write("\tpeekedElementName = pIWSDZ->peekNextElementName();\n");
+ writer.write("\tif (0x00 != *peekedElementName)\n");
+ writer.write("\t\tthrow UnknownElementException(peekedElementName);\n");
+
+ writer.write("\n");
writer.write("\treturn pIWSDZ->getStatus();\n");
writer.write("}\n");
}
+
+ private void endChoiceOrAll(boolean handleAll,
+ boolean handleChoice,
+ String tab1,
+ int startGroup, int endGroup) throws IOException
+ {
+ // If xsd:all xsd:choice - an unknown element check - throw exception.
+
+ if (handleAll)
+ {
+ writer.write(tab1 + "else\n");
+ writer.write(tab1 + "\tthrow UnknownElementException(peekedElementName);\n");
+
+ // Closes for loop
+ writer.write("\t}\n");
+
+ // Verify all fields set if possible.
+ boolean commentPrinted = false;
+ for (int j = startGroup; j <= endGroup; j++)
+ if (attribs[j].getAllElement() && !attribs[j].isArray()
+ && !attribs[j].isOptional() && !attribs[j].isNillable()
+ && attribs[j].getMinOccurs() != 0)
+ {
+ if (!commentPrinted)
+ {
+ CUtils.printComment(writer, "Ensure no missing elements in \"all\" group.");
+ commentPrinted = true;
+ }
+
+ writer.write("\tif (param->" + attribs[j].getParamNameAsMember() + " == NULL)");
+ writer.write(" throw ElementMissingException(\"" + attribs[j].getParamNameAsMember() + "\");\n");
+ }
+ }
+
+ writer.write("\n");
+ }
private void writeCreateGlobalMethod() throws IOException
{
@@ -1022,20 +1087,8 @@
{
if (attribs[i].isArray())
{
- if (attribs[i].getChoiceElement()||attribs[i].getAllElement())
- {
- // This is the 'choice' or 'all' route in the code
- writer.write("\t\t// This a 'choice' so need to ensure that any\n");
- writer.write("\t\t// other objects belonging to this union of elements are empty.\n");
- writer.write("\t\t// NB: Hasn't been implemented yet!\n");
- writer.write("\t" + attribs[i].getParamNameAsMember() + " = new "
- + attribs[i].getTypeName() +"_Array();\n");
- }
- else
- {
- writer.write("\t" + attribs[i].getParamNameAsMember() + " = new "
- + attribs[i].getTypeName() +"_Array();\n");
- }
+ writer.write("\t" + attribs[i].getParamNameAsMember() + " = new "
+ + attribs[i].getTypeName() +"_Array();\n");
}
}
writer.write("\treset();\n");
@@ -1086,22 +1139,9 @@
{
if (attribs[i].isArray())
{
- if (attribs[i].getChoiceElement()||attribs[i].getAllElement())
- {
- // This is the 'choice' or 'all' route in the code
- writer.write("\t\t// This object is a 'choice' or 'all', so need to ensure that any\n");
- writer.write("\t\t// other objects belonging to this union of elements are empty.\n");
- writer.write("\t\t// NB: Hasn't been implemented yet!\n");
- writer.write("\t" + attribs[i].getParamNameAsMember() + " = new "
- + attribs[i].getTypeName() + "_Array( *original."
- + attribs[i].getParamNameAsMember() + ");\n");
- }
- else
- {
- writer.write("\t" + attribs[i].getParamNameAsMember() + " = new "
- + attribs[i].getTypeName() + "_Array(*original."
- + attribs[i].getParamNameAsMember() + ");\n");
- }
+ writer.write("\t" + attribs[i].getParamNameAsMember() + " = new "
+ + attribs[i].getTypeName() + "_Array(*original."
+ + attribs[i].getParamNameAsMember() + ");\n");
}
else if (attribs[i].isAnyType())
{
@@ -1168,18 +1208,7 @@
for (int i = 0; i < attribs.length; i++)
{
if (attribs[i].isArray())
- {
- if (attribs[i].getChoiceElement()||attribs[i].getAllElement())
- {
- writer.write( "\t// This object is a 'choice' or 'all', so need to ensure that any\n");
- writer.write( "\t// other objects belonging to this union of elements are empty.\n");
- writer.write( "\t// NB: Hasn't been implemented yet!\n");
-
- writer.write("\t" + attribs[i].getParamNameAsMember() + "->clear();\n");
- }
- else
- writer.write("\t" + attribs[i].getParamNameAsMember() + "->clear();\n");
- }
+ writer.write("\t" + attribs[i].getParamNameAsMember() + "->clear();\n");
else if (!(attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()))
{
if (attribs[i].isAnyType())
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java Mon Jul 21 13:27:48 2008
@@ -101,6 +101,10 @@
{
try
{
+ writer.write("#include <axis/AxisException.hpp>\n");
+ writer.write("#include <axis/ElementMissingException.hpp>\n");
+ writer.write("#include <axis/RedundantElementException.hpp>\n");
+ writer.write("#include <axis/UnknownElementException.hpp>\n");
writer.write("#include <axis/AxisWrapperAPI.hpp>\n");
writer.write("#include <axis/Axis.hpp>\n\n");
writer.write("#include \"" + this.classname + CUtils.CPP_HEADER_SUFFIX + "\"\n");
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java?rev=678552&r1=678551&r2=678552&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java Mon Jul 21 13:27:48 2008
@@ -594,7 +594,9 @@
//=============================================================================
// Process output parameters
- //=============================================================================
+ //=============================================================================
+
+ String returnStatement = "";
if (isAllTreatedAsOutParams)
{
@@ -781,16 +783,11 @@
} // end for-loop for paramsC
writer.write ("\t\t\t}\n");
- writer.write ("\t\t}\n\n");
- writer.write ("\t\tm_pCall->unInitialize();\n");
}
else if (returntype == null)
{
if (minfo.getOutputMessage () != null)
- writer.write ("\t\t\t\t/*not successful*/\n\t\t\t}\n");
-
- writer.write ("\t\t}\n\n");
- writer.write ("\t\tm_pCall->unInitialize();\n");
+ writer.write ("\t\t\t\t// no output?\n\t\t\t}\n");
}
else if (returntypeisarray)
{
@@ -821,9 +818,8 @@
}
writer.write ("\t\t\t}\n");
- writer.write ("\t\t}\n\n");
- writer.write ("\t\tm_pCall->unInitialize();\n");
- writer.write ("\t\treturn RetArray;\n");
+
+ returnStatement = "\t\treturn RetArray;\n";
}
else if (returntypeissimple)
{
@@ -849,16 +845,14 @@
// writer.write("\t\t\t\tthrow new Exception(\"Unexpected use of nill\");");
}
writer.write ("\t\t\t}\n");
- writer.write ("\t\t}\n\n");
- writer.write ("\t\tm_pCall->unInitialize();\n");
- writer.write ("\t\treturn Ret;\n");
+
+ returnStatement = "\t\treturn Ret;\n";
}
else if (returntype.isAnyType ())
{
writer.write ("\t\t\t\tpReturn = (" + outparamType + "*)m_pCall->getAnyObject();\n\t\t}\n");
- writer.write ("\t\t}\n\n");
- writer.write ("\t\tm_pCall->unInitialize();\n");
- writer.write ("\t\treturn pReturn;\n");
+
+ returnStatement = "\t\treturn pReturn;\n";
}
else
{
@@ -880,11 +874,16 @@
returntype.getElementNameAsSOAPString () + "\", 0);\n\t\t\t}\n");
}
- writer.write ("\t\t}\n\n");
- writer.write ("\t\tm_pCall->unInitialize();\n");
- writer.write ("\t\treturn pReturn;\n");
+
+ returnStatement = "\t\treturn pReturn;\n";
}
+ if (minfo.getOutputMessage () != null)
+ writer.write ("\n\t\t\tcheckForExtraneousElements();\n");
+ writer.write ("\t\t}\n\n");
+ writer.write ("\t\tm_pCall->unInitialize();\n");
+ writer.write(returnStatement);
+
writer.write ("\t}\n");
//=============================================================================