【发布时间】:2013-10-19 10:20:07
【问题描述】:
Followin 是我的 OperationContract
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/send?canvasbyte={imgbyte}")]
string sendresponse(string imgbyte);
以下是我的 OperationContract 实现,我在这里返回相同的参数(字符串)
public string sendresponse(string imgbyte)
{
return imgbyte;
}
我正在使用 HTML5 客户端应用程序测试此服务,从它的 java 脚本中我发送一个 xmlHttpRequest 作为 get 方法 url 中传递的值是 Canvas 绘图的 DataUrl。
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();
这是我的客户端代码,canvas dataurl 是一个大文本值。 服务收到并返回相同的东西 但在这里我得到了一些改变的结果。为什么?? 我想我在结果中缺少一些“+”号..
【问题讨论】:
-
???请提供某种指示,说明 imgByte 到底是什么,以及它返回的内容是什么?
-
实际上我正在发送一个长字符串.. 在服务中,字符串中的所有 + 符号都替换为空格.. 这就是问题..
标签: c# javascript html wcf wcf-rest