Hi Nadeem, Nice, thanks. Now I can see the problem. So far I have "implemented" OnWriteBodyContents() as to write dummy output, and the exact problem is gone (done in git master/mono-2-10 branches). There is another issue, looks like .NET WCF treats Stream parameter in special manner that we didn't have done yet. I'll investigate that issue too.
Atsushi Eno (2011/06/13 18:00), Nadeem Backus wrote: > Hi Atsushi, > > I found an example that exhibits the same problem in mono, its taken from: > http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx > > > > using System; > using System.Collections.Generic; > using System.IO; > using System.Linq; > using System.Net; > using System.ServiceModel; > using System.ServiceModel.Description; > using System.ServiceModel.Web; > using System.Text; > > namespace HttpPst > { > class Program > { > static void Main(string[] args) > { > > Test(); > > } > > public static void Test() > { > string baseAddress = "http://" + Environment.MachineName + > ":8000/Service"; > ServiceHost host = new ServiceHost(typeof(Service), new > Uri(baseAddress)); > host.AddServiceEndpoint(typeof(ITest), new > WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior()); > host.Open(); > Console.WriteLine("Host opened"); > > HttpWebRequest req = > (HttpWebRequest)HttpWebRequest.Create(baseAddress + > "/UploadFile/Test.txt"); > req.Method = "POST"; > req.ContentType = "text/plain"; > Stream reqStream = req.GetRequestStream(); > byte[] fileToSend = new byte[12345]; > for (int i = 0; i < fileToSend.Length; i++) > { > fileToSend[i] = (byte)('a' + (i % 26)); > } > reqStream.Write(fileToSend, 0, fileToSend.Length); > reqStream.Close(); > HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); > Console.WriteLine("HTTP/{0} {1} {2}", > resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription); > host.Close(); > } > > > > } > [ServiceContract] > public interface ITest > { > [OperationContract, WebInvoke(UriTemplate = > "UploadFile/{fileName}")] > void UploadFile(string fileName, Stream fileContents); > } > public class Service : ITest > { > public void UploadFile(string fileName, Stream fileContents) > { > byte[] buffer = new byte[10000]; > int bytesRead, totalBytesRead = 0; > do > { > bytesRead = fileContents.Read(buffer, 0, > buffer.Length); > totalBytesRead += bytesRead; > } while (bytesRead > 0); > Console.WriteLine("Uploaded file {0} with {1} bytes", > fileName, totalBytesRead); > } > } > > } > > Hope that helps > > Nadeem > > > On 13 June 2011 08:20, Atsushi Eno > <[email protected] > <mailto:[email protected]>> wrote: > > Hello, > > NotSupportedException is not NotImplementedException, so it is > likely intended to actually throw that error. It is still possible > that the WCF internal goes wrong path and reaches that > WriteMessage() part, but without actual code to examine I cannot > guess for sure. > > Atsushi Eno > > > (2011/06/13 7:40), Nadeem Backus wrote: > > Dear All, > > I have implemented a service operation which recieves a file > (multipart) via HTTP POST (as a stream) from an asyncronous > uploader (SWFupload), this has been done using the > webHttpBinding in system.servicemodel.web. The service is > running as a console host on an unbuntu 10.10 system with mono > 2.10, it fails in this environment yet works in .net 4.0 in > windows. I am getting the following exception when a post is > attempted: > > > Unhandled Exception: System.NotSupportedException: Operation > is not supported. > at > > System.ServiceModel.Dispatcher.WebMessageFormatter+RawMessage.OnWriteBodyContents > (System.Xml.XmlDictionaryWriter writer) [0x00000] in <filename > unknown>:0 > at System.ServiceModel.Channels.Message.WriteBodyContents > (System.Xml.XmlDictionaryWriter writer) [0x00000] in <filename > unknown>:0 > at System.ServiceModel.Channels.Message.OnCreateBufferedCopy > (Int32 maxBufferSize) [0x00000] in <filename unknown>:0 > at System.ServiceModel.Channels.Message.CreateBufferedCopy > (Int32 maxBufferSize) [0x00000] in <filename unknown>:0 > at System.ServiceModel.Logger.LogMessage > (MessageLogSourceKind sourceKind, > System.ServiceModel.Channels.Message& msg, Int32 > maxMessageSize) [0x00000] in <filename unknown>:0 > at > System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest > (TimeSpan timeout, > System.ServiceModel.Channels.RequestContext& context) > [0x00000] in <filename unknown>:0 > at > > System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__20 > (TimeSpan tout, System.ServiceModel.Channels.RequestContext& > ctx) [0x00000] in <filename unknown>:0 > > > The Operation Contract code is this: > > [OperationContract] > [WebInvoke(Method = "POST", BodyStyle = > WebMessageBodyStyle.Bare, UriTemplate = "/UploadImage")] > Stream UploadImage(Stream data); > > > Having looked though the library source code I see that > RawMessage has been implemented (I am unsure to what extend it > has been completed) , but OnWriteBodyContents is throwing a > not supported exception. How else can I get access to the > posted stream data? > > Any help will be greatly appreciated, thank you in advance :-) > > Nadeem > > > _______________________________________________ > Mono-list maillist - [email protected] > <mailto:[email protected]> > http://lists.ximian.com/mailman/listinfo/mono-list > > > _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
