Question

Followin is my OperationContract

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "/send?canvasbyte={imgbyte}")]
string sendresponse(string imgbyte);

and Following is my OperationContract implementation and i'm returning an the same argument(string) here

public string sendresponse(string imgbyte)
{
            return imgbyte;
}

I'm Testing this service with a HTML5 client application, from its java script I'm sending a xmlHttpRequest as a get method The value passing in the url is the DataUrl of a Canvas Drawing.

var canvas = document.getElementById('canvasid');
console.log(canvas.toDataURL());
var url = "http://myserverurl.com/ServiceImpl.svc/send?canvasbyte=" +          canvas.toDataURL().toString();
var xmlHttp = new XMLHttpRequest();
xmlHttp.onload = function () {

    var xmldocument = xmlHttp.responseText;
    console.log(xmlHttp.responseText);

};
xmlHttp.open("GET", url, true);
xmlHttp.send();

This is my client code the canvas dataurl is a large text value. The Service recieve that and Returning the same thing But here i'm getting some alteration in the result. Why?? I think I'm Missing some "+" signs in the result..

Was it helpful?

Solution

Plus signs are interpretted as spaces by browsers.

Since you are using the GET method your request data is ending up in the querystring (probably better to use POST if you can).

As the data is in the querystring the server automatically changes + to space.

Here is a thread that may help more.

Plus sign in query string

OTHER TIPS

There are way too many problem with that code.

first of all default IIS configuration will not allow any urls longer than 2000 chars. second, get requires escaped value to be passed so, name=Files/John Doe becomes name=Files%2FJohn+Doe which is more than just + signs.

try POSTing your data to your method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top