我創建了許多標準的WCF服務(服務契約和主機(svc)在單獨的程序集中)。我在IIS中啓動了一個網站來託管服務(即地址爲http://services:1000/wcfservices.svc)。通過Javascript,AJAX或JQuery調用WCF服務
然後在我的網站項目中,我添加了參考。我可以正常撥打這些服務。我需要調用一些服務客戶端。不知道是否應該查看通過AJAX,JQuery或啓用JSON的WCF服務調用WCF服務的文章。任何人都可以提供任何想法或配置經驗嗎?
有些我做了加入以下的經營合同的更改:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "SetFoo")]
void SetFoo(string Id);
那麼這上面的接口的實現:
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
然後在服務webconfig我有這(parens是尖括號):
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://services:1000/wcfservices.svc/"/>>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
然後在客戶端我嘗試這樣的:
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
<compositeScript>
<Scripts>
<asp:ScriptReference
Path="http://Flixsit:1000/FlixsitWebServices.svc" />
</Scripts>
</CompositeScript>
</asp:ScriptManagerProxy>
我試圖打電話給這樣的服務在javascript:
wcfservices.SetFoo(string Id);
沒有什麼工作。如果這是想法或更好的解決方案來調用JSON啓用,JQuery等....我願意做任何改變。
感謝提供任何建議/提示....
有沒有設置這個可用的地方的例子?感謝您的反饋意見。 – obautista 2011-01-13 04:46:32