如何通过jquery访问WCF自助托管? [英] How to access WCF Self hosting by jquery ?

查看:43
本文介绍了如何通过jquery访问WCF自助托管?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:

我尝试了很多次,研究了许多文档,但仍然不起作用,即使我不知道出了什么问题. (我认为可能是wcf配置错误)

因为jQuery将返回

就绪状态:4

状态:415

statusText:由于内容类型'application/json; charset = utf-8'不是预期的类型'text/xml,因此无法处理该消息; charset = utf-8'."

我想执行控制台程序,它将在某个端口托管wcf服务并监听...

另一个HTML或aspx或cshtml页面将使用jquery访问wcf服务.

有人可以告诉我完整的示例代码吗?谢谢

这是我的示例代码

公共接口IService
{

解决方案

statusText:由于内容类型'application/json; charset = utf-8'不是预期的类型为'text/xml; charset = utf-8'."

http://www.freeformatter.com/mime-types-list.html

https://msdn. microsoft.com/en-us/library/bb472488%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

因此,您必须让WCF服务知道JSON即将到来,而不是text/xml使用Bing或Google, 查找有关此和WCF的文章.


Hi:

I try many times and study many document still not work, even I don't know what's problem. (I think maybe wcf configuration error)

because the jquery will return

readystate:4

status:415

statusText:"Cannot process the message because the content type 'application/json;charset=utf-8' was not the expected type 'text/xml; charset=utf-8'."

I want execute console program and it will hosting wcf service at some port and listen...

The other HTML or aspx or cshtml page will use jquery to access the wcf service.

Can someone show me the complete sample code ? thanks

Here are my sample code

public interface IService
{

解决方案

statusText:"Cannot process the message because the content type 'application/json;charset=utf-8' was not the expected type 'text/xml; charset=utf-8'."

http://www.freeformatter.com/mime-types-list.html

https://msdn.microsoft.com/en-us/library/bb472488%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

So, you have to make the WCF service know that JSON is coming and not text/xml use Bing or Google,  find articles about this and WCF.


这篇关于如何通过jquery访问WCF自助托管?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