[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
Wed Jul 14 03:34:32 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=619542

http://bugzilla.novell.com/show_bug.cgi?id=619542#c5


--- Comment #5 from Atsushi Enomoto <aenomoto at novell.com> 2010-07-14 07:34:31 UTC ---
OK, I could get a useful repro. In this code
WebHttpBehavior.GetReplyDispatchFormatter() and
WebMessageEncodingBindingElement do the trick. The former gives
WebBodyFormatMessageProperty with WebContentFormat.Raw for Format property, and
the latter then outputs the result Stream as is.

--------
using System;
using System.IO;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Text;
using System.Xml;

public class Tset
{
    public static void Main ()
    {
        var ms = new MemoryStream ();
        ms.Write (Encoding.UTF8.GetBytes ("TEST"), 0, 4);
        ms.Position = 0;
        var cd = ContractDescription.GetContract (typeof (ITestService));
        var od = cd.Operations [0];
        var se = new ServiceEndpoint (cd, new WebHttpBinding (), new
EndpointAddress ("http://localhost:8080/"));
        var formatter = new MyWebHttpBehavior ().GetRDF (od, se);
        var msg = formatter.SerializeReply (MessageVersion.None, null, ms);
        foreach (var p in msg.Properties)
            Console.WriteLine ("{0}: {1}", p.Key, p.Value);
        var wmebe = new WebMessageEncodingBindingElement ();
        var wme = wmebe.CreateMessageEncoderFactory ().Encoder;
        var ms2 = new MemoryStream ();
        wme.WriteMessage (msg, ms2);
        Console.WriteLine (Encoding.UTF8.GetString (ms2.ToArray ()));
    }
}

[ServiceContract]
public interface ITestService
{
    [OperationContract]
    Stream Receive (Stream input);
}

public class MyWebHttpBehavior : WebHttpBehavior
{
    public IDispatchMessageFormatter GetRDF (OperationDescription od,
ServiceEndpoint se)
    {
        return GetReplyDispatchFormatter (od, se);
    }
}

-- 
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