最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ajax - How do I make a JavaScript call to a WCF service hosted on a different domain? - Stack Overflow

programmeradmin2浏览0评论

We are designing a web application using ASP.NET and AJAX and we want to host our WCF Service Layer on a different website and make JavaScript calls to the Service Layer from our client pages. We understand that the browser will not allow AJAX calls to a different port or domain. What is the best way to architect a solution? We are considering using a proxy layer with services hosted on the same domain as the client which has a web reference to the service layer. Is there a better solution?

We are designing a web application using ASP.NET and AJAX and we want to host our WCF Service Layer on a different website and make JavaScript calls to the Service Layer from our client pages. We understand that the browser will not allow AJAX calls to a different port or domain. What is the best way to architect a solution? We are considering using a proxy layer with services hosted on the same domain as the client which has a web reference to the service layer. Is there a better solution?

Share edited Sep 30, 2008 at 15:46 Jason Bunting 59k16 gold badges104 silver badges94 bronze badges asked Sep 30, 2008 at 14:53 Josh KahnJosh Kahn 1
  • The solution you propose is really the only way, I believe. – nickohrn Commented Feb 14, 2009 at 7:41
Add a ment  | 

5 Answers 5

Reset to default 6

It's generally best to limit the number of domains accessed by your page. A server-side proxy is really a good way to go.

i think the best way is to call a local Page which call remote resource and returns result. in this way, you avoid cross domains problems

  • You can do virtual hosting of the service and website under same domain but different folder.
  • define the services in different dlls and create svc files in your websites and point the svc files to the dll which has the services
  • server side proxy.

Your load balancer could send all request to /service to your service server.

If you don't have a load balancer, you can have your webserver act as a reverse proxy to your service server. If you are using IIS7, you can do this with the Application Request Routing module.

Prototype has a plug in for this. The issue is on the client not the server. www.mellowmorning./2007/10/25/introducing-a-cross-site-ajax-plugin-for-prototype/

发布评论

评论列表(0)

  1. 暂无评论