Ajax calls web service in wcf(windows service)

  • Thread starter Thread starter Billy Zhang
  • Start date Start date
B

Billy Zhang

我们现在é‡åˆ°ä¸€ä¸ªé—®é¢˜ï¼Œé€šè¿‡wcf创建的webservice,选择windows
service作为宿主,采用java作为客户端调用æˆåŠŸï¼Œä½†æ˜¯æ— æ³•ä½¿ç”¨asp.net ajax调用。
我们å‚考了http://msdn.microsoft.com/zh-cn/library/bb410780.aspx的资料,并且下载了相应的sample
code,但是å‘现这些sample基本上都需è¦åœ¨iis上部署一个svc文件,但是根æ®å½“å‰ä¸šåŠ¡éœ€æ±‚,我们无法部署iisæœåŠ¡å™¨ã€‚
是å¦æœ‰windows service hostçš„wcf service与asp.net ajaxå作的解决方案?谢谢。
 
Hi Billy,

The thread content is displayed as garbo code, have you verified that all
the contents are posted via UTF8 or other unicode format? You can try first
paste them into a notepad with unicode encoding and repost the content
again to see whether it works.

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

--------------------
From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <[email protected]>
Subject: Ajax calls web service in wcf(windows service)
Date: Wed, 30 Jul 2008 01:57:01 -0700
ws
service作为宿主,采用java作为客户端调用æˆåŠŸï¼Œä½†æ˜¯æ— æ³•ä
½¿ç”¨asp.net ajax调用ã€?
我们å‚考了http://msdn.microsoft.com/zh-cn/library/bb410780.aspx的资æ–
™ï¼Œå¹¶ä¸”下载了相应的sample
code,但是å‘现这些sample基本上都需è¦åœ¨iis上部署一个svcæ–
‡ä»¶ï¼Œä½†æ˜¯æ ¹æ®å½“å‰ä¸šåŠ¡éœ€æ±‚,我们无法部署iisæœåŠ¡å™¨ã€?
是å¦æœ‰windows service hostçš„wcf service与asp.net
ajaxå作的解决方案?谢谢ã€?
 
Hi Billy,

I have performed some research on this. Here is some information I've got
so far:

As for the ASP.NET client script based AJAX call, it is limited by the web
page script model. For all the web pages in webbrowser, webbrowser will
restrict the script to access pages on remote server. For example, if your
page is from http://serverA , if your script try use some script
component to send webrequest to other server/application, it is not
allowed. And this also restrict the AJAX method call to remote
applications(webservice or wcf). I've even tried call WCF on the same
machine(different server application), it is now allowed.

So far, one way to make such remote WCF method call I can get is create a
local server-side page method in which you use server-side code to call the
remote WCF service. And your page's client-side script call this
server-side page_method via AJAX. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <[email protected]>
References: <[email protected]>
Subject: RE: Ajax calls web service in wcf(windows service)
Date: Wed, 30 Jul 2008 02:46:05 -0700
 
As you said, this also restrict the AJAX method call to remote
applications(webservice or wcf).

But actually I could call the web service in other IIS site by using Ajax.

Do I misunderstand you?
 
OK, please close it as resolved, thank you!


Steven Cheng said:
Hi Billy,

I have performed some research on this. Here is some information I've got
so far:

As for the ASP.NET client script based AJAX call, it is limited by the web
page script model. For all the web pages in webbrowser, webbrowser will
restrict the script to access pages on remote server. For example, if your
page is from http://serverA , if your script try use some script
component to send webrequest to other server/application, it is not
allowed. And this also restrict the AJAX method call to remote
applications(webservice or wcf). I've even tried call WCF on the same
machine(different server application), it is now allowed.

So far, one way to make such remote WCF method call I can get is create a
local server-side page method in which you use server-side code to call the
remote WCF service. And your page's client-side script call this
server-side page_method via AJAX. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------


