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 2006/12/22 07:40:48 UTC
svn commit: r489566 - in
/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws:
CUtils.java c/BeanParamWriter.java c/ParmHeaderFileWriter.java
cpp/BeanParamWriter.java cpp/ParmHeaderFileWriter.java
info/AttributeInfo.java
Author: nadiramra
Date: Thu Dec 21 22:40:47 2006
New Revision: 489566
URL: http://svn.apache.org/viewvc?view=rev&rev=489566
Log:
AXISCPP-849 - Stub compilation problems when WSDL contains complexTypes and elements of the same name
Modified:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.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/ParmHeaderFileWriter.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/ParmHeaderFileWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/AttributeInfo.java
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java?view=diff&rev=489566&r1=489565&r2=489566
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java Thu Dec 21 22:40:47 2006
@@ -1231,16 +1231,32 @@
return sanitisedName;
}
- public static String sanitiseAttributeName( String classname, String name)
+ // TODO - get rid of this and jsut call above routine directly.
+ public static String sanitiseAttributeName(String name)
{
String sanitisedName = sanitiseClassName( name);
-
- if( classname.equals( sanitisedName))
- sanitisedName += "_";
-
return sanitisedName;
}
+ public static boolean classExists(WebServiceContext wscontext, String name)
+ {
+ Type atype;
+ String atypeName;
+ Iterator types = wscontext.getTypemap().getTypes().iterator();
+ while (types.hasNext())
+ {
+ atype = (Type) types.next();
+ if (!atype.isExternalized())
+ continue;
+
+ atypeName = atype.getLanguageSpecificName();
+ if (null != atypeName && atypeName.equals( name ))
+ return true;
+ }
+
+ return false;
+ }
+
/**
* This routine is used to basically handle anonymous type naming. Anonymous types
* have names such as '>type' and '>>type>type2', the latter being a nested type.
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?view=diff&rev=489566&r1=489565&r2=489566
==============================================================================
--- 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 Thu Dec 21 22:40:47 2006
@@ -52,6 +52,8 @@
{
try
{
+ // Ensure writeSerializeGlobalMethod() is first since it ensure attribute name does not conflict with
+ // existing classes
writeSerializeGlobalMethod();
writeDeSerializeGlobalMethod();
writeCreateGlobalMethod();
@@ -129,6 +131,12 @@
writer.write("\t/* If there are any attributes serialize them. If there aren't then close the tag */\n");
for (int i = 0; i < attributeParamCount; i++)
{
+ // Ensure field name is valid and does not cause conflict with class names
+ String sanitizedAttrName = CUtils.sanitiseAttributeName(attribs[i].getParamName());
+ if (CUtils.classExists(wscontext, sanitizedAttrName))
+ sanitizedAttrName += "_";
+ attribs[i].setParamName(sanitizedAttrName);
+
if (attribs[i].isArray() || !(attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()))
{
throw new WrapperFault("Error : an attribute is not basic type");
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java?view=diff&rev=489566&r1=489565&r2=489566
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java Thu Dec 21 22:40:47 2006
@@ -263,7 +263,11 @@
{
for (int i = 0; i < attribs.length; i++)
{
- attribs[i].setParamName( CUtils.sanitiseAttributeName( classname, attribs[i].getParamName()));
+ // Ensure field name is valid and does not cause conflict with class names
+ String sanitizedAttrName = CUtils.sanitiseAttributeName(attribs[i].getParamName());
+ if (CUtils.classExists(wscontext, sanitizedAttrName))
+ sanitizedAttrName += "_";
+ attribs[i].setParamName(sanitizedAttrName);
if (isElementNillable(i)
|| attribs[i].isArray()
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?view=diff&rev=489566&r1=489565&r2=489566
==============================================================================
--- 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 Thu Dec 21 22:40:47 2006
@@ -67,6 +67,8 @@
{
try
{
+ // Ensure writeGetSetMethods() is first since it ensure attribute name does not conflict with
+ // existing classes
writeGetSetMethods();
writeSerializeGlobalMethod();
writeDeSerializeGlobalMethod();
@@ -98,20 +100,17 @@
{
for (int i = 0; i < attribs.length; i++)
{
- attribs[i].setParamName( CUtils.sanitiseAttributeName(classname, attribs[i].getParamName()));
+ // Ensure field name is valid and does not cause conflict with class names
+ String sanitizedAttrName = CUtils.sanitiseAttributeName(attribs[i].getParamName());
+ attribs[i].setMethodName(sanitizedAttrName);
+ if (CUtils.classExists(wscontext, sanitizedAttrName))
+ sanitizedAttrName += "_";
+ attribs[i].setParamName(sanitizedAttrName);
- String methodName = attribs[i].getParamNameWithoutSymbols();
- String parameterName = methodName;
+ String methodName = attribs[i].getMethodName();
+ String parameterName = sanitizedAttrName;
String properParamName = getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]);
String type = attribs[i].getTypeName();
-
- if( methodName.endsWith( "_"))
- {
- String localMethodName = methodName.substring( 0, methodName.length() - 1);
-
- if( localMethodName.equals( classname))
- methodName = localMethodName;
- }
if (attribs[i].isArray())
{
@@ -932,8 +931,6 @@
baseTypeName = CUtils.getclass4qname (type.getBaseType ());
else
baseTypeName = typeName;
-
- String elementName = attribs[i].getParamNameAsMember();
if( isPointerType)
{
@@ -949,15 +946,11 @@
}
writer.write( "\t\t\tif( pValue" + i + " == NULL)\n");
- writer.write("\t\t\t\tparam->" + elementName + " = NULL;\n");
+ writer.write("\t\t\t\tparam->" + attribs[i].getParamNameAsMember() + " = NULL;\n");
writer.write( "\t\t\telse\n");
writer.write( "\t\t\t{\n");
- String localElemName = elementName;
- if( elementName.endsWith( "_"))
- localElemName = elementName.substring( 0, elementName.length() - 1);
-
- writer.write("\t\t\t\tparam->set" + localElemName + " (pValue" + i + ");\n");
+ writer.write("\t\t\t\tparam->set" + attribs[i].getMethodName() + " (pValue" + i + ");\n");
writer.write("\t\t\t\tAxis::AxisDelete( (void *) pValue" + i + ", "
+ CUtils.getXSDTypeForBasicType( baseTypeName) + ");\n\n");
writer.write( "\t\t\t}\n\n");
@@ -981,13 +974,9 @@
+ CUtils.getParameterGetValueMethodName(
attribs[i].getTypeName(), attribs[i].isAttribute()) + "( \""
+ elementNameToSearchFor + "\",0)) != NULL)\n\t{\n");
-
- String localElemName = attribs[i].getParamNameAsMember();
- if( localElemName.endsWith( "_"))
- localElemName = localElemName.substring( 0, localElemName.length() - 1);
writer.write("\t\tparam->set"
- + localElemName + "(* " + attribs[i].getParamNameAsMember() + " );\n");
+ + attribs[i].getMethodName() + "(* " + attribs[i].getParamNameAsMember() + " );\n");
writer.write("\t\tAxis::AxisDelete( (void *) " + attribs[i].getParamNameAsMember() + ", " + CUtils.getXSDTypeForBasicType( attribs[i].getTypeName()) + ");\n");
writer.write("\t}\n");
}
@@ -1211,15 +1200,7 @@
{
writer.write("\t" + attribs[i].getParamName() + " = NULL;\n");
writer.write("\t__axis_deepcopy_" + attribs[i].getParamName() + " = false;\n");
- String methodName = attribs[i].getParamNameWithoutSymbols();
- if( methodName.endsWith( "_"))
- {
- String localMethodName = methodName.substring( 0, methodName.length() - 1);
-
- if( localMethodName.equals( classname))
- methodName = localMethodName;
- }
- writer.write("\tset" + methodName + "(original." + attribs[i].getParamName() + ", original.__axis_deepcopy_" + attribs[i].getParamName() + ");\n\n");
+ writer.write("\tset" + attribs[i].getMethodName() + "(original." + attribs[i].getParamName() + ", original.__axis_deepcopy_" + attribs[i].getParamName() + ");\n\n");
}
else if (attribs[i].isSimpleType())
{
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java?view=diff&rev=489566&r1=489565&r2=489566
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java Thu Dec 21 22:40:47 2006
@@ -316,7 +316,12 @@
writer.write("public:\n");
for (int i = 0; i < attribs.length; i++)
{
- attribs[i].setParamName( CUtils.sanitiseAttributeName(classname, attribs[i].getParamName()));
+ // Ensure field name is valid and does not cause conflict with class names
+ String sanitizedAttrName = CUtils.sanitiseAttributeName(attribs[i].getParamName());
+ attribs[i].setMethodName(sanitizedAttrName);
+ if (CUtils.classExists(wscontext, sanitizedAttrName))
+ sanitizedAttrName += "_";
+ attribs[i].setParamName(sanitizedAttrName);
if (isElementNillable(i)
|| attribs[i].isArray()
@@ -412,15 +417,7 @@
{
for (int i = 0; i < attribs.length; i++)
{
- String methodName = attribs[i].getParamNameWithoutSymbols();
-
- if( methodName.endsWith( "_"))
- {
- String localMethodName = methodName.substring( 0, methodName.length() - 1);
-
- if( localMethodName.equals( classname))
- methodName = localMethodName;
- }
+ String methodName = attribs[i].getMethodName();
if (isElementNillable(i) || attribs[i].isArray() || isElementOptional(i))
{
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/AttributeInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/AttributeInfo.java?view=diff&rev=489566&r1=489565&r2=489566
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/AttributeInfo.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/AttributeInfo.java Thu Dec 21 22:40:47 2006
@@ -38,6 +38,7 @@
private String typeNamespace;
private String className;
private String attribNameAsMember;
+ private String methodName;
//this variable states whether the attribute is an xsd:choice
private boolean choiceElement = false;
@@ -162,6 +163,7 @@
this.isSimpleType = isSimpleType;
}
+ // TODO - probably can remove since we sanitize attribute name.
public String getParamNameAsMember()
{
this.attribNameAsMember = super.getParamNameWithoutSymbols();
@@ -177,6 +179,7 @@
{
super.setParamName(paramName);
+ // TODO - probably can remove since we sanitize attribute name.
// make sure attributes does not have the same name as class name
if (this.className != null && this.className.equals(attribName))
this.attribNameAsMember = "m_" + attribName;
@@ -250,5 +253,15 @@
public void setMinOccurs(int minOccurs)
{
this.minOccurs = minOccurs;
+ }
+
+ public String getMethodName()
+ {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName)
+ {
+ this.methodName = methodName;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org