Click here to Skip to main content
15,892,674 members
Articles / Programming Languages / Visual Basic

Microsoft Robotics Studio (MSRS) and Windows Communication Foundation (WCF) Work Together

Rate me:
Please Sign up or sign in to vote.
4.80/5 (36 votes)
20 Oct 20066 min read 64.3K   1.1K   57  
A sample of collaboration between MSRS service and WinForm application by means of WCF services.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using Microsoft.Ccr.Core;
using Microsoft.Dss.ServiceModel.Dssp;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using W3C.Soap;
using compression = System.IO.Compression;
using contractmodel = Microsoft.Dss.Services.ContractModel;
using io = System.IO;
using pxfilewatcher = Robotics.FileWatcher.Proxy;
using reflection = System.Reflection;

[assembly: ContractNamespace(pxfilewatcher.Contract.Identifier, ClrNamespace="Robotics.FileWatcher.Proxy")]


namespace Robotics.FileWatcher.Proxy
{
    
    /// <summary>
    /// FileWatcher Contract
    /// </summary>
    [XmlTypeAttribute(IncludeInSchema=false)]
    public sealed class Contract
    {
        /// The Unique Contract Identifier for the FileWatcher service
        public const String Identifier = "http://schemas.tempuri.org/2006/09/filewatcher.html";
        /// The Dss Service dssModel Contract(s)
        public static List<contractmodel.ServiceSummary> ServiceModel()
        {
            List<contractmodel.ServiceSummary> services = null;
            io.Stream stream = null;
            try
            {
                string Resource = @"Robotics.FileWatcher.Resources.DssModel.dss";
                stream = reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Resource);
                compression.GZipStream compressionStream = new compression.GZipStream(stream, compression.CompressionMode.Decompress, true);
                XmlSerializer serializer = new XmlSerializer(typeof(List<contractmodel.ServiceSummary>));
                services = (List<contractmodel.ServiceSummary>)serializer.Deserialize(compressionStream);
                compressionStream.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error retrieving Dss Service Model: ", ex.Message);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream = null;
                }
            }
            return services;

        }
    }
    /// <summary>
    /// File Watcher State
    /// </summary>
    [DataContract()]
    [XmlRootAttribute("FileWatcherState", Namespace="http://schemas.tempuri.org/2006/09/filewatcher.html")]
    public class FileWatcherState : System.ICloneable
    {
        private String _watcherRootDir;
        /// <summary>
        /// watcher Root Dir
        /// </summary>
        [DataMember()]
        public String watcherRootDir
        {
            get
            {
                return this._watcherRootDir;
            }
            set
            {
                this._watcherRootDir = value;
            }
        }
        public void CopyTo(FileWatcherState target)
        {
            target.watcherRootDir = this.watcherRootDir;
        }
        public virtual object Clone()
        {
            FileWatcherState target = new FileWatcherState();

            target.watcherRootDir = this.watcherRootDir;
            return target;

        }
    }
    /// <summary>
    /// Watch Files Request
    /// </summary>
    [DataContract()]
    [XmlRootAttribute("WatchFilesRequest", Namespace="http://schemas.tempuri.org/2006/09/filewatcher.html")]
    public class WatchFilesRequest : System.ICloneable
    {
        private String _relativePath;
        private String _action;
        /// <summary>
        /// relative Path
        /// </summary>
        [DataMember()]
        public String relativePath
        {
            get
            {
                return this._relativePath;
            }
            set
            {
                this._relativePath = value;
            }
        }
        /// <summary>
        /// action
        /// </summary>
        [DataMember()]
        public String action
        {
            get
            {
                return this._action;
            }
            set
            {
                this._action = value;
            }
        }
        public void CopyTo(WatchFilesRequest target)
        {
            target.relativePath = this.relativePath;
            target.action = this.action;
        }
        public virtual object Clone()
        {
            WatchFilesRequest target = new WatchFilesRequest();

            target.relativePath = this.relativePath;
            target.action = this.action;
            return target;

        }
    }
    /// <summary>
    /// File Watcher Operations
    /// </summary>
    [XmlTypeAttribute(IncludeInSchema=false)]
    public class FileWatcherOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, Replace, WatchFiles, Subscribe>
    {
        // Post DsspDefaultLookup and return the response port.
        public virtual PortSet<LookupResponse,Fault> DsspDefaultLookup(LookupRequestType body)
        {
            DsspDefaultLookup op = new DsspDefaultLookup();
            op.Body = body ?? new LookupRequestType();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post DsspDefaultLookup and return the response port.
        public virtual PortSet<LookupResponse,Fault> DsspDefaultLookup()
        {
            DsspDefaultLookup op = new DsspDefaultLookup();
            op.Body = new LookupRequestType();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post DsspDefaultDrop and return the response port.
        public virtual PortSet<DefaultDropResponseType,Fault> DsspDefaultDrop(DropRequestType body)
        {
            DsspDefaultDrop op = new DsspDefaultDrop();
            op.Body = body ?? new DropRequestType();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post DsspDefaultDrop and return the response port.
        public virtual PortSet<DefaultDropResponseType,Fault> DsspDefaultDrop()
        {
            DsspDefaultDrop op = new DsspDefaultDrop();
            op.Body = new DropRequestType();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post Get and return the response port.
        public virtual PortSet<FileWatcherState,Fault> Get(GetRequestType body)
        {
            Get op = new Get();
            op.Body = body ?? new GetRequestType();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post Replace and return the response port.
        public virtual PortSet<DefaultReplaceResponseType,Fault> Replace(FileWatcherState body)
        {
            Replace op = new Replace();
            op.Body = body ?? new FileWatcherState();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post WatchFiles and return the response port.
        public virtual PortSet<DefaultUpdateResponseType,Fault> WatchFiles(WatchFilesRequest body)
        {
            WatchFiles op = new WatchFiles();
            op.Body = body ?? new WatchFilesRequest();
            this.Post(op);
            return op.ResponsePort;

        }
        // Post Subscribe and return the response port.
        public virtual PortSet<SubscribeResponseType,Fault> Subscribe(SubscribeRequestType body, IPort notificationPort)
        {
            Subscribe op = new Subscribe();
            op.Body = body ?? new SubscribeRequestType();
            op.NotificationPort = notificationPort;
            this.Post(op);
            return op.ResponsePort;

        }
        // Post Subscribe and return the response port.
        public virtual PortSet<SubscribeResponseType,Fault> Subscribe(IPort notificationPort)
        {
            Subscribe op = new Subscribe();
            op.Body = new SubscribeRequestType();
            op.NotificationPort = notificationPort;
            this.Post(op);
            return op.ResponsePort;

        }
    }
    /// <summary>
    /// Get
    /// </summary>
    [XmlTypeAttribute(IncludeInSchema=false)]
    public class Get : Get<GetRequestType, PortSet<FileWatcherState, Fault>>
    {
        public Get()
        {
        }
        public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body) : 
                base(body)
        {
        }
        public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body, Microsoft.Ccr.Core.PortSet<FileWatcherState,W3C.Soap.Fault> responsePort) : 
                base(body, responsePort)
        {
        }
    }
    /// <summary>
    /// Replace
    /// </summary>
    [XmlTypeAttribute(IncludeInSchema=false)]
    public class Replace : Replace<FileWatcherState, PortSet<DefaultReplaceResponseType, Fault>>
    {
        public Replace()
        {
        }
        public Replace(FileWatcherState body) : 
                base(body)
        {
        }
        public Replace(FileWatcherState body, Microsoft.Ccr.Core.PortSet<Microsoft.Dss.ServiceModel.Dssp.DefaultReplaceResponseType,W3C.Soap.Fault> responsePort) : 
                base(body, responsePort)
        {
        }
    }
    /// <summary>
    /// Watch Files
    /// </summary>
    [XmlTypeAttribute(IncludeInSchema=false)]
    public class WatchFiles : Update<WatchFilesRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public WatchFiles()
        {
        }
        public WatchFiles(WatchFilesRequest body) : 
                base(body)
        {
        }
        public WatchFiles(WatchFilesRequest body, Microsoft.Ccr.Core.PortSet<Microsoft.Dss.ServiceModel.Dssp.DefaultUpdateResponseType,W3C.Soap.Fault> responsePort) : 
                base(body, responsePort)
        {
        }
    }
    /// <summary>
    /// Subscribe
    /// </summary>
    [XmlTypeAttribute(IncludeInSchema=false)]
    public class Subscribe : Subscribe<SubscribeRequestType, PortSet<SubscribeResponseType, Fault>>
    {
        public Subscribe()
        {
        }
        public Subscribe(Microsoft.Dss.ServiceModel.Dssp.SubscribeRequestType body) : 
                base(body)
        {
        }
        public Subscribe(Microsoft.Dss.ServiceModel.Dssp.SubscribeRequestType body, Microsoft.Ccr.Core.PortSet<Microsoft.Dss.ServiceModel.Dssp.SubscribeResponseType,W3C.Soap.Fault> responsePort) : 
                base(body, responsePort)
        {
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Israel Israel


  • Nov 2010: Code Project Contests - Windows Azure Apps - Winner
  • Feb 2011: Code Project Contests - Windows Azure Apps - Grand Prize Winner



Comments and Discussions