Beispiel #1
0
        /**
         * This method binding the service
         */
        private Boolean bindProxyService()
        {
            Debug.Print("Binding proxy service...");
            try
            {
                WS2007HttpBinding a = new WS2007HttpBinding();
                ProtocolVersion11 b = new ProtocolVersion11();
                proxy = new IService1ClientProxy(a, b);

                // NOTE: the endpoint needs to match the endpoint of the servicehost
                proxy.EndpointAddress = SERVICE_ADDR;
            }
            catch (SocketException e)
            {
                WindowsManager.showWindowServiceDown();
                return(false);
            }
            catch (ObjectDisposedException e)
            {
                Debug.Print("Disposed object exception");
                WindowsManager.showWindowServiceDown();
                return(false);
            }


            Debug.Print("Binding proxy service COMPLETE");
            return(true);
        }
Beispiel #2
0
        public void Start()
        {
            // Initialize the binding
            //Guid g = Guid.NewGuid();
            string guid = "urn:uuid:18571766-87df-06e2-bb68-5136c48f483f";

            ProtocolVersion version = new ProtocolVersion11();

            // ProtocolVersion10 can be used only if the corresponding HelloWorldClient_WCF application
            // uses a custom binding with Soap12WSAddressingAugust2004 text message encoding.
            //ProtocolVersion version = new ProtocolVersion10();

            Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig(guid, 8084)), version);

            // Set device information
            Device.ThisModel.Manufacturer    = "Microsoft Corporation";
            Device.ThisModel.ManufacturerUrl = "http://www.microsoft.com/";
            Device.ThisModel.ModelName       = "SimpleService Test Device";
            Device.ThisModel.ModelNumber     = "1.0";
            Device.ThisModel.ModelUrl        = "http://www.microsoft.com/";
            Device.ThisModel.PresentationUrl = "http://www.microsoft.com/";

            Device.ThisDevice.FriendlyName    = "HelloWorldService";
            Device.ThisDevice.FirmwareVersion = "alpha";
            Device.ThisDevice.SerialNumber    = "32345678";

            // Add a Host service type
            Device.Host = new HelloWCFService(version);

            // Add Dpws hosted service(s) to the device
            Device.HostedServices.Add(new IServiceHelloWCF(new ServiceHelloWCFImplementation()));

            // Set this device property if you want to ignore this clients request
            Device.IgnoreLocalClientRequest = false;

            // Turn console messages on
            Console.Verbose = true;

            System.Ext.Console.Write("Start DPWS device service with endpoint address: '" + Device.EndpointAddress + "'");

            ServerBindingContext ctx = new ServerBindingContext(version);

            // Start the device
            Device.Start(ctx);
        }
Beispiel #3
0
        public void Run()
        {
            Uri remoteEp = new Uri("http://localhost:8084/ServiceHelloWCF.svc");
            WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(remoteEp));

            ProtocolVersion ver = new ProtocolVersion11();

            // To enable WSDiscoveryApril2005 and Soap12WSAddressingAugust2004
            //ProtocolVersion ver = new ProtocolVersion10();

            /// ProtocolVersion11 can be used if the corresponding WCF desktop server application
            /// WcfServer uses wsHttpBinding instead of the custom binding "Soap11AddressingBinding"
            m_clientProxy = new ServiceHelloWCFClientProxy(binding, ver);

            m_clientProxy.IgnoreRequestFromThisIP = false;

            if (!Discover(m_clientProxy))
            {
                Debug.Print("Discovery failed, trying direct address");
            }

            HelloWCF req = new HelloWCF();

            req.name = "World";

            try
            {
                HelloWCFResponse resp = m_clientProxy.HelloWCF(req);

                Debug.Print("\n\n*****************");
                Debug.Print(resp.HelloWCFResult);
                Debug.Print("*****************\n\n");
            }
            catch (WsFaultException ex)
            {
                Debug.Print("DPWS Fault: " + ex.Message);
            }
            finally
            {
                m_clientProxy.Dispose();
            }
        }
Beispiel #4
0
        //SimpleServiceClient client;

        public void Start()
        {
            // Initialize the binding
            string          guid    = "urn:uuid:18571766-87df-06e2-bb68-5136c48f483a";
            ProtocolVersion version = new ProtocolVersion11();

            // To enable WSDiscoveryApril2005 and Soap12WSAddressingAugust2004
            //ProtocolVersion version = new ProtocolVersion10();
            Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig(guid, 8084)), version);

            // Set device information
            Device.ThisModel.Manufacturer    = "Microsoft Corporation";
            Device.ThisModel.ManufacturerUrl = "http://www.microsoft.com/";
            Device.ThisModel.ModelName       = "SimpleService Test Device";
            Device.ThisModel.ModelNumber     = "1.0";
            Device.ThisModel.ModelUrl        = "http://www.microsoft.com/";
            Device.ThisModel.PresentationUrl = "http://www.microsoft.com/";

            Device.ThisDevice.FriendlyName    = "SimpleService";
            Device.ThisDevice.FirmwareVersion = "alpha";
            Device.ThisDevice.SerialNumber    = "12345678";

            // Add a Host service type
            Device.Host = new SimpleDeviceHost(version);

            // make sure event sink connections remain open as long as the
            // the subscription is alive.
            Device.SubscriptionManager.PersistEventConnections = true;

            // Add Dpws hosted service(s) to the device
            Device.HostedServices.Add(new SimpleService(new SimpleServiceImplementation(), version));
            EventingService eventingService = new EventingService(version);

            Device.HostedServices.Add(eventingService);
            Device.HostedServices.Add(new AttachmentService(new AttachmentServiceImplementation(), version));

            // Add a Dpws client to this device. Uncomment to run a client and device
            //client = new SimpleServiceClient();

            // Set this device property if you want to ignore this clients request
            Device.IgnoreLocalClientRequest = false;

            // Turn console messages on
            Console.Verbose = true;

            System.Ext.Console.Write("Start DPWS device service with endpoint address: '" + Device.EndpointAddress + "'");

            // Start the device
            ServerBindingContext ctx = new ServerBindingContext(version);

            Device.Start(ctx);

            //TEST RESTART CAPABILITY
            //Thread.Sleep(3000);
            //Device.Stop();
            //Thread.Sleep(100);
            //Device.Start(ctx);

            // Events cause WsFaultExceptions if loopback messages are used.
            if (Device.IgnoreLocalClientRequest)
            {
                // Create and start EventSimulator
                EventSimulator eventSimulator = new EventSimulator(eventingService);
                eventSimulator.StartEventSimulator();
            }
        }