[Mono-dev] WCF in Mono 2.6.7

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Sat Jan 15 03:11:26 EST 2011


Not sure where the actual error occurs without stack trace, but 2.6 is 
too old
for WCF to try anyways.
And Mtom is almost untested so it will cause any kind of problem (never
expected that there are actually people who use it).

Atsushi Eno

(2011/01/14 23:37), joelcaner wrote:
> I am having trouble getting WCF working on Mono in Suse Linux 11.3
> I have the client as follow:
> BasicHttpBinding binding = new BasicHttpBinding();
>              binding.Security.Mode = BasicHttpSecurityMode.None;
>              binding.TransferMode = TransferMode.Streamed;
>              binding.MessageEncoding = WSMessageEncoding.Mtom;
>              binding.MaxReceivedMessageSize = int.MaxValue;
>
>              EndpointAddress address = new
> EndpointAddress("http://localhost:5800/DataUploader");
>              ChannelFactory<IDataUploader>  channel = new
> ChannelFactory<IDataUploader>(binding, address);
>
>              IDataUploader uploader = channel.CreateChannel();
>
>              try
>              {
>
>
>                  uploader.Upload(File.Open(@"G:\anthem-1.5.2.zip",
> FileMode.Open, FileAccess.Read));
>                  Console.WriteLine("File uploaded to the server");
>                  Console.ReadLine();
>              }
>              catch (Exception ex)
>              {
>                  Console.Write(ex.Message);
>                  Console.ReadLine();
>              }
>              finally
>              {
>                  ((IClientChannel)uploader).Close();
>
>
>              }
>
> I have the following interface:
> [ServiceContract]
>      interface IDataUploader
>      {
>          [OperationContract]
>          void Upload(Stream data);
>      }
>
> Now the service is as follow on DataUploader.cs:
> class DataUploader : IDataUploader
>
>      {
>
>          #region IDataUploader Members
>
>          public void Upload(Stream data)
>
>          {
>
>              string xmlFile = @"c:\temp\uploadedfile" + ".zip";
>
>
>
>              using (FileStream fs = new FileStream(xmlFile, FileMode.Create))
>
>              {
>
>                  int bufferSize = 1 * 1024 * 1024; // 1MB buffer
>
>                  byte[] buffer = new byte[bufferSize];
>
>                  int bytes;
>
>
>
>                  while ((bytes = data.Read(buffer, 0, bufferSize))>  0)
>
>                  {
>
>                      fs.Write(buffer, 0, bytes);
>
>                      fs.Flush();
>
>                  }
>
>              }
>
>
>
>
>
>          }
>
>           #endregion
>
>
>
>
>
>      }
>
> Now on IDataUploader.cs:
> [ServiceContract]
>
>      interface IDataUploader
>
>      {
>
>          [OperationContract]
>
>          void Upload(Stream data);
>
>      }
>
> On the main.cs I have:
> public static void Main (string[] args)
>
> 		{
>
> 			ServiceHost host = new ServiceHost(typeof(DataUploader));
>
>
>
>              BasicHttpBinding binding = new BasicHttpBinding();
>
> 			binding.Security.Mode = BasicHttpSecurityMode.None;
>
>              binding.TransferMode = TransferMode.Streamed;
>
> 			binding.MessageEncoding = WSMessageEncoding.Mtom;
>
>              binding.MaxReceivedMessageSize = int.MaxValue;
>
>
>
>
>
>              host.AddServiceEndpoint(typeof(IDataUploader), binding, new
> Uri("http://localhost:5800/DataUploader"));
>
>
>
>              ServiceBehaviorAttribute attribute =
> (ServiceBehaviorAttribute)host.Description.Behaviors[typeof(ServiceBehaviorAttribute)];
>
>              attribute.ConcurrencyMode = ConcurrencyMode.Multiple;
>
>              attribute.InstanceContextMode = InstanceContextMode.Single;
>
> 			attribute.IncludeExceptionDetailInFaults = true;
>
>
>
>              ServiceThrottlingBehavior throttling = new
> ServiceThrottlingBehavior();
>
>              throttling.MaxConcurrentSessions = 24;
>
>              throttling.MaxConcurrentCalls = 24;
>
>
>
>              host.Description.Behaviors.Add(throttling);
>
>
>
>              host.Open();
>
>
>
>              Console.WriteLine("Service Hosted ...");
>
>              Console.ReadKey();
>
>              host.Close();
>
> 		}
> I have both client and service running on the same system. I get an error:
> Object reference not set to an instance of an object error. When I run a
> client on a windows system and the service on the linux system I get "bad
> request(400) error. Can someone help me understand what I am missing?



More information about the Mono-devel-list mailing list