I was having a problem sending video data to a WCF restful service using post, my contract looks like this
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat=WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "UploadMovie")]
string UploadMovie(Stream stream);
This works ok when I'm sending some text data but does not work when I attempt to send Video data, I have some exception catching in place but it seems like the request is not even being processed, since I get no response and no exceptions get logged... anyone have any input on this?
you can use the svclog app to determine exactly what is happening. You just have enable wcf logging
http://wcfsecurity.codeplex.com/Wiki/View.aspx?title=How%20to%20enable%20WCF%20message%20logging
If you are instantiating all wcf in code, you can just add an app.config with the correct information to your code directory and this will work. Just remember to take it out when you're done. Most likely you have some exception that the WCF framework is catching. That happened to me on a message that seemingly vanished into thin air.
Check out this post on streaming in Restful WCF. It's reverse of what you want to do, but using the AdapterStream class will probably help.
The problem was the buffer size, i ended up splitting the video up into chunks and sending it like that, thanks everyone for their input
Related
I am using Entity framework and wcf rest service for my project.
what i required is i want to change the xml structure which is generated like this
<ArrayOfBug>
<Bug>
<BugID>1</BugID>
<PageName>Home.aspx</PageName>
<BugDescription>Bug Testing</BugD`enter code here`escription>
<Priority>H</Priority>
</Bug>
</ArrayOfBug>
-------------
I need Attributes instead of element like this
<ArrayOfBug>
<Bug BugID="1" PageName="Home.aspx" BugDescription="Bug Testing" Priority="H" >
</Bug>
</ArrayOfBug>
what is the best way to do so?
My interface is like this
[OperationContract]
[WebGet(BodyStyle=WebMessageBodyStyle.Bare, UriTemplate = "/SelectAllBug", ResponseFormat = WebMessageFormat.Xml )]
List<Bug> SelectAllBug();
thanks in advance
Monish
There is no out-of-box way in WCF to do what you want.
You can extend WCF by creating a custom message formatter as shown in this good blog post. The down-side is that you'll need to invest some time in understanding how the WCF message processing pipeline works to potentially handle formatting both the request and response messages.
I'm trying to pull a large amount of data out of a WCF web service. The request is fairly small and the response message will be very big. Currently the web service is throwing SystemOutOfMemory exceptions due a limitation on IIS6 for the memory it can allocated (~1.4GB).
I have read in some blogs that implementing streaming will solve my problem.
Can anybody share their experiences with this topic? I'm most interested in any sample client-side & service-side code that can be shared or any recommendations/best practices. MemoryStream vs FileStream? Return type should be Stream, Message, Byte[]?
My operation looks like the following: (typically it will return a big number of elements in the response array, ~200K elements)
MediumSizeResponseClass[] GetData(SmallSizeRequestClass request)
If you want to stream back only the response, then use transferMode=streamedResponse in your binding configuration. This makes sure only the returned response will be streamed.
The return value of a streaming function must be a Stream. You can then read from that stream and do whatever you need to do with it (store it, analyse it, whatever).
So basically you'd have a service contract something like this:
[ServiceContract]
interface IYourService
{
[OperationContract]
Stream GetData(SmallSizeRequestClass request);
}
On the server, you basically just write to a stream, while on the client, you read from the stream.
Have you consulted the MSDN docs on WCF Streaming?
I have a WCF service defined, it accepts JSON and maps that JSON to an object at which point I can then begin debugging code.
Sometimes, the object fails to create. Most recently my service had a BodyStyle of Wrapped but should have been Bare. In this case I would have liked to watch the request come in and see what happens to it as it gets mapped from JSON to POCO and then onto the service so I can watch for errors.
I'd also like to see what happends with the response where I have also had issues in the past.
What is the best way of seeing what is going on in WCF when it is (kind of) out of my control? What kind of logging/tracing can I use and can I see errors/exceptions being thrown by WCF?
Thanks
Scott
I don't know much but svctraceviewer might help in case you haven't heard about it already.
Arnis gives a good suggestion. I'd also suggest using Fiddler to trace WCF traffic assuming you are using a HTTP end point. I've used fiddler to troubleshoot WCF issues so it might be helpful to you as well.
I've been looking for examples for how to write a WCF REST service that allows image data to be POSTed to. I may be missing something (I generally am), but does anyone know how to do it? Is it as simple as getting the HTTP request from inside your WCF REST service, and extracting the binary data? If so, is there an example as to how to do that? Would I be able to do that using WebOperationContext.IncomingRequest?
Or, is there a way to do something like this...
[ServiceContract]
public interface IImage
{
[OperationContract]
[WebInvoke(
Method = "POST",
UriTemplate = "/images")]
void StoreImage(byte[] imageData);
}
Any ideas?
This post is more or less the answer I was looking for.
I have a legacy service I'm looking to update to WCF and one of it's behaviours is to allow clients to POST a request that has something like:
MyService.asmx/ProcessDocument
With Post data looking like:
request=<big block of xml>
Now in the ASMX days this service accepted a single string parameter i.e:
public void ProcessDocument(string request) {
}
So far I have only gotten this to work in WCF by using a Stream as of the advice in this post here:
http://www.dennydotnet.com/post/2008/09/16/WCF-REST-and-POST-Lets-Dance!.aspx
A Stream will work, there are just more steps involved to make it work for something that seems to it should be supported out of the box.
I am pretty new to WCF - what am I missing?
OK, this sample got me to most of where I needed to go:
http://msdn.microsoft.com/en-us/library/bb943485.aspx
I now have it working as required.