Tag: wcf rest

Jquery无法从WCF REST服务获得响应

我已经开发了WCFrest服务并将其部署在可以通过浏览器访问的链接上,因为它的操作是“GET”。 我想使用jQuery获取该数据。 我尽力让WCf使用jQuery获得响应但是徒劳无功。 我也试过$ .Ajax和’jsonp’没有运气。 谁能帮我? 该url是: http : //www.lonestarus.com/AndroidApp/AndroidLocation.svc/RestService/getLatestLocation 您可以通过在浏览器中粘贴url来检查该url响应。

使用jQuery上传文件插件时出错,附加到文件的不需要的字符串(WebKitFormBoundary)

我正在使用这个插件: http : //hayageek.com/docs/jquery-upload-file.php 我用它将文件发送到WCF Rest服务并将其保存在硬盘上。 上传工作正常,但问题是图像,exe等上传损坏。 如果我用文本编辑器打开上传的文件,我可以看到不需要的字符串 开始时: —— WebKitFormBoundaryPUTfurckDMbpBxiw Content-Disposition:form-data; NAME = “文件”; filename =“image.png”内容类型:image / png 最后: —— WebKitFormBoundaryPUTfurckDMbpBxiw– 我的服务代码: Function GetFile(str As Stream, fileName As String, accion As String) As String Try Dim absFileName As String = “C:\inetpub\wwwroot\UploadedComponents\” & fileName Using fs As New FileStream(absFileName, FileMode.Create) str.CopyTo(fs) str.Close() End Using Return […]

使用json将发送请求发送到RESTful WCF

我已经尝试了每个组合来发送请求从jQuery向RESTful WCF发送POST请求。 有人可以模仿并使其发挥作用。 代码在这里: http : //pastebin.com/Ua97919C 我在过去2年与WCF合作,但每次发送POST请求都会让我很烦恼。 我努力让它在过去的4天里工作,并且经历了至少35-40个post。 最终,此请求将从iPhone发送到WCF。 当我用Fiddler检查时,错误主要是:*服务器遇到处理请求的错误。 exception消息是’传入消息具有意外的消息格式’Raw’。 该操作的预期消息格式是’Xml’,’Json’。 这可能是因为尚未在绑定上配置WebContentTypeMapper。 有关更多详细信息,请参阅WebContentTypeMapper的文档。 请参阅服务器日志以获取更多详 exception堆栈跟踪是:at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

wcf REST服务和JQuery Ajax Post:不允许使用方法

谁知道这有什么问题? 我无法从我的wcfrest服务获得json响应。 jQuery的 $.ajax({ type: ‘POST’, url: “http://localhost:8090/UserService/ValidateUser”, data: {username: ‘newuser’, password: ‘pwd’}, contentType: “application/json; charset=utf-8”, success: function(msg) { alert(msg); }, error: function(xhr, ajaxOptions, thrownError) { alert(‘error’); } }); 服务 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class UserService: IUserService { private readonly IUserRepository _repository; public UserService() { _repository = new UserRepository(); } public ServiceObject […]