¦Ë†Â·Ã§Â«Â¯Ã¨Â°Æ’çâ€Â¨æˆÂÂ功,ä½â€ 是æâ€?法Ã?
我们å‚考äºâ€ http://msdn.microsoft.com/zh-cn/library/bb
410780.aspx的资æ�
©Æ’½éœ€è¦ÂÂ在iisä¸Å 部署一个svcæâ€?‡ä»¶ï¼Œä½â€ 是Ã?¹æ®当å‰ÂÂ业åÅ ¡éœ€æ±â
€šÃ¯Â¼Å’我们æâ€?法部署iisæœÂÂ务器ã€?
 
Thanks or your reply.

Yes, this is a "cross-browser" script restriction which prevent script to
interact with remote site(domain).

Anyway, so far for your scenario, two possible solutions are available:

1. use AJAX call to invoke local server-side page method and let
server-side to call the WCF service

2. Move the WCF to the local site/application(at least need to have the
same main domain server name) with your web page application.

If there is anything else need help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <[email protected]>
References: <[email protected]>
<4#[email protected]>
Subject: RE: Ajax calls web service in wcf(windows service)
Date: Wed, 30 Jul 2008 22:38:00 -0700
OK, please close it as resolved, thank you!



€ Ã‚°Ã¤Â¸â‚¬Ã¤Â¸ÂªÃ©â€â€Ã‚®Ã©Â¢ËœÃ¯Â¼Å’Ã
©â‚Â?šè¿‡wcf创建的webserviceÃ
ƒÂ¯Ã‚¼Å’选择windo
€¡â€¡Ã§â€Â¨java作为客Ã?
¦Ë†Â·Ã§Â«Â¯Ã¨Â°Æ’çâ€Â¨æˆÂÂÃ¥Ã?ŸÃ
¯Â¼Å’ä½â€ 是æââ‚?法Ã?™ï¼Œå¹¶ä¸â€Â下载Ã
¤Âºâ€ 相åºâ€Âçš„sample
是å‘现这些sampleÃ
ƒÂ¥Ã…¸ÂºÃ¦Å“¬ä¸Ã?Ã
是Ã?¹æ®当å‰ÂÂ业ÃÂ
¥Ã… ¡éœ€æ±Ã?
 
Thanks or your reply.

Yes, this is a "cross-browser" script restriction which prevent script to
interact with remote site(domain).

Anyway, so far for your scenario, two possible solutions are available:

1. use AJAX call to invoke local server-side page method and let
server-side to call the WCF service

2. Move the WCF to the local site/application(at least need to have the
same main domain server name) with your web page application.

If there is anything else need help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <[email protected]>
References: <[email protected]>
<4#[email protected]>
Subject: RE: Ajax calls web service in wcf(windows service)
Date: Wed, 30 Jul 2008 22:38:00 -0700
OK, please close it as resolved, thank you!



€ Ã‚°Ã¤Â¸â‚¬Ã¤Â¸ÂªÃ©â€â€Ã‚®Ã©Â¢ËœÃ¯Â¼Å’Ã
©â‚Â?šè¿‡wcf创建的webserviceÃ
ƒÂ¯Ã‚¼Å’选择windo
€¡â€¡Ã§â€Â¨java作为客Ã?
¦Ë†Â·Ã§Â«Â¯Ã¨Â°Æ’çâ€Â¨æˆÂÂÃ¥Ã?ŸÃ
¯Â¼Å’ä½â€ 是æââ‚?法Ã?™ï¼Œå¹¶ä¸â€Â下载Ã
¤Âºâ€ 相åºâ€Âçš„sample
是å‘现这些sampleÃ
ƒÂ¥Ã…¸ÂºÃ¦Å“¬ä¸Ã?Ã
是Ã?¹æ®当å‰ÂÂ业ÃÂ
¥Ã… ¡éœ€æ±Ã?
 
Back
Top