CppType HandleArrayType(wsdlParser.qname typeName, MSXML2.ISchemaComplexType typeDesc) { MSXML2.ISchemaComplexType ct = typeDesc; MSXML2.ISchemaItem encArrayType = ct.attributes.itemByQName("arrayType", Consts.SOAP_11_ENCODING); string wsdlArrayType = null; for (int idx = 0; idx < encArrayType.unhandledAttributes.length; idx++) { if ((encArrayType.unhandledAttributes.getLocalName(idx) == "arrayType") && (encArrayType.unhandledAttributes.getURI(idx) == Consts.WSDL_URL)) { wsdlArrayType = encArrayType.unhandledAttributes.getValue(idx); break; } } if (wsdlArrayType == null) { throw new ApplicationException("SOAP-ENC:Array derivation must include a wsdl:arrayType attribute"); } wsdlParser.qname qn = new wsdlParser.qnameClass(); int lastColon = wsdlArrayType.LastIndexOf(":"); qn.@namespace = wsdlArrayType.Substring(0, lastColon); int rank = wsdlArrayType.IndexOf("[", lastColon); qn.localname = wsdlArrayType.Substring(lastColon + 1, rank - lastColon - 1); CppType itemType = mapType(qn); CppType t = CppType.CreateArray(itemType, CppType.ArrayType.Encoded, false, qn); m_typesCache.Add(typeName.ExpandedName, t); if (t.Style == CppType.TypeStyle.Object) { string qnln = m_factory.IdForString(qn.localname, IdType.Localname); string qnns = m_factory.IdForString(qn.@namespace, IdType.Namespace); string psad = m_factory.IdForString("PocketSOAP.ArrayDeserializer.1", IdType.ProgId); string psas = m_factory.IdForString("PocketSOAP.ArraySerializer.1", IdType.ProgId); m_factory.Add(string.Format("m_sf->Deserializer({0}, {1}, VARIANT_TRUE, VT_UNKNOWN, {2});", qnln, qnns, psad)); m_factory.Add(string.Format("m_sf->Serializer(VT_UNKNOWN | VT_ARRAY, {0}, {1}, {2});", qnln, qnns, psas)); } return(t); }
CppType CreateComplexType(wsdlParser.qname typeName, MSXML2.ISchemaComplexType typeDesc) { // look to see if its a section 5 encoded array first foreach (MSXML2.ISchemaType bt in typeDesc.baseTypes) { if ((bt.name == "Array") && (bt.namespaceURI == Consts.SOAP_11_ENCODING)) { return(HandleArrayType(typeName, typeDesc)); } } CppType t = CppType.Create((int)VarEnum.VT_UNKNOWN, NameBuilder(typeName), CppType.ArrayType.NotArray, CppType.TypeStyle.Object, false, typeName); // a qname for the serializer class wsdlParser.qname tSerQName = new wsdlParser.qnameClass(); tSerQName.localname = "s" + typeName.localname; tSerQName.@namespace = "http://serializers.schemas.pocketsoap.com/"; // register the type mapping now, incase there is some recursive nonsense going on m_typesCache[typeName.ExpandedName] = t; // a complexTypeWriter ComplexTypeWriter ctw = new ComplexTypeWriter(m_project, typeName.ExpandedName, t.CppName); // a SerializerWriter SerializerWriter sw = new SerializerWriter(m_project, tSerQName, NameBuilder(tSerQName), t.CppName); MSXML2.ISchemaComplexType complexType = typeDesc; MSXML2.ISchemaModelGroup smg = complexType.contentModel; // walk through each contained particle // attributes foreach (MSXML2.ISchemaAttribute attr in complexType.attributes) { wsdlParser.qname ptype = new wsdlParser.qnameClass(); ptype.@namespace = attr.type.namespaceURI; ptype.localname = attr.type.name; CppType itemType = mapType(ptype); string itemName = vcProject.safeClassName(attr.name); ctw.AddPropertyField(itemName, itemType); sw.AddAttribute(itemName, itemType, attr, ptype); } AddElementsToContainer(typeName, smg, ctw, sw); ctw.Complete(); sw.Complete(); // add type registrations string serProgId = m_project.ProjectName + "." + sw.SerializerName; string clsProgId = m_project.ProjectName + "." + ctw.ComplexTypeName; string clsItfIID = string.Format("CComVariant(OLESTR(\"{{{0}}}\"))", ctw.InterfaceIID); m_factory.Add(string.Format("m_sf->Serializer({0}, CComBSTR(OLESTR(\"{1}\")), CComBSTR(OLESTR(\"{2}\")), CComBSTR(OLESTR(\"{3}\")));", clsItfIID, typeDesc.name, typeDesc.namespaceURI, serProgId)); string typeLN = string.Format("CComBSTR(OLESTR(\"{0}\"))", typeName.localname); string typeNS = string.Format("CComBSTR(OLESTR(\"{0}\"))", typeName.@namespace); m_factory.Add(string.Format("m_sf->Deserializer({0}, {1}, VARIANT_FALSE, CComVariant(OLESTR(\"{2}\")), {3});", typeLN, typeNS, clsProgId, makeBstr(serProgId))); return(t); }