WCF - how to receive plain string?
I have WCF service that I use with JSON. Now I need to receive plain message (headers + text) So, I expect to get string in fileContents but service fails because it's not JSON-encoded.
How do I code my method to allow for that?
This is my method
[WebInvoke(Method = "POST", UriTemplate = "/files/{fileName}")]
public void UploadFile(string fileName, strin开发者_StackOverflow中文版g fileContents)
{
}
And this is my service:
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class MobileService
{
If you want to receive "raw" data, you need to receive the input (fileContents) as a System.IO.Stream
. Take a look at the post at http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx for more information.
精彩评论