I'm trying to upload a complex object to my WCF REST service. I'm doing this because it seems to be the easiest way to upload a Stream type object and other parameters to a endpoint at the same time.
Service:
[OperationContract]
[WebInvoke(Method = "POST",
    BodyStyle = WebMessageBodyStyle.Bare,
    RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json,
    UriTemplate = "Upload")]
public string upload(UploadObject uploadObject)
{
    return uploadObject.stream.ToString() + " " + uploadObject.guid; 
}
[DataContract]
public class UploadObject
{
    [DataMember]
    public Stream stream { get; set; }
    [DataMember]
    public string guid { get; set; }
}
JQuery
var guid = getParameterByName("guid");  //<--gets value from query string parameter
var file = $('#btnUpload').val();  //<--value from a file input box
var uploadObject = { stream: file, guid: guid };
$.ajax({
    type: "POST",            
    contentType: "application/json",
    url: "localhost/service/Upload", 
    data: uploadObject,
    datatype: "jsonp",
    processData : false,          
    success: function(data){
        alert(data);
    },
    error: function (xhr, status, error) {
        alert("fail");
    }
});
 
    