From d39d2e68169fb8fa038ee6fa3c9be98039d35eab Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Wed, 17 Sep 2008 13:47:06 +0000 Subject: QPID-1281: Added wcf support + demos git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@696292 13f79535-47bb-0310-9956-ffa450edef68 --- dotnet/client-010/wcf/Properties/AssemblyInfo.cs | 36 ++++ dotnet/client-010/wcf/demo/ConfigDemo.suo | Bin 0 -> 23552 bytes dotnet/client-010/wcf/demo/Demo.suo | Bin 0 -> 33280 bytes .../wcf/demo/wcfBookingClient/Form1.Designer.cs | 164 +++++++++++++++ .../client-010/wcf/demo/wcfBookingClient/Form1.cs | 74 +++++++ .../wcf/demo/wcfBookingClient/Form1.resx | 123 ++++++++++++ .../wcf/demo/wcfBookingClient/Program.cs | 21 ++ .../wcfBookingClient/Properties/AssemblyInfo.cs | 36 ++++ .../Properties/Resources.Designer.cs | 71 +++++++ .../wcfBookingClient/Properties/Resources.resx | 117 +++++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../wcfBookingClient/Properties/Settings.settings | 7 + .../demo/wcfBookingClient/wcBookingClient.csproj | 103 ++++++++++ .../wcf/demo/wcfBookingServer/Booking.cs | 62 ++++++ .../wcf/demo/wcfBookingServer/IBooking.cs | 43 ++++ .../client-010/wcf/demo/wcfBookingServer/Order.cs | 45 +++++ .../wcf/demo/wcfBookingServer/Program.cs | 98 +++++++++ .../wcfBookingServer/Properties/AssemblyInfo.cs | 36 ++++ .../wcf/demo/wcfBookingServer/Receipt.cs | 46 +++++ .../demo/wcfBookingServer/wcfBookingServer.csproj | 77 ++++++++ .../client-010/wcf/demo/wcfHelloClient/App.config | 35 ++++ .../wcf/demo/wcfHelloClient/HelloClient.cs | 36 ++++ .../wcf/demo/wcfHelloClient/IHelloService.cs | 33 ++++ .../client-010/wcf/demo/wcfHelloClient/Program.cs | 48 +++++ .../demo/wcfHelloClient/Properties/AssemblyInfo.cs | 36 ++++ .../wcf/demo/wcfHelloClient/wcfHelloClient.csproj | 65 ++++++ .../client-010/wcf/demo/wcfHelloServer/App.config | 43 ++++ .../wcf/demo/wcfHelloServer/HelloService.cs | 34 ++++ .../wcf/demo/wcfHelloServer/IHelloService.cs | 32 +++ .../client-010/wcf/demo/wcfHelloServer/Program.cs | 47 +++++ .../demo/wcfHelloServer/Properties/AssemblyInfo.cs | 36 ++++ .../wcf/demo/wcfHelloServer/wcfHelloServer.csproj | 73 +++++++ dotnet/client-010/wcf/demo/wcfRPC/IUpperCase.cs | 31 +++ dotnet/client-010/wcf/demo/wcfRPC/Program.cs | 113 +++++++++++ .../wcf/demo/wcfRPC/Properties/AssemblyInfo.cs | 36 ++++ .../demo/wcfRPC/QpidBindingConfigurationElement.cs | 205 +++++++++++++++++++ dotnet/client-010/wcf/demo/wcfRPC/UpperCase.cs | 33 ++++ dotnet/client-010/wcf/demo/wcfRPC/wcfRPC.csproj | 73 +++++++ .../client-010/wcf/model/CommunicationOperation.cs | 31 +++ dotnet/client-010/wcf/model/QpidBinding.cs | 185 +++++++++++++++++ dotnet/client-010/wcf/model/QpidChannelBase.cs | 167 ++++++++++++++++ dotnet/client-010/wcf/model/QpidChannelFactory.cs | 74 +++++++ dotnet/client-010/wcf/model/QpidChannelListener.cs | 79 ++++++++ .../wcf/model/QpidChannelListenerBase.cs | 111 +++++++++++ dotnet/client-010/wcf/model/QpidInputChannel.cs | 219 +++++++++++++++++++++ .../client-010/wcf/model/QpidInputChannelBase.cs | 101 ++++++++++ dotnet/client-010/wcf/model/QpidOutputChannel.cs | 89 +++++++++ .../client-010/wcf/model/QpidOutputChannelBase.cs | 77 ++++++++ .../wcf/model/QpidTransportBindingElement.cs | 186 +++++++++++++++++ .../client-010/wcf/model/QpidTransportElement.cs | 183 +++++++++++++++++ dotnet/client-010/wcf/wcf.csproj | 69 +++++++ dotnet/client-010/wcf/wcf.sln | 50 +++++ dotnet/client-010/wcf/wcf.suo | Bin 0 -> 91648 bytes 53 files changed, 3819 insertions(+) create mode 100644 dotnet/client-010/wcf/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/wcf/demo/ConfigDemo.suo create mode 100644 dotnet/client-010/wcf/demo/Demo.suo create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Form1.Designer.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Form1.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Form1.resx create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Program.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.Designer.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.resx create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.Designer.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.settings create mode 100644 dotnet/client-010/wcf/demo/wcfBookingClient/wcBookingClient.csproj create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/Booking.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/IBooking.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/Order.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/Program.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/Receipt.cs create mode 100644 dotnet/client-010/wcf/demo/wcfBookingServer/wcfBookingServer.csproj create mode 100644 dotnet/client-010/wcf/demo/wcfHelloClient/App.config create mode 100644 dotnet/client-010/wcf/demo/wcfHelloClient/HelloClient.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloClient/IHelloService.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloClient/Program.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloClient/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloClient/wcfHelloClient.csproj create mode 100644 dotnet/client-010/wcf/demo/wcfHelloServer/App.config create mode 100644 dotnet/client-010/wcf/demo/wcfHelloServer/HelloService.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloServer/IHelloService.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloServer/Program.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloServer/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/wcf/demo/wcfHelloServer/wcfHelloServer.csproj create mode 100644 dotnet/client-010/wcf/demo/wcfRPC/IUpperCase.cs create mode 100644 dotnet/client-010/wcf/demo/wcfRPC/Program.cs create mode 100644 dotnet/client-010/wcf/demo/wcfRPC/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/wcf/demo/wcfRPC/QpidBindingConfigurationElement.cs create mode 100644 dotnet/client-010/wcf/demo/wcfRPC/UpperCase.cs create mode 100644 dotnet/client-010/wcf/demo/wcfRPC/wcfRPC.csproj create mode 100644 dotnet/client-010/wcf/model/CommunicationOperation.cs create mode 100644 dotnet/client-010/wcf/model/QpidBinding.cs create mode 100644 dotnet/client-010/wcf/model/QpidChannelBase.cs create mode 100644 dotnet/client-010/wcf/model/QpidChannelFactory.cs create mode 100644 dotnet/client-010/wcf/model/QpidChannelListener.cs create mode 100644 dotnet/client-010/wcf/model/QpidChannelListenerBase.cs create mode 100644 dotnet/client-010/wcf/model/QpidInputChannel.cs create mode 100644 dotnet/client-010/wcf/model/QpidInputChannelBase.cs create mode 100644 dotnet/client-010/wcf/model/QpidOutputChannel.cs create mode 100644 dotnet/client-010/wcf/model/QpidOutputChannelBase.cs create mode 100644 dotnet/client-010/wcf/model/QpidTransportBindingElement.cs create mode 100644 dotnet/client-010/wcf/model/QpidTransportElement.cs create mode 100644 dotnet/client-010/wcf/wcf.csproj create mode 100644 dotnet/client-010/wcf/wcf.sln create mode 100644 dotnet/client-010/wcf/wcf.suo diff --git a/dotnet/client-010/wcf/Properties/AssemblyInfo.cs b/dotnet/client-010/wcf/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..477c21fd40 --- /dev/null +++ b/dotnet/client-010/wcf/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Qpid WCF")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Qpid WCF")] +[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a39d56ec-7d81-48e1-9602-347a3ce6f638")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/wcf/demo/ConfigDemo.suo b/dotnet/client-010/wcf/demo/ConfigDemo.suo new file mode 100644 index 0000000000..baa935693b Binary files /dev/null and b/dotnet/client-010/wcf/demo/ConfigDemo.suo differ diff --git a/dotnet/client-010/wcf/demo/Demo.suo b/dotnet/client-010/wcf/demo/Demo.suo new file mode 100644 index 0000000000..ee4cb5d21e Binary files /dev/null and b/dotnet/client-010/wcf/demo/Demo.suo differ diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.Designer.cs b/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.Designer.cs new file mode 100644 index 0000000000..24ae32cf77 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.Designer.cs @@ -0,0 +1,164 @@ +namespace WindowsFormsBooking +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.button2 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + this.SuspendLayout(); + // + // comboBox1 + // + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Hotel", + "Taxi", + "Train", + "Cinema", + "Theater", + "Restaurant"}); + this.comboBox1.Location = new System.Drawing.Point(60, 20); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(76, 21); + this.comboBox1.TabIndex = 0; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(23, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(31, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Type"; + // + // numericUpDown1 + // + this.numericUpDown1.Increment = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDown1.Location = new System.Drawing.Point(60, 49); + this.numericUpDown1.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDown1.Minimum = new decimal(new int[] { + 30, + 0, + 0, + 0}); + this.numericUpDown1.Name = "numericUpDown1"; + this.numericUpDown1.Size = new System.Drawing.Size(76, 20); + this.numericUpDown1.TabIndex = 2; + this.numericUpDown1.Value = new decimal(new int[] { + 30, + 0, + 0, + 0}); + this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(23, 56); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(31, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Price"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(142, 20); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(40, 49); + this.button1.TabIndex = 4; + this.button1.Text = "Add"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // richTextBox1 + // + this.richTextBox1.ForeColor = System.Drawing.SystemColors.ControlText; + this.richTextBox1.Location = new System.Drawing.Point(27, 113); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(155, 83); + this.richTextBox1.TabIndex = 5; + this.richTextBox1.Text = ""; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(27, 81); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(155, 29); + this.button2.TabIndex = 6; + this.button2.Text = "Receipt"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(211, 211); + this.Controls.Add(this.button2); + this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.button1); + this.Controls.Add(this.label2); + this.Controls.Add(this.numericUpDown1); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBox1); + this.Name = "Form1"; + this.Text = "Booking Client"; + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown numericUpDown1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Button button2; + } +} + diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.cs b/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.cs new file mode 100644 index 0000000000..e3ce7e0a3f --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.cs @@ -0,0 +1,74 @@ +using System; +using System.ServiceModel; +using System.Windows.Forms; +using org.apache.qpid.wcf.demo; +using org.apache.qpid.wcf.model; + +namespace WindowsFormsBooking +{ + public partial class Form1 : Form + { + private ChannelFactory _fac; + private readonly Order _order = new Order(); + private IBooking _calc; + + public Form1() + { + InitializeComponent(); + _calc = StartClient(new QpidBinding("192.168.1.14", 5673)); + _order.Type = "Default"; + _order.Price = 0; + } + + public IBooking StartClient(System.ServiceModel.Channels.Binding binding) + { + IBooking res = null; + try + { + Console.WriteLine(" Starting Client..."); + _fac = new ChannelFactory(binding, "soap.amqp:///Booking"); + _fac.Open(); + res = _fac.CreateChannel(); + Console.WriteLine("[DONE]"); + } + catch (Exception e) + { + Console.WriteLine(e); + } + return res; + } + + public void StopClient(IBooking client) + { + Console.WriteLine(" Stopping Client..."); + ((System.ServiceModel.Channels.IChannel)client).Close(); + _fac.Close(); + Console.WriteLine("[DONE]"); + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + _order.Type = ((ComboBox) sender).SelectedItem.ToString(); + } + + private void numericUpDown1_ValueChanged(object sender, EventArgs e) + { + _order.Price = (double) ((NumericUpDown) sender).Value; + } + + private void button1_Click(object sender, EventArgs e) + { + _calc.Add(_order); + } + + private void button2_Click(object sender, EventArgs e) + { + Receipt r = _calc.Checkout(); + richTextBox1.Text = r.Summary + "\n" + "Total Price = " + r.Price; + // reset + _calc = StartClient(new QpidBinding("192.168.1.14", 5673)); + } + + + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.resx b/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.resx new file mode 100644 index 0000000000..925d12594b --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Program.cs b/dotnet/client-010/wcf/demo/wcfBookingClient/Program.cs new file mode 100644 index 0000000000..25e2cd2624 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace WindowsFormsBooking +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/AssemblyInfo.cs b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..5c84747dec --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Booking Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Booking Client")] +[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fc8b1e0e-1ca9-46fe-9aae-b1ed046716b8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.Designer.cs b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..ef98621391 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsBooking.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsBooking.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.resx b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.resx new file mode 100644 index 0000000000..ffecec851a --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.Designer.cs b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..028322e275 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsBooking.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.settings b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.settings new file mode 100644 index 0000000000..abf36c5d3d --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dotnet/client-010/wcf/demo/wcfBookingClient/wcBookingClient.csproj b/dotnet/client-010/wcf/demo/wcfBookingClient/wcBookingClient.csproj new file mode 100644 index 0000000000..62144a218c --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingClient/wcBookingClient.csproj @@ -0,0 +1,103 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {4086B3FE-F745-4DCC-952A-682CAE01F4C9} + WinExe + Properties + WindowsFormsBooking + Booking Client + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.0 + + + 3.5 + + + 3.5 + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + Designer + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD} + wcf + + + {B34E21C4-A742-4886-8569-1A89490E093E} + wcfBookingServer + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/Booking.cs b/dotnet/client-010/wcf/demo/wcfBookingServer/Booking.cs new file mode 100644 index 0000000000..8b5e9db760 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/Booking.cs @@ -0,0 +1,62 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.Collections.Generic; +using System.ServiceModel; + + +namespace org.apache.qpid.wcf.demo +{ + [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] + public class Booking : IBooking + { + private Guid _id; + private List _orders; + + public Booking() + { + _id = Guid.NewGuid(); + _orders = new List(); + } + + public void Add(Order order) + { + _orders.Add(order); + } + + public Receipt Checkout() + { + var r = new Receipt(); + foreach (Order order in _orders) + { + r.Price += order.Price; + r.Summary = r.Summary + " \n " + order.Type + " Price: " + order.Price; + } + return r; + } + + public Guid Id + { + get { return _id; } + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/IBooking.cs b/dotnet/client-010/wcf/demo/wcfBookingServer/IBooking.cs new file mode 100644 index 0000000000..80890617aa --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/IBooking.cs @@ -0,0 +1,43 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + [ServiceContract(SessionMode=SessionMode.Required)] + public interface IBooking + { + [OperationContract] + void Add(Order order); + + [OperationContract] + Receipt Checkout(); + + Guid Id + { + [OperationContract] + get; + } + } + +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/Order.cs b/dotnet/client-010/wcf/demo/wcfBookingServer/Order.cs new file mode 100644 index 0000000000..c6266366c3 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/Order.cs @@ -0,0 +1,45 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +using System.Runtime.Serialization; + +namespace org.apache.qpid.wcf.demo +{ + [DataContract] + public sealed class Order + { + private double _price; + private string _type; + + [DataMember] + public double Price + { + get { return _price; } + set { _price = value; } + } + + [DataMember] + public string Type + { + get { return _type; } + set { _type = value; } + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/Program.cs b/dotnet/client-010/wcf/demo/wcfBookingServer/Program.cs new file mode 100644 index 0000000000..26e22b5103 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/Program.cs @@ -0,0 +1,98 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.Threading; +using org.apache.qpid.wcf.model; + + +namespace org.apache.qpid.wcf.demo +{ + internal class Program + { + private ServiceHost _service; + private ChannelFactory fac; + + public void StartService(Binding binding) + { + try + { + Console.WriteLine(" Binding Service..."); + _service = new ServiceHost(typeof(Booking), new Uri("soap.amqp:///")); + _service.AddServiceEndpoint(typeof(IBooking), binding, "Booking"); + _service.Open(); + Thread.Sleep(500); + Console.WriteLine("[DONE]"); + } + catch (Exception e) + { + Console.WriteLine(e); + } + } + + public void StopService() + { + Console.WriteLine(" Stopping Service..."); + _service.Close(); + Console.WriteLine("[DONE]"); + } + + public IBooking StartClient(Binding binding) + { + IBooking res = null; + try + { + Console.WriteLine(" Starting Client..."); + fac = new ChannelFactory(binding, "soap.amqp:///Booking"); + fac.Open(); + res = fac.CreateChannel(); + Console.WriteLine("[DONE]"); + } + catch (Exception e) + { + Console.WriteLine(e); + } + return res; + } + + public void StopClient(IBooking client) + { + Console.WriteLine(" Stopping Client..."); + ((IChannel)client).Close(); + fac.Close(); + Console.WriteLine("[DONE]"); + } + + private static void Main(string[] args) + { + var p = new Program(); + + Binding binding = new QpidBinding("192.168.1.14", 5673); + p.StartService(binding); + + Console.ReadLine(); + + p.StopService(); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/Properties/AssemblyInfo.cs b/dotnet/client-010/wcf/demo/wcfBookingServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..286d8ed354 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Booking Server")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Booking Server")] +[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("12ef158b-ac5f-43b3-99f6-e4a4c096d6f8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/Receipt.cs b/dotnet/client-010/wcf/demo/wcfBookingServer/Receipt.cs new file mode 100644 index 0000000000..869fdabe21 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/Receipt.cs @@ -0,0 +1,46 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System.Runtime.Serialization; + +namespace org.apache.qpid.wcf.demo +{ + [DataContract] + public sealed class Receipt + { + private double _price; + private string _summary; + + [DataMember] + public double Price + { + get { return _price; } + set { _price = value; } + } + + [DataMember] + public string Summary + { + get { return _summary; } + set { _summary = value; } + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfBookingServer/wcfBookingServer.csproj b/dotnet/client-010/wcf/demo/wcfBookingServer/wcfBookingServer.csproj new file mode 100644 index 0000000000..4b5cbdd9e8 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfBookingServer/wcfBookingServer.csproj @@ -0,0 +1,77 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {B34E21C4-A742-4886-8569-1A89490E093E} + Exe + Properties + wcfSession + Booking Server + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + + 3.0 + + + 3.0 + + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD} + wcf + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfHelloClient/App.config b/dotnet/client-010/wcf/demo/wcfHelloClient/App.config new file mode 100644 index 0000000000..3237fb8cc0 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloClient/App.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfHelloClient/HelloClient.cs b/dotnet/client-010/wcf/demo/wcfHelloClient/HelloClient.cs new file mode 100644 index 0000000000..0158a0b1ab --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloClient/HelloClient.cs @@ -0,0 +1,36 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + public class HelloClient : ClientBase, IHelloContract + { + public HelloClient(string configurationName) + : base(configurationName) { } + + public void Hello(string name) + { + Channel.Hello(name); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfHelloClient/IHelloService.cs b/dotnet/client-010/wcf/demo/wcfHelloClient/IHelloService.cs new file mode 100644 index 0000000000..5424a931a5 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloClient/IHelloService.cs @@ -0,0 +1,33 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + [ServiceContract] + public interface IHelloContract + { + [OperationContract(IsOneWay=true)] + void Hello(string name); + } + +} diff --git a/dotnet/client-010/wcf/demo/wcfHelloClient/Program.cs b/dotnet/client-010/wcf/demo/wcfHelloClient/Program.cs new file mode 100644 index 0000000000..2d6beebfef --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloClient/Program.cs @@ -0,0 +1,48 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; + +namespace org.apache.qpid.wcf.demo +{ + class Program + { + static void Main(string[] args) + { + Console.Title = "Hello Service Client"; + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine("Hello Service Client"); + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine(); + // create a client using the configuration file App.config + var client = new HelloClient("HelloService"); + Console.WriteLine("Client Saying Hello to Qpid"); + client.Hello("Qpid"); + Console.WriteLine("Client Saying Hello to AMQP"); + client.Hello("AMQP"); + // closing the client service + client.ChannelFactory.Close(); + Console.WriteLine(); + Console.Write("Press Enter to Exit..."); + Console.ReadLine(); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfHelloClient/Properties/AssemblyInfo.cs b/dotnet/client-010/wcf/demo/wcfHelloClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..59c03c642a --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Qpid WCF Hello Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Qpid WCF Hello Client")] +[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f7628695-280a-4689-ac6f-1186177f9a25")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/wcf/demo/wcfHelloClient/wcfHelloClient.csproj b/dotnet/client-010/wcf/demo/wcfHelloClient/wcfHelloClient.csproj new file mode 100644 index 0000000000..9640114524 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloClient/wcfHelloClient.csproj @@ -0,0 +1,65 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {A24E27DB-A38D-40C9-9879-8390B68C2F06} + Exe + Properties + wcfHelloClient + Qpid WCF Hello Client + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + 3.0 + + + + + + + + + + + + + + + + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD} + wcf + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfHelloServer/App.config b/dotnet/client-010/wcf/demo/wcfHelloServer/App.config new file mode 100644 index 0000000000..60e7e586be --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloServer/App.config @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfHelloServer/HelloService.cs b/dotnet/client-010/wcf/demo/wcfHelloServer/HelloService.cs new file mode 100644 index 0000000000..7ccec54568 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloServer/HelloService.cs @@ -0,0 +1,34 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; + +namespace org.apache.qpid.wcf.demo +{ + public class HelloService : IHelloContract + { + public void Hello(string name) + { + Console.WriteLine("Hello {0}!", name); + + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfHelloServer/IHelloService.cs b/dotnet/client-010/wcf/demo/wcfHelloServer/IHelloService.cs new file mode 100644 index 0000000000..73bad2ab04 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloServer/IHelloService.cs @@ -0,0 +1,32 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + [ServiceContract] + public interface IHelloContract + { + [OperationContract(IsOneWay=true)] + void Hello(string name); + } + +} diff --git a/dotnet/client-010/wcf/demo/wcfHelloServer/Program.cs b/dotnet/client-010/wcf/demo/wcfHelloServer/Program.cs new file mode 100644 index 0000000000..f010a8b48c --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloServer/Program.cs @@ -0,0 +1,47 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + class Program + { + static void Main(string[] args) + { + Console.Title = "Hello Service Server"; + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine("Hello Service Server"); + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine(); + + var host = new ServiceHost(typeof(HelloService)); + host.Open(); + + Console.WriteLine("Service Ready"); + Console.WriteLine("Press Enter to Exit..."); + Console.ReadLine(); + + host.Close(); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfHelloServer/Properties/AssemblyInfo.cs b/dotnet/client-010/wcf/demo/wcfHelloServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..229fd72767 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloServer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Qpid WCF Hello Server")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Qpid WCF Hello Server")] +[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("afa87185-f224-4948-904c-b4f3cd19dadb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/wcf/demo/wcfHelloServer/wcfHelloServer.csproj b/dotnet/client-010/wcf/demo/wcfHelloServer/wcfHelloServer.csproj new file mode 100644 index 0000000000..aa75159b54 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfHelloServer/wcfHelloServer.csproj @@ -0,0 +1,73 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {3EF848D7-5FAC-482C-922A-D4D45A4CCD2A} + Exe + Properties + wcfHelloServer + Qpid WCF Hello Server + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.0 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD} + wcf + + + + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/demo/wcfRPC/IUpperCase.cs b/dotnet/client-010/wcf/demo/wcfRPC/IUpperCase.cs new file mode 100644 index 0000000000..10312c6fe6 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfRPC/IUpperCase.cs @@ -0,0 +1,31 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + [ServiceContract] + public interface IUpperCase + { + [OperationContract] + string ToUpperCase(string message); + } +} diff --git a/dotnet/client-010/wcf/demo/wcfRPC/Program.cs b/dotnet/client-010/wcf/demo/wcfRPC/Program.cs new file mode 100644 index 0000000000..1c15813155 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfRPC/Program.cs @@ -0,0 +1,113 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.Threading; +using org.apache.qpid.wcf.model; + + +namespace org.apache.qpid.wcf.demo +{ + internal class Program + { + private ServiceHost _service; + private ChannelFactory fac; + + public void StartService(Binding binding) + { + try + { + Console.WriteLine(" Binding Service..."); + _service = new ServiceHost(typeof (UpperCase), new Uri("soap.amqp:///")); + _service.AddServiceEndpoint(typeof(IUpperCase), binding, "UpperCase"); + _service.Open(); + Thread.Sleep(500); + Console.WriteLine("[DONE]"); + } + catch (Exception e) + { + Console.WriteLine(e); + } + } + + public void StopService() + { + Console.WriteLine(" Stopping Service..."); + _service.Close(); + Console.WriteLine("[DONE]"); + } + + public IUpperCase StartClient(Binding binding) + { + IUpperCase res = null; + try + { + Console.WriteLine(" Starting Client..."); + fac = new ChannelFactory(binding, "soap.amqp:///UpperCase"); + fac.Open(); + res = fac.CreateChannel(); + Console.WriteLine("[DONE]"); + } + catch (Exception e) + { + Console.WriteLine(e); + } + return res; + } + + public void StopClient(IUpperCase client) + { + Console.WriteLine(" Stopping Client..."); + ((IChannel) client).Close(); + fac.Close(); + Console.WriteLine("[DONE]"); + } + + private static void Main(string[] args) + { + var p = new Program(); + + Binding binding = new QpidBinding("192.168.1.14", 5673); + p.StartService(binding); + + + IUpperCase calc = p.StartClient(new QpidBinding("192.168.1.14", 5673)); + + string[] messages = {"Twas brillig, and the slithy toves", + "Did gire and gymble in the wabe. ", + "All mimsy were the borogroves, ", + "And the mome raths outgrabe. "}; + foreach (string m in messages) + { + Console.Write(m + " --UperCase--> " ); + Console.Write(calc.ToUpperCase(m)); + Console.WriteLine(); + } + + Console.ReadLine(); + + p.StopClient(calc); + p.StopService(); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfRPC/Properties/AssemblyInfo.cs b/dotnet/client-010/wcf/demo/wcfRPC/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..7236da2e5b --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfRPC/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Qpid WCF UpperCase")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Qpid WCF UpperCase")] +[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("14ba3707-3fcc-4033-8bbc-0db65c5424f3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/wcf/demo/wcfRPC/QpidBindingConfigurationElement.cs b/dotnet/client-010/wcf/demo/wcfRPC/QpidBindingConfigurationElement.cs new file mode 100644 index 0000000000..470fe49734 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfRPC/QpidBindingConfigurationElement.cs @@ -0,0 +1,205 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.Reflection; +using System.ServiceModel.Channels; +using System.ServiceModel.Configuration; +using System.Configuration; + +namespace org.apache.qpid.wcf.model +{ + + /// + /// This configuration element should be imported into the client + /// and server configuration files to provide declarative configuration + /// of a AMQP bound service. + /// + public sealed class QpidBindingConfigurationElement : StandardBindingElement + { + /// + /// Creates a new instance of the QpidBindingConfigurationElement + /// Class initialized with values from the specified configuration. + /// + /// + public QpidBindingConfigurationElement(string configurationName) + : base(configurationName) + { + } + + /// + /// Creates a new instance of the RabbitMQBindingConfigurationElement Class. + /// + public QpidBindingConfigurationElement() + : this(null) + { + } + + + protected override void InitializeFrom(Binding binding) + { + base.InitializeFrom(binding); + QpidBinding qpidbinding = binding as QpidBinding; + if (qpidbinding != null) + { + Host = qpidbinding.Host; + OneWayOnly = qpidbinding.OneWayOnly; + TransactionFlowEnabled = qpidbinding.TransactionFlow; + VirtualHost = qpidbinding.VirtualHost; + PortNumber = qpidbinding.PortNumber; + UserName = qpidbinding.UserName; + Password = qpidbinding.Password; + } + } + + protected override void OnApplyConfiguration(Binding binding) + { + if (binding == null) + throw new ArgumentNullException("binding"); + + var qpidbinding = binding as QpidBinding; + if (qpidbinding == null) + { + throw new ArgumentException( + string.Format("Invalid type for binding. Expected {0}, Passed: {1}", + typeof(QpidBinding).AssemblyQualifiedName, + binding.GetType().AssemblyQualifiedName)); + } + + qpidbinding.Host = Host; + qpidbinding.OneWayOnly = OneWayOnly; + qpidbinding.TransactionFlow = TransactionFlowEnabled; + qpidbinding.Password = Password; + qpidbinding.UserName = UserName; + qpidbinding.VirtualHost = VirtualHost; + qpidbinding.PortNumber = PortNumber; + } + + + /// + /// Specifies the host that the binding should connect to. + /// + [ConfigurationProperty("host", DefaultValue = "localhost")] + public string Host + { + get { return ((string) base["host"]); } + set { base["host"] = value; } + } + + /// + /// Specifies the broker port number that the binding should connect to. + /// + [ConfigurationProperty("port", DefaultValue = "5672")] + public int PortNumber + { + get { return (Convert.ToInt16(base["port"])); } + set { base["port"] = value; } + } + + + /// + /// Specifies whether or not the CompositeDuplex and ReliableSession + /// binding elements are added to the channel stack. + /// + [ConfigurationProperty("oneWay", DefaultValue = false)] + public bool OneWayOnly + { + get { return ((bool)base["oneWay"]); } + set { base["oneWay"] = value; } + } + + /// + /// Password to use when authenticating with the broker + /// + [ConfigurationProperty("password", DefaultValue = "guest")] + public string Password + { + get { return ((string)base["password"]); } + set { base["password"] = value; } + } + + /// + /// Specifies whether or not WS-AtomicTransactions are supported by the binding + /// + [ConfigurationProperty("transactionFlow", DefaultValue = false)] + public bool TransactionFlowEnabled + { + get { return ((bool)base["transactionFlow"]); } + set { base["transactionFlow"] = value; } + } + + /// + /// The username to use when authenticating with the broker + /// + [ConfigurationProperty("username", DefaultValue = "guest")] + public string UserName + { + get { return ((string)base["username"]); } + set { base["username"] = value; } + } + + + + + /// + /// The virtual host to access. + /// + [ConfigurationProperty("virtualHost", DefaultValue = "test")] + public string VirtualHost + { + get { return ((string)base["virtualHost"]); } + set { base["virtualHost"] = value; } + } + + ///The security realm to use when calling IModel.AccessRequest + [ConfigurationProperty("realm", DefaultValue = "plain")] + public string Realm + { + get { return ((string)base["realm"]); } + set { base["realm"] = value; } + } + + protected override Type BindingElementType + { + get { return typeof(QpidBinding); } + } + + protected override ConfigurationPropertyCollection Properties + { + get + { + ConfigurationPropertyCollection configProperties = base.Properties; + foreach (PropertyInfo prop in this.GetType().GetProperties(BindingFlags.DeclaredOnly + | BindingFlags.Public + | BindingFlags.Instance)) + { + foreach (ConfigurationPropertyAttribute attr in prop.GetCustomAttributes(typeof(ConfigurationPropertyAttribute), false)) + { + configProperties.Add( + new ConfigurationProperty(attr.Name, prop.PropertyType, attr.DefaultValue)); + } + } + + return configProperties; + } + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfRPC/UpperCase.cs b/dotnet/client-010/wcf/demo/wcfRPC/UpperCase.cs new file mode 100644 index 0000000000..955b6132e5 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfRPC/UpperCase.cs @@ -0,0 +1,33 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +using System.ServiceModel; + +namespace org.apache.qpid.wcf.demo +{ + [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] + public sealed class UpperCase : IUpperCase + { + public string ToUpperCase(string message) + { + return message.ToUpper(); + } + } +} diff --git a/dotnet/client-010/wcf/demo/wcfRPC/wcfRPC.csproj b/dotnet/client-010/wcf/demo/wcfRPC/wcfRPC.csproj new file mode 100644 index 0000000000..36d8d62e88 --- /dev/null +++ b/dotnet/client-010/wcf/demo/wcfRPC/wcfRPC.csproj @@ -0,0 +1,73 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {C988F456-1025-486F-9BCD-49C0F83B91DB} + Exe + Properties + wcfRPC + Qpid WCF UpperCase + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + 3.5 + + + + 3.0 + + + + 3.5 + + + 3.5 + + + + + + + + + + + + + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD} + wcf + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/model/CommunicationOperation.cs b/dotnet/client-010/wcf/model/CommunicationOperation.cs new file mode 100644 index 0000000000..d32f3b3f40 --- /dev/null +++ b/dotnet/client-010/wcf/model/CommunicationOperation.cs @@ -0,0 +1,31 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel.Channels; + +namespace org.apache.qpid.wcf.model +{ + internal delegate void CommunicationOperation(TimeSpan timeout); + internal delegate TResult CommunicationOperation(TimeSpan timeout); + internal delegate TResult CommunicationOperation(TimeSpan timeout, out TArg arg0); + internal delegate void SendOperation(Message message, TimeSpan timeout); +} diff --git a/dotnet/client-010/wcf/model/QpidBinding.cs b/dotnet/client-010/wcf/model/QpidBinding.cs new file mode 100644 index 0000000000..73b7b92845 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidBinding.cs @@ -0,0 +1,185 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System.Configuration; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace org.apache.qpid.wcf.model +{ + public sealed class QpidBinding : Binding + { + private string _host; + private int _port; + private string _username; + private string _password; + private string _virtuaHost; + private readonly CompositeDuplexBindingElement _compositeDuplex; + private readonly MessageEncodingBindingElement _encoding; + private bool _oneWayOnly; + private readonly ReliableSessionBindingElement _session; + private readonly TransactionFlowBindingElement _transactionFlow; + private bool _transactionsEnabled; + private readonly QpidTransportBindingElement _transport; + + + + public QpidBinding() : this("localhost", 5672, "guest", "guest", "test") + { + } + + + public QpidBinding(string host, int port ) : this (host, port, "guest", "guest", "test") + { + } + + public QpidBinding(string host, int port, string username, string password, string virtualhost) + { + Host = host; + PortNumber = port; + UserName = username; + Password = password; + VirtualHost = virtualhost; + _transport = new QpidTransportBindingElement(); + _transport.Host = host; + _transport.PortNumber = port; + _transport.Password = password; + _transport.UserName = username; + _transport.VirtualHost = virtualhost; + _encoding = new TextMessageEncodingBindingElement(); + _session = new ReliableSessionBindingElement(); + _compositeDuplex = new CompositeDuplexBindingElement(); + _transactionFlow = new TransactionFlowBindingElement(); + } + + public override BindingElementCollection CreateBindingElements() + { + var elements = new BindingElementCollection(); + + if (_transactionsEnabled) + { + elements.Add(_transactionFlow); + } + if (!OneWayOnly) + { + elements.Add(_session); + elements.Add(_compositeDuplex); + } + elements.Add(_encoding); + elements.Add(_transport); + + return elements; + } + + + + /// + /// Gets the scheme used by the binding, soap.amqp + /// + public override string Scheme + { + get { return "soap.amqp"; } + } + + /// + /// Specifies the broker host + /// + [ConfigurationProperty("host")] + public string Host + { + get { return _host; } + set { _host = value; } + } + + /// + /// Specifies the broker port + /// + public int PortNumber + { + get { return _port; } + set { _port = value; } + } + + /// + /// Specifies the username + /// + public string UserName + { + get { return _username; } + set { _username = value; } + } + + /// + /// Specifies the password + /// + public string Password + { + get { return _password; } + set { _password = value; } + } + + /// + /// Specifies the virtualhost + /// + public string VirtualHost + { + get { return _virtuaHost; } + set { _virtuaHost = value; } + } + + + /// + /// Gets the AMQP _transport binding element + /// + public QpidTransportBindingElement Transport + { + get { return _transport; } + } + + /// + /// Gets the reliable _session parameters for this binding instance + /// + public ReliableSession ReliableSession + { + get { return new ReliableSession(_session); } + } + + /// + /// Determines whether or not the TransactionFlowBindingElement will + /// be added to the channel stack + /// + public bool TransactionFlow + { + get { return _transactionsEnabled; } + set { _transactionsEnabled = value; } + } + + /// + /// Specifies whether or not the CompositeDuplex and ReliableSession + /// binding elements are added to the channel stack. + /// + public bool OneWayOnly + { + get { return _oneWayOnly; } + set { _oneWayOnly = value; } + } + } +} \ No newline at end of file diff --git a/dotnet/client-010/wcf/model/QpidChannelBase.cs b/dotnet/client-010/wcf/model/QpidChannelBase.cs new file mode 100644 index 0000000000..25789a7955 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidChannelBase.cs @@ -0,0 +1,167 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace org.apache.qpid.wcf.model +{ + internal abstract class QpidChannelBase : IChannel + { + private readonly CommunicationOperation _closeMethod; + private readonly BindingContext _context; + private readonly CommunicationOperation _openMethod; + private CommunicationState _state; + + private QpidChannelBase() + { + _state = CommunicationState.Created; + _closeMethod = Close; + _openMethod = Open; + } + + protected QpidChannelBase(BindingContext context) + : this() + { + _context = context; + } + + public abstract void Close(TimeSpan timeout); + + public abstract void Open(TimeSpan timeout); + + public virtual void Abort() + { + Close(); + } + + public virtual void Close() + { + Close(_context.Binding.CloseTimeout); + } + + public virtual T GetProperty() where T : class + { + return default(T); + } + + public virtual void Open() + { + Open(_context.Binding.OpenTimeout); + } + + #region Async Methods + + public virtual IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state) + { + return _closeMethod.BeginInvoke(timeout, callback, state); + } + + public virtual IAsyncResult BeginClose(AsyncCallback callback, object state) + { + return _closeMethod.BeginInvoke(_context.Binding.CloseTimeout, callback, state); + } + + public virtual IAsyncResult BeginOpen(TimeSpan timeout, AsyncCallback callback, object state) + { + return _openMethod.BeginInvoke(timeout, callback, state); + } + + public virtual IAsyncResult BeginOpen(AsyncCallback callback, object state) + { + return _openMethod.BeginInvoke(_context.Binding.OpenTimeout, callback, state); + } + + public virtual void EndClose(IAsyncResult result) + { + _closeMethod.EndInvoke(result); + } + + public virtual void EndOpen(IAsyncResult result) + { + _openMethod.EndInvoke(result); + } + + #endregion + + #region Event Raising Methods + + protected void OnOpening() + { + _state = CommunicationState.Opening; + if (Opening != null) + Opening(this, null); + } + + protected void OnOpened() + { + _state = CommunicationState.Opened; + if (Opened != null) + Opened(this, null); + } + + protected void OnClosing() + { + _state = CommunicationState.Closing; + if (Closing != null) + Closing(this, null); + } + + protected void OnClosed() + { + _state = CommunicationState.Closed; + if (Closed != null) + Closed(this, null); + } + + protected void OnFaulted() + { + _state = CommunicationState.Faulted; + if (Faulted != null) + Faulted(this, null); + } + + #endregion + + + public CommunicationState State + { + get { return _state; } + } + + protected BindingContext Context + { + get { return _context; } + } + + + public event EventHandler Closed; + + public event EventHandler Closing; + + public event EventHandler Faulted; + + public event EventHandler Opened; + + public event EventHandler Opening; + } +} diff --git a/dotnet/client-010/wcf/model/QpidChannelFactory.cs b/dotnet/client-010/wcf/model/QpidChannelFactory.cs new file mode 100644 index 0000000000..fd26cbed99 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidChannelFactory.cs @@ -0,0 +1,74 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; +using org.apache.qpid.client; + +namespace org.apache.qpid.wcf.model +{ + public class QpidChannelFactory : ChannelFactoryBase + { + private readonly BindingContext _context; + private readonly CommunicationOperation _openMethod; + private readonly QpidTransportBindingElement _bindingElement; + private ClientSession _session; + + public QpidChannelFactory(BindingContext context) + { + _context = context; + _openMethod = Open; + _bindingElement = context.Binding.Elements.Find(); + } + + protected override IOutputChannel OnCreateChannel(EndpointAddress address, Uri via) + { + return new QpidOutputChannel(_context, _session, address); + } + + protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) + { + return _openMethod.BeginInvoke(timeout, callback, state); + } + + protected override void OnEndOpen(IAsyncResult result) + { + _openMethod.EndInvoke(result); + } + + protected override void OnOpen(TimeSpan timeout) + { + _session = _bindingElement.Open(timeout.Milliseconds); + } + + protected override void OnClose(TimeSpan timeout) + { + _bindingElement.Close(); + } + + protected override void OnAbort() + { + base.OnAbort(); + OnClose(_context.Binding.CloseTimeout); + } + } +} diff --git a/dotnet/client-010/wcf/model/QpidChannelListener.cs b/dotnet/client-010/wcf/model/QpidChannelListener.cs new file mode 100644 index 0000000000..ea795775b4 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidChannelListener.cs @@ -0,0 +1,79 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; +using org.apache.qpid.client; + +namespace org.apache.qpid.wcf.model +{ + public sealed class QpidChannelListener : QpidChannelListenerBase + { + + private IInputChannel _channel; + private ClientSession _session; + + public QpidChannelListener(BindingContext context) + : base(context) + { + _channel = null; + _session = null; + } + + protected override IInputChannel OnAcceptChannel(TimeSpan timeout) + { + // Since only one connection to a broker is required (even for communication + // with multiple exchanges + if (_channel != null) + return null; + + _channel = new QpidInputChannel(Context, _session, new EndpointAddress(Uri.ToString())); + _channel.Closed += ListenChannelClosed; + return _channel; + } + + protected override bool OnWaitForChannel(TimeSpan timeout) + { + return false; + } + + protected override void OnOpen(TimeSpan timeout) + { + _session = _bindingElement.Open(timeout.Milliseconds); + } + + protected override void OnClose(TimeSpan timeout) + { + if (_channel != null) + { + _channel.Close(); + _channel = null; + } + _bindingElement.Close(); + } + + private void ListenChannelClosed(object sender, EventArgs args) + { + Close(); + } +} +} diff --git a/dotnet/client-010/wcf/model/QpidChannelListenerBase.cs b/dotnet/client-010/wcf/model/QpidChannelListenerBase.cs new file mode 100644 index 0000000000..f2bba9316a --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidChannelListenerBase.cs @@ -0,0 +1,111 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; + +namespace org.apache.qpid.wcf.model +{ + public abstract class QpidChannelListenerBase : ChannelListenerBase where TChannel: class, IChannel + { + private readonly Uri _listenUri; + private readonly BindingContext _context; + protected QpidTransportBindingElement _bindingElement; + private readonly CommunicationOperation _closeMethod; + private readonly CommunicationOperation _openMethod; + private readonly CommunicationOperation _acceptChannelMethod; + private readonly CommunicationOperation _waitForChannelMethod; + + protected QpidChannelListenerBase(BindingContext context) + { + _context = context; + _bindingElement = context.Binding.Elements.Find(); + _closeMethod = OnClose; + _openMethod = OnOpen; + _waitForChannelMethod = OnWaitForChannel; + _acceptChannelMethod = OnAcceptChannel; + if (context.ListenUriMode == ListenUriMode.Explicit && context.ListenUriBaseAddress != null) + { + _listenUri = new Uri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress); + } + else + { + _listenUri = new Uri(new Uri("soap.amqp:///"), Guid.NewGuid().ToString()); + } + } + + protected override void OnAbort() + { + OnClose(_context.Binding.CloseTimeout); + } + + protected override IAsyncResult OnBeginAcceptChannel(TimeSpan timeout, AsyncCallback callback, object state) + { + return _acceptChannelMethod.BeginInvoke(timeout, callback, state); + } + + protected override TChannel OnEndAcceptChannel(IAsyncResult result) + { + return _acceptChannelMethod.EndInvoke(result); + } + + protected override IAsyncResult OnBeginWaitForChannel(TimeSpan timeout, AsyncCallback callback, object state) + { + return _waitForChannelMethod.BeginInvoke(timeout, callback, state); + } + + protected override bool OnEndWaitForChannel(IAsyncResult result) + { + return _waitForChannelMethod.EndInvoke(result); + } + + protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) + { + return _closeMethod.BeginInvoke(timeout, callback, state); + } + + protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) + { + return _openMethod.BeginInvoke(timeout, callback, state); + } + + protected override void OnEndClose(IAsyncResult result) + { + _closeMethod.EndInvoke(result); + } + + protected override void OnEndOpen(IAsyncResult result) + { + _openMethod.EndInvoke(result); + } + + public override Uri Uri + { + get { return _listenUri; } + } + + protected BindingContext Context + { + get { return _context; } + } + } +} diff --git a/dotnet/client-010/wcf/model/QpidInputChannel.cs b/dotnet/client-010/wcf/model/QpidInputChannel.cs new file mode 100644 index 0000000000..0bf50792cb --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidInputChannel.cs @@ -0,0 +1,219 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.Text; +using System.Threading; +using client.client; +using org.apache.qpid.client; +using org.apache.qpid.transport; +using org.apache.qpid.transport.util; + +namespace org.apache.qpid.wcf.model +{ + internal sealed class QpidInputChannel : QpidInputChannelBase + { + private static readonly Logger _log = Logger.get(typeof (QpidInputChannel)); + + private readonly QpidTransportBindingElement _bindingElement; + private readonly MessageEncoder _encoder; + private readonly ClientSession _session; + private readonly string _queueName; + private BlockingQueue _queue; + private bool _closed = false; + + public QpidInputChannel(BindingContext context, ClientSession session, EndpointAddress address) + : base(context, address) + { + _bindingElement = context.Binding.Elements.Find(); + var encoderElem = context.BindingParameters.Find(); + if (encoderElem != null) + { + _encoder = encoderElem.CreateMessageEncoderFactory().Encoder; + } + _session = session; + _queueName = address.Uri.ToString(); + _queue = new BlockingQueue(); + } + + + public override Message Receive(TimeSpan timeout) + { + _session.messageFlow("myDest", MessageCreditUnit.MESSAGE, 1); + _session.sync(); + MessageTransfer m = _queue.Dequeue(); + Message result = null; + if (m != null) + { + var reader = new BinaryReader(m.Body, Encoding.UTF8); + var body = new byte[m.Body.Length - m.Body.Position]; + reader.Read(body, 0, body.Length); + try + { + result = _encoder.ReadMessage(new MemoryStream(body), + (int) _bindingElement.MaxReceivedMessageSize); + } + catch(Exception e) + { + Console.WriteLine(e.StackTrace); + } + result.Headers.To = LocalAddress.Uri; + + var ack = new RangeSet(); + // ack this message + ack.add(m.Id); + _session.messageAccept(ack); + _session.sync(); + } + else + { + if(! _closed ) + { + return Receive(timeout); + } + } + return result; + } + + public override bool TryReceive(TimeSpan timeout, out Message message) + { + message = Receive(timeout); + return message != null; + } + + public override bool WaitForMessage(TimeSpan timeout) + { + throw new NotImplementedException(); + } + + public override void Close(TimeSpan timeout) + { + _closed = true; + _queue = null; + } + + public override void Open(TimeSpan timeout) + { + if (State != CommunicationState.Created && State != CommunicationState.Closed) + throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", State)); + + OnOpening(); + + var qr = (QueueQueryResult) _session.queueQuery(_queueName).Result; + if (qr.getQueue() == null) + { + // create the queue + _session.queueDeclare(_queueName, null, null); + } + // bind the queue + _session.exchangeBind(_queueName, "amq.direct", _queueName, null); + var myListener = new WCFListener(_queue); + _session.attachMessageListener(myListener, "myDest"); + _session.messageSubscribe(_queueName, "myDest", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED, + null, + 0, null); + // issue credits + _session.messageSetFlowMode("myDest", MessageFlowMode.WINDOW); + _session.messageFlow("myDest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES); + _session.sync(); + + OnOpened(); + } + } + + internal class WCFListener : MessageListener + { + private static readonly Logger _log = Logger.get(typeof (WCFListener)); + private readonly BlockingQueue _q; + + public WCFListener(BlockingQueue q) + { + _q = q; + } + + public void messageTransfer(MessageTransfer m) + { + _log.debug("message received by listener"); + _q.Enqueue(m); + } + } + + internal class BlockingQueue + { + private int _count; + private readonly Queue _queue = new Queue(); + + public MessageTransfer Dequeue(TimeSpan timeout) + { + lock (_queue) + { + DateTime start = DateTime.Now; + long elapsed = 0; + while (_count <= 0 && elapsed < timeout.Milliseconds) + { + Monitor.Wait(_queue, new TimeSpan(timeout.Milliseconds - elapsed)); + elapsed = DateTime.Now.Subtract(start).Milliseconds; + } + if (_count > 0) + { + _count--; + return _queue.Dequeue(); + } + return null; + } + } + + public MessageTransfer Dequeue() + { + lock (_queue) + { + while (_count <= 0) + { + Monitor.Wait(_queue); + } + if (_count > 0) + { + _count--; + return _queue.Dequeue(); + } + return null; + } + } + + public void Enqueue(MessageTransfer data) + { + if (data != null) + { + lock (_queue) + { + _queue.Enqueue(data); + _count++; + Monitor.Pulse(_queue); + } + } + } + } +} + diff --git a/dotnet/client-010/wcf/model/QpidInputChannelBase.cs b/dotnet/client-010/wcf/model/QpidInputChannelBase.cs new file mode 100644 index 0000000000..94aa459eab --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidInputChannelBase.cs @@ -0,0 +1,101 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace org.apache.qpid.wcf.model +{ + internal abstract class QpidInputChannelBase : QpidChannelBase, IInputChannel + { + private readonly EndpointAddress _localAddress; + private readonly CommunicationOperation _receiveMethod; + private readonly CommunicationOperation _tryReceiveMethod; + private readonly CommunicationOperation _waitForMessage; + + + protected QpidInputChannelBase(BindingContext context, EndpointAddress localAddress) + :base(context) + { + _localAddress = localAddress; + _receiveMethod = Receive; + _tryReceiveMethod = TryReceive; + _waitForMessage = WaitForMessage; + } + + + #region Async Methods + public virtual IAsyncResult BeginReceive(TimeSpan timeout, AsyncCallback callback, object state) + { + return _receiveMethod.BeginInvoke(timeout, callback, state); + } + + public virtual IAsyncResult BeginReceive(AsyncCallback callback, object state) + { + return _receiveMethod.BeginInvoke(Context.Binding.ReceiveTimeout, callback, state); + } + + public virtual IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state) + { + Message message; + return _tryReceiveMethod.BeginInvoke(timeout, out message, callback, state); + } + + public virtual IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state) + { + return _waitForMessage.BeginInvoke(timeout, callback, state); + } + + public virtual Message EndReceive(IAsyncResult result) + { + return _receiveMethod.EndInvoke(result); + } + + public virtual bool EndTryReceive(IAsyncResult result, out Message message) + { + return _tryReceiveMethod.EndInvoke(out message, result); + } + + public virtual bool EndWaitForMessage(IAsyncResult result) + { + return _waitForMessage.EndInvoke(result); + } + #endregion + + public abstract Message Receive(TimeSpan timeout); + + public abstract bool TryReceive(TimeSpan timeout, out Message message); + + public abstract bool WaitForMessage(TimeSpan timeout); + + public virtual Message Receive() + { + return Receive(Context.Binding.ReceiveTimeout); + } + + + public EndpointAddress LocalAddress + { + get { return _localAddress; } + } + } +} diff --git a/dotnet/client-010/wcf/model/QpidOutputChannel.cs b/dotnet/client-010/wcf/model/QpidOutputChannel.cs new file mode 100644 index 0000000000..b88b20fd19 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidOutputChannel.cs @@ -0,0 +1,89 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.IO; +using System.ServiceModel; +using System.ServiceModel.Channels; +using org.apache.qpid.client; +using org.apache.qpid.transport; +using org.apache.qpid.transport.util; + +namespace org.apache.qpid.wcf.model +{ + internal sealed class QpidOutputChannel : QpidOutputChannelBase + { + private readonly MessageEncoder _encoder; + private readonly ClientSession _session; + private readonly string _queueName; + + public QpidOutputChannel(BindingContext context, ClientSession session, EndpointAddress address) + : base(context, address) + { + var encoderElement = context.Binding.Elements.Find(); + if (encoderElement != null) + { + _encoder = encoderElement.CreateMessageEncoderFactory().Encoder; + } + _queueName = address.Uri.ToString(); + _session = session; + } + + public override void Send(Message message, TimeSpan timeout) + { + if (message.State != MessageState.Closed) + { + byte[] body; + using (var str = new MemoryStream()) + { + _encoder.WriteMessage(message, str); + body = str.ToArray(); + } + _session.messageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED, + new Header(new DeliveryProperties().setRoutingKey(_queueName), + new transport.MessageProperties().setMessageId(UUID.randomUUID())), + body); + } + } + + public override void Close(TimeSpan timeout) + { + if (State == CommunicationState.Closed || State == CommunicationState.Closing) + return; // Ignore the call, we're already closing. + OnClosing(); + OnClosed(); + } + + public override void Open(TimeSpan timeout) + { + if (State != CommunicationState.Created && State != CommunicationState.Closed) + throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", State)); + OnOpening(); + var qr = (QueueQueryResult) _session.queueQuery(_queueName).Result; + if (qr.getQueue() == null) + { + // create the queue + _session.queueDeclare(_queueName, null, null); + } + OnOpened(); + } + } +} diff --git a/dotnet/client-010/wcf/model/QpidOutputChannelBase.cs b/dotnet/client-010/wcf/model/QpidOutputChannelBase.cs new file mode 100644 index 0000000000..bcf6b4b6b8 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidOutputChannelBase.cs @@ -0,0 +1,77 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace org.apache.qpid.wcf.model +{ + internal abstract class QpidOutputChannelBase : QpidChannelBase, IOutputChannel + { + + private readonly SendOperation _sendMethod; + private readonly EndpointAddress _address; + + protected QpidOutputChannelBase(BindingContext context, EndpointAddress address) + : base(context) + { + _address = address; + _sendMethod = Send; + } + + #region Async Methods + + public IAsyncResult BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, object state) + { + return _sendMethod.BeginInvoke(message, timeout, callback, state); + } + + public IAsyncResult BeginSend(Message message, AsyncCallback callback, object state) + { + return _sendMethod.BeginInvoke(message, Context.Binding.SendTimeout, callback, state); + } + + public void EndSend(IAsyncResult result) + { + _sendMethod.EndInvoke(result); + } + + #endregion + + public abstract void Send(Message message, TimeSpan timeout); + + public virtual void Send(Message message) + { + Send(message, Context.Binding.SendTimeout); + } + + public EndpointAddress RemoteAddress + { + get { return _address; } + } + + public Uri Via + { + get { throw new NotImplementedException(); } + } + } +} diff --git a/dotnet/client-010/wcf/model/QpidTransportBindingElement.cs b/dotnet/client-010/wcf/model/QpidTransportBindingElement.cs new file mode 100644 index 0000000000..1c37de45d8 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidTransportBindingElement.cs @@ -0,0 +1,186 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.Configuration; +using System.ServiceModel.Channels; +using org.apache.qpid.client; + +namespace org.apache.qpid.wcf.model +{ + public sealed class QpidTransportBindingElement : TransportBindingElement + { + private Client _connection; + private string _host; + private int _port; + private string _username; + private string _password; + private string _virtuaHost; + + /// + /// Creates a new instance of the QpidTransportBindingElement Class + /// + public QpidTransportBindingElement() + { + _host = "localhost"; + _port = 5672; + _username = "guest"; + _password = "guest"; + _virtuaHost = "test"; + } + + private QpidTransportBindingElement(QpidTransportBindingElement other) + : this() + { + Connection = other.Connection; + Host = other.Host; + PortNumber = other.PortNumber; + UserName = other.UserName; + Password = other.Password; + } + + + public override IChannelFactory BuildChannelFactory(BindingContext context) + { + if (Host == null) + throw new InvalidOperationException("No broker was specified."); + return (IChannelFactory) new QpidChannelFactory(context); + } + + public override IChannelListener BuildChannelListener(BindingContext context) + { + if (Host == null) + throw new InvalidOperationException("No broker was specified."); + + return (IChannelListener) ((object) new QpidChannelListener(context)); + } + + public override bool CanBuildChannelFactory(BindingContext context) + { + return typeof (TChannel) == typeof (IOutputChannel); + } + + public override bool CanBuildChannelListener(BindingContext context) + { + return typeof (TChannel) == typeof (IInputChannel); + } + + public override BindingElement Clone() + { + return new QpidTransportBindingElement(this); + } + + public override T GetProperty(BindingContext context) + { + return context.GetInnerProperty(); + } + + /// + /// Gets the scheme used by the binding, this is 0.10 as default for now. + /// + public override string Scheme + { + get { return "soap.amqp"; } + } + + + /// + /// Specifies the broker host + /// + [ConfigurationProperty("host")] + public string Host + { + get { return _host; } + set { _host = value; } + } + + /// + /// Specifies the broker port + /// + public int PortNumber + { + get { return _port; } + set { _port = value; } + } + + /// + /// Specifies the username + /// + public string UserName + { + get { return _username; } + set { _username = value; } + } + + /// + /// Specifies the password + /// + public string Password + { + get { return _password; } + set { _password = value; } + } + + /// + /// Specifies the virtualhost + /// + public string VirtualHost + { + get { return _virtuaHost; } + set { _virtuaHost = value; } + } + + /// + /// Specifies the connection + /// + public Client Connection + { + get { return _connection; } + set { _connection = value; } + } + + + internal ClientSession Open(long timeout) + { + if (Connection == null) + { + Connection = new Client(); + } + Connection.connect(Host, PortNumber, VirtualHost, UserName, Password); + return Connection.createSession(timeout); + } + + internal void Close() + { + if (Connection != null) + { + try + { + Connection.close(); + } + catch (Exception e) + { + // todo log it + } + } + } + } +} diff --git a/dotnet/client-010/wcf/model/QpidTransportElement.cs b/dotnet/client-010/wcf/model/QpidTransportElement.cs new file mode 100644 index 0000000000..8a829e5b13 --- /dev/null +++ b/dotnet/client-010/wcf/model/QpidTransportElement.cs @@ -0,0 +1,183 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System; +using System.Configuration; +using System.Reflection; +using System.ServiceModel.Channels; +using System.ServiceModel.Configuration; + +namespace org.apache.qpid.wcf.model +{ + public sealed class QpidTransportElement : TransportElement + { + + public override void ApplyConfiguration(BindingElement bindingElement) + { + base.ApplyConfiguration(bindingElement); + if (bindingElement == null) + throw new ArgumentNullException("bindingElement"); + + var bindind = bindingElement as QpidTransportBindingElement; + if (bindind == null) + { + throw new ArgumentException( + string.Format("Invalid type for binding. Expected {0}, Passed: {1}", + typeof(QpidTransportBindingElement).AssemblyQualifiedName, + bindingElement.GetType().AssemblyQualifiedName)); + } + + bindind.Host = Host; + bindind.Password = Password; + bindind.UserName = UserName; + bindind.VirtualHost = VirtualHost; + bindind.PortNumber = PortNumber; + } + + public override void CopyFrom(ServiceModelExtensionElement from) + { + base.CopyFrom(from); + var element = from as QpidTransportElement; + if (element != null) + { + Host = element.Host; + PortNumber = element.PortNumber; + Password = element.Password; + UserName = element.UserName; + VirtualHost = element.VirtualHost; + } + } + + protected override BindingElement CreateBindingElement() + { + TransportBindingElement element = CreateDefaultBindingElement(); + ApplyConfiguration(element); + return element; + } + + protected override TransportBindingElement CreateDefaultBindingElement() + { + return new QpidTransportBindingElement(); + } + + protected override void InitializeFrom(BindingElement bindingElement) + { + base.InitializeFrom(bindingElement); + + if (bindingElement == null) + throw new ArgumentNullException("bindingElement"); + + var binding = bindingElement as QpidTransportBindingElement; + if (binding == null) + { + throw new ArgumentException( + string.Format("Invalid type for binding. Expected {0}, Passed: {1}", + typeof(QpidTransportBindingElement).AssemblyQualifiedName, + bindingElement.GetType().AssemblyQualifiedName)); + } + + Host = binding.Host; + PortNumber = binding.PortNumber; + Password = binding.Password; + UserName = binding.UserName; + VirtualHost = binding.VirtualHost; + } + + public override Type BindingElementType + { + get { return typeof(QpidTransportElement); } + } + + + + /// + /// Specifies the broker host name that the binding should connect to. + /// + [ConfigurationProperty("host", DefaultValue = "localhost")] + public string Host + { + get { return ((string) base["host"]); } + set { base["host"] = value; } + } + + /// + /// Specifies the broker port number that the binding should connect to. + /// + [ConfigurationProperty("port", DefaultValue = "5672")] + public int PortNumber + { + get { return (Convert.ToInt16(base["port"])); } + set { base["port"] = value; } + } + + /// + /// Password to use when authenticating with the broker + /// + [ConfigurationProperty("password", DefaultValue = "guest")] + public string Password + { + get { return ((string)base["password"]); } + set { base["password"] = value; } + } + + /// + /// The username to use when authenticating with the broker + /// + [ConfigurationProperty("username", DefaultValue = "guest")] + public string UserName + { + get { return ((string)base["username"]); } + set { base["username"] = value; } + } + + + /// + /// The virtual host to access. + /// + [ConfigurationProperty("virtualHost", DefaultValue = "test")] + public string VirtualHost + { + get { return ((string)base["virtualHost"]); } + set { base["virtualHost"] = value; } + } + + + protected override ConfigurationPropertyCollection Properties + { + get + { + ConfigurationPropertyCollection configProperties = base.Properties; + foreach (PropertyInfo prop in GetType().GetProperties(BindingFlags.DeclaredOnly + | BindingFlags.Public + | BindingFlags.Instance)) + { + foreach (ConfigurationPropertyAttribute attr in prop.GetCustomAttributes(typeof(ConfigurationPropertyAttribute), false)) + { + configProperties.Add( + new ConfigurationProperty(attr.Name, prop.PropertyType, attr.DefaultValue)); + } + } + + return configProperties; + } + } + } +} \ No newline at end of file diff --git a/dotnet/client-010/wcf/wcf.csproj b/dotnet/client-010/wcf/wcf.csproj new file mode 100644 index 0000000000..a294f52be2 --- /dev/null +++ b/dotnet/client-010/wcf/wcf.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD} + Library + Properties + WCF + qpidWCFModel + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\client\bin\Debug\Qpid Client.dll + + + + + 3.0 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dotnet/client-010/wcf/wcf.sln b/dotnet/client-010/wcf/wcf.sln new file mode 100644 index 0000000000..2d80874a23 --- /dev/null +++ b/dotnet/client-010/wcf/wcf.sln @@ -0,0 +1,50 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wcf", "wcf.csproj", "{F1D80D9D-FE22-4213-A760-BFFDE7D131DD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wcfHelloClient", "demo\wcfHelloClient\wcfHelloClient.csproj", "{A24E27DB-A38D-40C9-9879-8390B68C2F06}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wcfHelloServer", "demo\wcfHelloServer\wcfHelloServer.csproj", "{3EF848D7-5FAC-482C-922A-D4D45A4CCD2A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wcfRPC", "demo\wcfRPC\wcfRPC.csproj", "{C988F456-1025-486F-9BCD-49C0F83B91DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wcBookingClient", "demo\wcfBookingClient\wcBookingClient.csproj", "{4086B3FE-F745-4DCC-952A-682CAE01F4C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wcfBookingServer", "demo\wcfBookingServer\wcfBookingServer.csproj", "{B34E21C4-A742-4886-8569-1A89490E093E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1D80D9D-FE22-4213-A760-BFFDE7D131DD}.Release|Any CPU.Build.0 = Release|Any CPU + {A24E27DB-A38D-40C9-9879-8390B68C2F06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A24E27DB-A38D-40C9-9879-8390B68C2F06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A24E27DB-A38D-40C9-9879-8390B68C2F06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A24E27DB-A38D-40C9-9879-8390B68C2F06}.Release|Any CPU.Build.0 = Release|Any CPU + {3EF848D7-5FAC-482C-922A-D4D45A4CCD2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EF848D7-5FAC-482C-922A-D4D45A4CCD2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EF848D7-5FAC-482C-922A-D4D45A4CCD2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EF848D7-5FAC-482C-922A-D4D45A4CCD2A}.Release|Any CPU.Build.0 = Release|Any CPU + {C988F456-1025-486F-9BCD-49C0F83B91DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C988F456-1025-486F-9BCD-49C0F83B91DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C988F456-1025-486F-9BCD-49C0F83B91DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C988F456-1025-486F-9BCD-49C0F83B91DB}.Release|Any CPU.Build.0 = Release|Any CPU + {4086B3FE-F745-4DCC-952A-682CAE01F4C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4086B3FE-F745-4DCC-952A-682CAE01F4C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4086B3FE-F745-4DCC-952A-682CAE01F4C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4086B3FE-F745-4DCC-952A-682CAE01F4C9}.Release|Any CPU.Build.0 = Release|Any CPU + {B34E21C4-A742-4886-8569-1A89490E093E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B34E21C4-A742-4886-8569-1A89490E093E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B34E21C4-A742-4886-8569-1A89490E093E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B34E21C4-A742-4886-8569-1A89490E093E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/dotnet/client-010/wcf/wcf.suo b/dotnet/client-010/wcf/wcf.suo new file mode 100644 index 0000000000..8efca1318e Binary files /dev/null and b/dotnet/client-010/wcf/wcf.suo differ -- cgit v1.2.1