从远程javascript中调用WCF服务 [英] Calling WCF service from a remote javascript

查看:104
本文介绍了从远程javascript中调用WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WCF服务(XML + JSON)在 HTTP运行://的ServiceHost:8080 /为myService 。 使用jQuery我的ASP.NET应用程序运行在 HTTP://webapp/Login.aspx

我想jQuery的使用Ajax和调用的URL 的http://的ServiceHost:8080 /为myService 。该浏览器不允许这种跨主机通话,预计。 一些计算器上的帖子建议使用JSONP。这是唯一的选择吗?

有没有一种方法来定义的 HTTP代理服务:// Web应用并有它访问远程WCF服务?

感谢

ABHI

解决方案
  

有没有一种方法来定义代理   在的http:// web应用并有   它访问远程WCF服务?

是的,这就是我想要做的。有很多方法可以做到这一点。如果使用负载平衡器或其他前端代理软件,你可以路线那里。此外,您还可以与IIS代理服务器代理

http://windowsitpro.com/article/articleid/8322/extending-iis-with-proxy-server.html

有第三方和开源替代品(例如Apache可能只是你的代理)

也许,你会想要做这样的事情呢 - 不是每个人都可以打开8080端口(如企业防火墙内)

I have a WCF service (XML+JSON) running on http://servicehost:8080/myService. My ASP.NET application with jQuery is running on http://webapp/Login.aspx

I want jQuery to use Ajax and call the URL http://servicehost:8080/myService. The browser does not allow this cross-host call, which is expected. Some of the posts on stackoverflow suggested using JSONP. Is that the only option?

Is there a way to define a proxy service on the http://webapp and have it access the remote WCF service?

Thanks

Abhi

解决方案

Is there a way to define a proxy service on the http://webapp and have it access the remote WCF service?

Yes, and that's what I'd do. There are a lot of ways to do it. If you use a load-balancer or other front-end proxy software, you could route there. Also, you could proxy with IIS proxy server

http://windowsitpro.com/article/articleid/8322/extending-iis-with-proxy-server.html

There are third-party and open-source alternatives (e.g. Apache could be just your proxy)

Probably, you'd want to do something like that anyway -- not everyone can open up port 8080 (like inside of corporate firewalls).

这篇关于从远程javascript中调用WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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