From 06c3beb8e8ee45b0075fdc9bfbb0f7e019679ccb Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Thu, 18 Jun 2009 01:39:13 +0000 Subject: [PATCH] --- wsdl/gw2wsdl.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/wsdl/gw2wsdl.py b/wsdl/gw2wsdl.py index c6070ed7..682733cd 100755 --- a/wsdl/gw2wsdl.py +++ b/wsdl/gw2wsdl.py @@ -63,7 +63,7 @@ def name_complex_type(arg): #if (complex_types.has_key(arg)): # return complex_types[arg] - types_section = types.getElementsByTagName("wsdl:types")[0] + types_section = types.getElementsByTagName("xsd:schema")[0] if (isinstance(arg, Mixed)): inner_types = reduce(fold_complex_type, arg) @@ -89,9 +89,33 @@ def name_complex_type(arg): elif (isinstance(arg, Parameter)): return (name_simple_type(arg.type)) elif type(arg) == ListType or type(arg) == TupleType: - return "sequence" - elif type(arg) == DictType or arg == DictType: - return "dict" + inner_type = name_complex_type(arg[0]) + num_types=num_types+1 + type_name = "Type%d"%num_types + complex_type = types_section.appendChild(types.createElement("xsd:complexType")) + complex_type.setAttribute("name", type_name) + complex_content = complex_type.appendChild(types.createElement("xsd:complexContent")) + restriction = complex_content.appendChild(types.createElement("restriction")) + restriction.setAttribute("base","Array") + attribute = restriction.appendChild(types.createElement("attribute")) + attribute.setAttribute("wsdl:arrayType",inner_type+"[]") + return "tns:%s"%type_name + + elif type(arg) == DictType or arg == DictType or issubclass(arg, dict): + num_types=num_types+1 + type_name = "Type%d"%num_types + complex_type = types_section.appendChild(types.createElement("xsd:complexType")) + complex_type.setAttribute("name", type_name) + complex_content = complex_type.appendChild(types.createElement("xsd:sequence")) + + for k in arg.fields: + inner_type = name_complex_type(arg.fields[k]) + element=complex_content.appendChild(types.createElement("xsd:element")) + element.setAttribute("name",k) + element.setAttribute("type",inner_type) + + return "tns:%s"%type_name + else: return (name_simple_type(arg)) @@ -99,7 +123,7 @@ def name_simple_type(arg_type): if arg_type == None: return "none" if arg_type == DictType: - return "xsd:dict" + return "xsd:anyType" elif arg_type == IntType or arg_type == LongType: return "xsd:int" elif arg_type == bool: @@ -109,8 +133,8 @@ def name_simple_type(arg_type): elif arg_type in StringTypes: return "xsd:string" else: - #pdb.set_trace() - raise SoapError, "Cannot handle %s objects" % arg_type + pdb.set_trace() + raise SoapError, "Cannot handle %s objects" % arg_type def param_type(arg): return (name_complex_type(arg)) @@ -237,7 +261,7 @@ def get_wsdl_definitions(): name="auto_generated" targetNamespace="%s" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" - xmlns:tns="xmlns:%s" + xmlns:tns="%s" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/> """ % (globals.plc_ns,globals.plc_ns) @@ -251,8 +275,8 @@ def get_wsdl_definitions_and_types(): -- 2.47.0