简体   繁体   English

连接到WCF服务C#时出错

[英]Error connecting to WCF Service c#

I'm developing a SOAP software for a customer. 我正在为客户开发SOAP软件。 We are migrating to SOAP because we'll do a mobile app soon. 我们正在迁移到SOAP,因为我们将很快开发一个移动应用程序。

I alread did the .svc file and connects with IE. 我已经做了.svc文件并与IE连接。 But, if I try to connect with Firefox, Opera, GC or any other browser, it says "Method not allowed". 但是,如果我尝试与Firefox,Opera,GC或任何其他浏览器连接,则会显示“不允许使用方法”。

I alread tried to insert a header on AJAX/JSON to allow 'Access-Control-Allow-Origin'. 我已经尝试在AJAX / JSON上插入标头以允许“ Access-Control-Allow-Origin”。 I also insert on server side, on the interface the webinvoke header, and nothing works. 我还在服务器端,在接口上插入了webinvoke标头,但没有任何效果。

This is my first question on stack overflow, so I do not know how asking works. 这是我关于堆栈溢出的第一个问题,所以我不知道询问的工作原理。

Thanks to all! 谢谢大家!

Header Code of AJAX/JSON: AJAX / JSON的标题代码:

function SendToService(urlSvc, objDTO) {

var bk = null;
var item = {
    info: objDTO
};

$.ajax({
    url: urlSvc,
    type: 'POST',
    data: JSON.stringify(item),
    contentType: 'application/json; charset=utf-8',
    dataType: 'json',
    async: false,
    headers: {
        'Access-Control-Allow-Origin': 'http://localhost:16587',
    },
    success: function (msg) {
        bk = msg.d;
    },
    error: function (msg) {
        bk = false;
    }
});

return bk;

}; };

It looks like your method doesn't allow POST requests. 看来您的方法不允许POST请求。 Try allowing for POST on the destination method or test by changing your ajax request to GET instead. 尝试在目标方法上允许POST或通过将ajax请求更改为GET进行测试。 If the GET succeeds, you know where your problem is. 如果GET成功,您就会知道问题出在哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM