Javascript 将文本文件的内容发送到WCF Web服务
我正在从事一个项目,其中涉及调用WCF web服务将给定文件的内容上载到WCF web服务。客户端是一个使用Titanium Studio编写的iPad应用程序。但是我可以发送小于8KB的文件。但是我发送的文件可能比8KB大。当我发送大于8KB的文件时,web服务返回以下错误消息 服务器在处理请求时遇到错误 下面给出的是调用 数据使用JSON格式发送到web服务Javascript 将文本文件的内容发送到WCF Web服务,javascript,wcf,web-services,titanium,appcelerator,Javascript,Wcf,Web Services,Titanium,Appcelerator,我正在从事一个项目,其中涉及调用WCF web服务将给定文件的内容上载到WCF web服务。客户端是一个使用Titanium Studio编写的iPad应用程序。但是我可以发送小于8KB的文件。但是我发送的文件可能比8KB大。当我发送大于8KB的文件时,web服务返回以下错误消息 服务器在处理请求时遇到错误 下面给出的是调用 数据使用JSON格式发送到web服务 var readFile = Titanium.Filesystem.getFile(Titanium.Filesys
var readFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'log.txt');
modifiedDate = readFile.modificationTimestamp();
var payload ={dateTime: modifiedDate, fileName:'log.txt' , text:readFile};
var xhrLog = Titanium.Network.createHTTPClient();
var serviceUrl = 'http://192.168.134.134/webservice/viewerservice.svc/submitLogData/';
xhrLog.open("POST", serviceUrl);
xhrLog.setRequestHeader("Content-Type", "");
xhrLog.setRequestHeader("Authentication-Token", "605b32dd");
xhrLog.onload = function() {
Ti.API.info(this.responseText);
},
xhrLog.onerror = function() {
}
xhrLog.send(JSON.stringify(sendData));
以下是WCF web服务中用于检索数据的服务契约和数据契约
[OperationContract]
[WebInvoke(
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/SubmitLogData/")]
bool SubmitLogData(List<LogData> log);
您可能需要增加所有配额——如果您能够启用WCF服务器端跟踪并看到确切的错误消息,这将非常有帮助 更新:wsHttpBinding的示例:
<binding name="wsHttp" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" >
</binding>
<binding name="wsHttp" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" >
</binding>