Tag: wcf

使用Javascript连接到WCF Web服务

有谁知道如何使用Javascript连接到WCF Web服务? 此时我需要的是实际连接到Web服务,并通知连接成功。 有谁知道我怎么做到这一点?

如何从jQuery调用WCF Web服务?

如何从jquery调用wcf服务(我正在使用asp.net mvc)。 这就是我以前用asmx webservices做的事情: $.ajax({ type: “POST”, url: “Services/MyService.asmx/DoSomething”, data: “{}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { //do the magic } }); 如何使用WCF服务执行相同操作?

从jQuery调用一个简单的WCF服务

我有一个非常简单的WCF服务叫做pilltrkr.svc。 我试图通过以下代码从jQuery调用此服务: var jsondata = JSON.stringify(); $.ajax({ type: “POST”, async: false, url: ‘./pilltrakr.svc/DoWork/’, contentType: “application/json; charset=utf-8”, data: jsondata, dataType: “json”, success: function (msg) { alert(msg); }, error: function (XMLHttpRequest, textStatus, errorThrown) { // alert(XMLHttpRequest.status); // alert(XMLHttpRequest.responseText); } }); 我在本地做这个(所以使用localhost)。 DoWork只返回一个字符串。 当我调用此函数时,我得到一个http:// localhost:57400 / pilltrakr / pilltrakr.svc / DoWork / 404 Not Found 如何调用我的WCF服务? 我尝试了几种不同的变体(经过研究)。 我能够使用代码隐藏方法(客户端)来调用此服务。 […]

通过GET将数组传递给WCF服务

我有一个AJAX调用,我想针对WCF GET服务运行。 基本上,对服务的调用(通过jquery)看起来像这样: $.get(serviceEndpoint, {query : “some search text”, statusTypes: [1, 2]}, function (result) { /* do something*/ }, ‘text’); 当这个调用运行时,我看到firebug中的GET正确通过,我确实击中了端点。 但是,参数statusTypes始终为null。 来自jquery的GET本身看起来像是编码的,但是当我不对括号进行编码时,调用根本不会进入端点: HTTP://localhost/Services/SomeService.svc/Endpoint statusTypes%5B%5D = 1&statusTypes%5B%5D = 2&查询=一些+搜索+文本 而WCF服务本身: [OperationContract的] [WebInvoke(Method =“GET”,BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)] public ResultsViewModel GetTags(string query,int [] statusTypes) 是否可以通过GET将数组传递给WCF服务? 排列并不多,所以我可以编写一个单独的端点“每个数组”,但我宁愿把它保持在一个。

问题从jQuery调用WCF服务库

我有一个通过我的ASPX站点公开的WCF服务库,如下所示 [System.ServiceModel.OperationContract] [System.ServiceModel.Web.WebInvoke( Method= “POST”, RequestFormat=System.ServiceModel.Web. WebMessageFormat .Json, ResponseFormat=System.ServiceModel.Web.WebMessageFormat .Json)] LogonResponse Logon(LogonRequest logonRequest); [System.Runtime.Serialization.DataContract] [ Serializable()] public class LogonRequest { [System.Runtime.Serialization.DataMember] public string EMailAddress; [System.Runtime.Serialization.DataMember] public string Password; } 在我的测试页面中,我可以通过MS Ajax调用: – . . . function clsLogonRequest(eMailAddress, password) { this .EMailAddress = eMailAddress; this .Password = password; } function login(eMailAddress, password) { var LogonRequest = […]

415不支持的媒体类型从$ .ajax调用WCF服务

我试图从ASPX页面调用WCF Web服务,如下所示: var payload = { applicationKey: 40868578 }; $.ajax({ url: “/Services/AjaxSupportService.svc/ReNotify”, type: “POST”, data: JSON.stringify(payload), contentType: “application/json”, dataType: “json” }); 这样做会导致Web服务器返回错误415 Unsupported Media Type 。 我确定这是WCF服务的配置问题,定义如下: [OperationContract] [WebInvoke(Method = “POST”, RequestFormat = WebMessageFormat.Json)] void ReNotify(int applicationKey); web.config文件中没有条目,因此假设该服务使用默认配置。

WCF不反序列化JSON输入

我有一个WCF服务定义如下: Imports System.ServiceModel Imports System.ServiceModel.Web Public Interface ILayoutService Sub SaveLayout(ByVal layout As Layout) Function GetLayout() As Layout End Interface Layout类定义为: Imports System.Runtime.Serialization Public Class Layout Public Property Columns As New List(Of ContentColumn) End Class Public Class ContentColumn Public Property Name As String = “Column Name” Public Property Position As Integer Public Property Modules As New […]

Jquery Ajax,不在Internet Explorer中工作

我正在尝试做一些jQuery ajax,它适用于Firfox和Chrome,但不适用于Internet Explorer 9。 最终的代码必须跨越子域,这在默认传输中不起作用。 所以我正在尝试创建一个在Internet Explorer中使用的自定义传输 方法1 $.ajaxTransport(“+*”, function (options, originalOptions, jqXHR) { if (jQuery.browser.msie && window.XDomainRequest) { var xdr; return { send: function (headers, completeCallback) { // Use Microsoft XDR xdr = new XDomainRequest(); xdr.open(“get”, options.url); xdr.onload = function () { if (this.contentType.match(/\/xml/)) { var dom = new ActiveXObject(“Microsoft.XMLDOM”); dom.async = false; dom.loadXML(this.responseText); […]

通过AJAX调用在jQuery中使用WCF服务在另一个项目中调用(跨域)

我正在使用我下载的WCF jQuery AJAX调用示例。 我可以运行它并使它在同一个项目中工作。 当我从同一解决方案中的不同项目访问相同的内容时,它什么都不做。 以下是我打电话的方法。 function WCFJSON() { var parameter = “1234567890 (Cross Domain)”; Type = “GET”; Url = “http://localhost:52729/jQueryWebSite/Service.svc/Test?Id=” + parameter; Data = ‘{“Id”: “‘ + parameter + ‘”}’; ContentType = “application/json; charset=utf-8”; DataType = “jsonp”; ProcessData = false; CallService(); } $(document).ready(function () { WCFJSON(); }); 我有成功和失败方法的警报()。 当我直接在浏览器中运行URL时,它会返回结果。 但是,如果我从一个不同的项目运行它,它什么都不做。 没有警报,没有结果。 以下是我的服务运行项目的Web.Config; 是否与Web.config或脚本中的任何错误有关? 我已经遵循了许多方法并尝试了各种方法。

通过JQuery使用WCF POST进行400错误请求HTTP响应

无法让我的JQuery POST被WCF服务接受。 这是来自javascript的POST: function jqueryPost() { var url = “/LoggingTest”; $.post(url, { message: “test message” }); } 这就是我通过接口接受POST的方式: [OperationContract] [WebInvoke(Method = “POST”, UriTemplate = “/LoggingTest”, BodyStyle = WebMessageBodyStyle.Bare)] void LoggingTest(string message); 并实施: public void LoggingTest(string message) { log.Debug(message, null); } 当我调用函数jqueryPost时,我在Web检查器中看到了400 Bad Request的HTTP响应。 不确定如何让POST请求工作。 (在7/1上添加) @James,这是web检查器的输出: http:// localhost:4252 / LoggingTest HTTP信息 请求方法:POST 状态代码:400错误请求 请求标题 接受: […]