[Mono-bugs] [Bug 619542] webHttpBinging is generating wrong responses for methods that return a Stream
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Jul 13 15:27:22 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=619542
http://bugzilla.novell.com/show_bug.cgi?id=619542#c3
Clovis Ribeiro <clovis.ribeiro at myabcm.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clovis.ribeiro at myabcm.com
--- Comment #3 from Clovis Ribeiro <clovis.ribeiro at myabcm.com> 2010-07-13 19:27:21 UTC ---
To reproduce the problem, simply get the example below from MSDN and run both
in MS.NET and Mono. You will get different results.
How to: Create a Service That Returns Arbitrary Data Using The WCF Web HTTP
Programming Model
http://msdn.microsoft.com/en-us/library/cc681221.aspx
Alternatively, you can use my modified example below:
using System;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Description;
using System.IO;
namespace RawImageService
{
// Define the service contract
[ServiceContract]
public interface IImageServer
{
[WebGet]
[OperationContract]
Stream GetImage(int width, int height);
}
public class Service : IImageServer
{
public Stream GetImage(int width, int height)
{
string message = @"<?xml version=""1.0""
encoding=""utf-8""?><image_size><width>" + width.ToString() +
"</width><height>" + height.ToString() + "</height></image_size>";
if (WebOperationContext.Current != null)
WebOperationContext.Current.OutgoingResponse.ContentType =
"application/xml";
return new MemoryStream(Encoding.UTF8.GetBytes(message));
}
}
class Program
{
static void Main(string[] args)
{
string baseAddress = "http://" + Environment.MachineName +
":8000/Service";
ServiceHost host = new ServiceHost(typeof(Service), new
Uri(baseAddress));
host.AddServiceEndpoint(typeof(IImageServer), new WebHttpBinding(),
"").Behaviors.Add(new WebHttpBehavior());
host.Open();
Console.WriteLine("Service is running");
Console.Write("Press ENTER to close the host");
Console.ReadLine();
host.Close();
}
}
}
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list