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 ha...@apache.org on 2006/01/20 10:54:16 UTC
svn commit: r370767 -
/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
Author: hawkeye
Date: Fri Jan 20 01:53:52 2006
New Revision: 370767
URL: http://svn.apache.org/viewcvs?rev=370767&view=rev
Log:
Exposed nested anonymous types
Modified:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java?rev=370767&r1=370766&r2=370767&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java Fri Jan 20 01:53:52 2006
@@ -104,6 +104,11 @@
try
{
Parser wsdlParser = new Parser();
+ // set timeout
+ String timeout = cmdLineArgs.getOptionBykey("t");
+ if (timeout != null)
+ wsdlParser.setTimeout(Long.parseLong(timeout));
+
//get the commandline arguments
String wsdlfile = cmdLineArgs.getArgument(0);
wsdlParser.run(wsdlfile);
@@ -695,6 +700,7 @@
throw new WrapperFault("WSDL2Ws does not support the option combination");
exposeReferenceTypes(wsContext);
exposeMessagePartsThatAreAnonymousTypes(wsContext);
+ exposeNestedTypesThatAreAnonymousTypes(wsContext);
if (WSDL2Ws.verbose)
{
@@ -707,6 +713,7 @@
wsg.generate();
}
+
/**
* @param wsContext
*/
@@ -721,7 +728,6 @@
if(!(highLevelType instanceof BaseType))
{
DefinedType type = (DefinedType)highLevelType;
-
if(type.getQName().getLocalPart().toString().startsWith(">")&& !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1))
{
// this is an "inner" type that will not be exposed
@@ -795,6 +801,146 @@
// }
}
+
+ /**
+ * @param wsContext
+ */
+ private void exposeNestedTypesThatAreAnonymousTypes(WebServiceContext wsContext)
+ {
+ // get the main types
+ Collection types = symbolTable.getTypeIndex().values();
+ Iterator typeIterator = types.iterator();
+ while(typeIterator.hasNext())
+ {
+ Object highLevelType = typeIterator.next();
+ if(!(highLevelType instanceof BaseType))
+ {
+ DefinedType type = (DefinedType)highLevelType;
+ if(!type.getQName().getLocalPart().toString().startsWith(">"))
+ {
+// System.out.println( "HERE "+type.getQName().getLocalPart());
+ HashSet nestedTypes = type.getNestedTypes(symbolTable, true);
+ Iterator iterator = nestedTypes.iterator();
+ while(iterator.hasNext())
+ {
+ Object nestedObjectType = iterator.next();
+ if(nestedObjectType instanceof DefinedType)
+ {
+ //System.out.println( "nestedname"+nestedObjectType);
+ DefinedType nestedType =(DefinedType) nestedObjectType;
+ // If the nested parts are complex inner/anonymous types then they need to be exposed as seperate classes
+ String name =nestedType.getQName().getLocalPart().toString();
+ // System.out.println( "iterator next = "+name);
+ if(name.startsWith(">") && name.lastIndexOf(">")>0)
+ {
+ // then this type needs to be exposed !
+ QName oldName = nestedType.getQName();
+// System.out.println( "Exposing nestedType "+oldName);
+// System.out.println( "nestobjecttype = "+nestedObjectType.getClass());
+// QName newTypeName = new QName(oldName.getNamespaceURI(), oldName.getLocalPart().substring(1));
+ QName newTypeName =new QName(oldName.getNamespaceURI(), CUtils.sanitiseClassName(oldName.getLocalPart().toString()));
+
+ Type innerClassType = wsContext.getTypemap().getType(oldName);
+ if(innerClassType!=null)
+ {
+ // First thing to do is to expose the type so it gets created.
+ innerClassType.setLanguageSpecificName(newTypeName.getLocalPart().toString());
+
+ // also have to set the QName because this is used in generating the header info.
+ innerClassType.setName(newTypeName);
+ // The typemap we get back is a copy of the actual typemap so we have to set the new value explicitly
+ // firstly remove the old version
+ wsContext.getTypemap().removeType(oldName);
+ wsContext.getTypemap().addType(newTypeName, innerClassType);
+ }
+
+ // Iterator AllTypes = symbolTable.getTypeIndex().values().iterator();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+
+// }
+// }
+// if(type.getQName().getLocalPart().toString().startsWith(">")&& !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1))
+// {
+// // this is an "inner" type that will not be exposed
+// // however, it needs to be if it is referenced in a message part.
+// // check all the messages
+// ArrayList methods = wsContext.getSerInfo().getMethods();
+// for(int i=0; i<methods.size(); i++)
+// {
+// MethodInfo method = (MethodInfo)methods.get(i);
+// Collection inputParameterTypes = method.getInputParameterTypes();
+// Iterator paramIterator = inputParameterTypes.iterator();
+// while(paramIterator.hasNext())
+// {
+// ParameterInfo parameterInfo =(ParameterInfo)paramIterator.next();
+// Type parameterType = parameterInfo.getType();
+// if(parameterType.getName().equals(type.getQName()))
+// {
+// QName oldName = parameterType.getName();
+// QName newTypeName = new QName(parameterType.getName().getNamespaceURI(), parameterType.getName().getLocalPart().substring(1));
+//
+// Type innerClassType = wsContext.getTypemap().getType(parameterType.getName());
+// // innerClassType.setLanguageSpecificName(newTypeName);
+//
+// // First thing to do is to expose the type so it gets created.
+// innerClassType.setLanguageSpecificName(newTypeName.getLocalPart().toString());
+//
+// // also have to set the QName becuase this is used in generating the header info.
+// innerClassType.setName(newTypeName);
+//
+// // The typemap we get back is a copy of the actual typemap so we have to set the new value explicitly
+// // firstly remove the old version
+// wsContext.getTypemap().removeType(oldName);
+// wsContext.getTypemap().addType(newTypeName, innerClassType);
+//
+// Iterator AllTypes = symbolTable.getTypeIndex().values().iterator();
+// }
+// }
+// }
+//
+// }
+// }
+// }
+
+
+ // ArrayList methods = wsContext.getSerInfo().getMethods();
+ // for(int i=0; i<methods.size(); i++)
+ // {
+ // MethodInfo method = (MethodInfo)methods.get(i);
+ // Collection inputParameterTypes = method.getInputParameterTypes();
+ // Iterator paramIterator = inputParameterTypes.iterator();
+ // while(paramIterator.hasNext())
+ // {
+ // ParameterInfo parameterInfo =(ParameterInfo)paramIterator.next();
+ // Type parameterType = parameterInfo.getType();
+ // if(parameterType.getLanguageSpecificName().startsWith(">"))
+ // {
+ // // Then this type has not been exposed as a seperate class and it needs to be
+ // System.out.println( "got to expose "+parameterType.getName().getLocalPart());
+ // QName exposedName = new QName(parameterType.getName().getNamespaceURI(), parameterType.getName().getLocalPart().substring(1));
+ // // There'#s no point in doing this unless the type map is changed
+ // Type type = wsContext.getTypemap().getType(parameterType.getName());
+ // type.setName(exposedName);
+ // wsContext.getTypemap().removeType(parameterType.getName());
+ // wsContext.getTypemap().addType(exposedName, type);
+ // //parameterType.setLanguageSpecificName(new QName(parameterType.getLanguageSpecificName().substring(1)).toString() );
+ //
+ // // also have to set the QName becuase this is used in generating the header info.
+ // //parameterType.setName(new QName(parameterType.getName().getNamespaceURI(), parameterType.getLanguageSpecificName()));
+ //
+ //
+ // }
+
+// }
+
/**
* This code is taken from the org.apache.axis.wsdl.gen.Parser Class.
* WSDL file should have only one service, The first service
@@ -1317,6 +1463,8 @@
usage();
return;
}
+
+
// WSDL2Ws.makeSystem = data.getOptionBykey("m");