コード例 #1
0
ファイル: TestUtils.cs プロジェクト: baulig/wcf-config
        public static void Deserialize(string xmlFilename, string xsdFilename)
        {
            var context = new Context ();
            var config = new Configuration (context, xmlFilename, xsdFilename);
            Console.WriteLine ("READ CONFIG FROM XML");

            DebugUtils.Dump (config);
        }
コード例 #2
0
ファイル: TestUtils.cs プロジェクト: baulig/wcf-config
        public static void GenerateFromWsdl(Uri uri, string wsdlFilename,
		                                     string xmlFilename, string xsdFilename)
        {
            var doc = Utils.LoadMetadata (uri, wsdlFilename);
            var importer = new WsdlImporter (doc);
            var endpoints = importer.ImportAllEndpoints ();

            var config = new Configuration ();
            foreach (var endpoint in endpoints)
                config.AddEndpoint (endpoint);

            Generator.Write (xmlFilename, xsdFilename, config);
        }
コード例 #3
0
ファイル: BindingTests.cs プロジェクト: baulig/wcf-config
        public static void Run(string xmlFilename, string xsdFilename)
        {
            var http = new BasicHttpBinding ();
            http.OpenTimeout = TimeSpan.FromHours (3);
            http.MaxBufferSize = 8192;
            http.HostNameComparisonMode = HostNameComparisonMode.WeakWildcard;
            http.AllowCookies = true;
            http.Security.Mode = BasicHttpSecurityMode.Transport;
            http.TransferMode = TransferMode.StreamedRequest;

            #if !MOBILE || MOBILE_BAULIG
            var https = new BasicHttpsBinding ();
            https.MaxBufferSize = 32768;
            #endif

            #if !MOBILE_FIXME
            var netTcp = new NetTcpBinding ();
            #endif

            var custom = new CustomBinding ();
            custom.Name = "myCustomBinding";
            var text = new TextMessageEncodingBindingElement ();
            text.MessageVersion = MessageVersion.Soap12WSAddressingAugust2004;
            custom.Elements.Add (text);
            custom.Elements.Add (new HttpTransportBindingElement ());

            var root = new Configuration ();
            root.AddBinding (http);
            #if !MOBILE || MOBILE_BAULIG
            root.AddBinding (https);
            #endif
            #if !MOBILE_FIXME
            root.AddBinding (netTcp);
            #endif
            root.AddBinding (custom);

            var contract = new ContractDescription ("MyContract");
            var endpointUri = "custom://localhost:8888/MyService";
            var endpointAddress = new EndpointAddress (endpointUri);

            var endpoint = new ServiceEndpoint (contract, custom, endpointAddress);

            root.AddEndpoint (endpoint);

            Generator.Write (xmlFilename, xsdFilename, root);

            Utils.Dump (xsdFilename);
            Utils.Dump (xmlFilename);

            Utils.ValidateSchema (xmlFilename, xsdFilename);
        }
コード例 #4
0
ファイル: DebugUtils.cs プロジェクト: baulig/wcf-config
 public static void Dump(Configuration config)
 {
     foreach (var binding in config.Bindings) {
         Console.WriteLine ("BINDING: {0}", binding);
         var http = binding as BasicHttpBinding;
         if (http != null)
             Dump (http);
     #if !MOBILE || MOBILE_BAULIG
         var https = binding as BasicHttpsBinding;
         if (https != null)
             Dump (https);
     #endif
         var custom = binding as CustomBinding;
         if (custom != null)
             Dump (custom);
     }
     foreach (var endpoint in config.Endpoints) {
         Console.WriteLine ("ENDPOINT: {0}", endpoint);
     }
 }
コード例 #5
0
		private ConfigurationHost (string xmlFilename, string xsdFilename)
		{
			context = new Context ();

#if MOBILE
			/*
			 * The Mono.ServiceModel.Configuration.IMonoConfigurationHost
			 * API is public in the mobile profile.
			 */
			MonoConfigurationHost.CustomConfigurationHost = this;
#else
			/*
			 * We use reflection here, so we don't depend on Mono
			 * additions to System.ServiceModel.dll which would cause
			 * problems when using the Mono.ServiceModel.Configuration.dll
			 * with Microsoft's runtime on Windows.
			 */
			if (Environment.OSVersion.Platform != PlatformID.Unix)
				throw new InvalidOperationException (
					"ConfigurationHost can only be used on Mono.");

			var asm = typeof (ChannelFactory).Assembly;
			var type = asm.GetType ("Mono.ServiceModel.Configuration.MonoConfigurationHost", true);
			
			var bf = BindingFlags.Static | BindingFlags.NonPublic;
			var method = type.GetMethod ("SetCustomConfigurationHandler", bf);
			if (method == null)
				throw new InvalidOperationException ();
			
			var dlgType = type.GetNestedType ("CustomConfigurationDelegate", BindingFlags.NonPublic);
			if (dlgType == null)
				throw new InvalidOperationException ();
			
			var handler = Delegate.CreateDelegate (dlgType, this, "ConfigureEndpoint");
			
			method.Invoke (null, new object[] { handler });
#endif
			
			Console.WriteLine ("Custom configuration handler installed.");

			config = new Configuration (context, xmlFilename, xsdFilename);

			foreach (var warning in context.Warnings)
				Console.WriteLine ("WARNING: {0}", warning.Message);
			foreach (var error in context.Errors)
				Console.WriteLine ("ERROR: {0}", error.Message);

			if (context.HasErrors)
				Console.WriteLine ("Failed to load configuration!");

			DebugUtils.Dump (config);
			Console.WriteLine ("Configuration loaded.");
		}