public void Reflect (Type type, string url)
		{
			XmlSchemaExporter schemaExporter = new XmlSchemaExporter (Schemas);
			SoapSchemaExporter soapSchemaExporter = new SoapSchemaExporter (Schemas);
			
			new SoapProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
			
			if (WSConfig.IsSupported (WSProtocol.HttpGet))
				new HttpGetProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
			
#if NET_1_1
			if (WSConfig.IsSupported (WSProtocol.HttpPost) || WSConfig.IsSupported (WSProtocol.HttpPostLocalhost))
#else
			if (WSConfig.IsSupported (WSProtocol.HttpPost))
#endif
				new HttpPostProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
				
			int i=0;
			while (i < types.Schemas.Count) {
				if (types.Schemas[i].Items.Count == 0) types.Schemas.RemoveAt (i);
				else i++;
			}
			
			if (serviceDescriptions.Count == 1)
				serviceDescriptions[0].Types = types;
			else
			{
				foreach (ServiceDescription d in serviceDescriptions)
				{
					d.Types = new Types();
					for (int n=0; n<types.Schemas.Count; n++)
						ProtocolReflector.AddImport (d, types.Schemas[n].TargetNamespace, GetSchemaUrl (url, n));
				}
			}
		}
예제 #2
0
		private XmlSchemas Export (Type type, SoapAttributeOverrides overrides, string defaultNamespace)
		{
			SoapReflectionImporter ri = new SoapReflectionImporter (overrides, defaultNamespace);
			XmlSchemas schemas = new XmlSchemas ();
			SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
			XmlTypeMapping tm = ri.ImportTypeMapping (type);
			sx.ExportTypeMapping (tm);
			return schemas;
		}
예제 #3
0
		internal void Reflect (ServiceDescriptionReflector serviceReflector, Type type, string url, XmlSchemaExporter xxporter, SoapSchemaExporter sxporter)
		{
			portNames = new CodeIdentifiers ();
			this.serviceReflector = serviceReflector;
			serviceUrl = url;
			serviceType = type;
			
			schemaExporter = xxporter;
			soapSchemaExporter = sxporter;
			
			typeInfo = TypeStubManager.GetTypeStub (type, ProtocolName);
			
			ServiceDescription desc = ServiceDescriptions [typeInfo.LogicalType.WebServiceNamespace];
			
			if (desc == null)
			{
				desc = new ServiceDescription ();
				desc.TargetNamespace = typeInfo.LogicalType.WebServiceNamespace;
				desc.Name = typeInfo.LogicalType.WebServiceName;
				ServiceDescriptions.Add (desc);
			}
			
			ImportService (desc, typeInfo, url);			
		}
예제 #4
0
		[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
/*
#if NET_2_0
		[Category ("NotWorking")] // minOccurs is 1 on Mono
#endif
 */
		public void ExportClass_SimpleClass_Array ()
		{
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			SoapAttributes attr = new SoapAttributes ();
			SoapElementAttribute element = new SoapElementAttribute ();
			element.ElementName = "saying";
			element.IsNullable = true;
			attr.SoapElement = element;
			overrides.Add (typeof (SimpleClass), "something", attr);

			SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
			XmlSchemas schemas = new XmlSchemas ();
			SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
			XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
			sx.ExportTypeMapping (tm);

			Assert.AreEqual (1, schemas.Count, "#1");

			StringWriter sw = new StringWriter ();
			schemas[0].Write (sw);

			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
#if NET_2_0
				"<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
#else
				"<xs:schema xmlns:tns=\"NSSimpleClassArray\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
#endif
				"  <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
				"  <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
				"  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
				"    <xs:complexContent mixed=\"false\">{0}" +
				"      <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
				"        <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
				"      </xs:restriction>{0}" +
				"    </xs:complexContent>{0}" +
				"  </xs:complexType>{0}" +
				"  <xs:complexType name=\"SimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
#if NET_2_0
				"      <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
#else
				"      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
#endif
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
		}