我已經使用this example 爲jQuery創建了一個WCF服務我的WCF目前在用於PhoneGap應用程序的jQuery中工作,我可以在C#中的其他應用程序中使用相同的WCF服務。在Jquery和C#中都可以訪問相同的WCF嗎?
1
A
回答
2
可以爲不同的應用程序使用相同的WCF服務。 爲同一WCF服務創建多個綁定和多個端點
多個綁定
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConfiguration" receiveTimeout="infinite" sendTimeout="10.00:00:00" maxBufferPoolSize="1073741824" maxBufferSize="1073741824" maxReceivedMessageSize="1073741824">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
</binding>
</netTcpBinding>
<webHttpBinding>
<binding name="webHttpBindingConfiguration" receiveTimeout="00:10:00" sendTimeout="10.00:00:00" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
</binding>
</webHttpBinding>
</bindings>
多個端點 - 兩個端點被曝光,一個使用的WebHttpBinding,另一個使用NetTcpBinding的
請注意,雖然在en dpoints,即使用behaviorConfiguration =「EndpointBehavior」。使用webHttpBinding的終端通過JSON公開數據。
<services>
<service behaviorConfiguration="behavior" name="WCFCallbackTry.Service1">
<endpoint address="http://localhost:8018/Service1.svc" bindingConfiguration="webHttpBindingConfiguration" binding="webHttpBinding"
contract="WCFCallbackTry.IService" name="HttpEndPoint" behaviorConfiguration="EndpointBehavior"/>
<endpoint address="net.tcp://localhost:8004/Service1.svc" bindingConfiguration="netTcpBindingConfiguration" binding="netTcpBinding"
contract="WCFCallbackTry.IService" name="NetTcpEndPoint"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8018/Service1.svc"/>
</baseAddresses>
</host>
</service>
</services>
對於使用Jquery公開WCF,必須使用以下行爲,如您引用的鏈接所示。
<endpointBehaviors>
<behavior name="EndpointBehavior">
<webHttp/>
</behavior>
使用NetTcpBinding的端點可以從使用C#,而可能的WebHttpBinding使用JQuery使用的客戶端應用程序來使用。
與上面類似的配置可以用於不同或相同類型的綁定,同時暴露不同的端點。
希望這會有幫助
+0
thnx dera這幫了很多.. – faraaz
相關問題
- 1. 可以通過python和php訪問相同的mysqldb嗎?
- 2. WCF可以通過Internet訪問Windows服務中的WCF嗎?
- 3. 不同的Android設備可以訪問相同的SQLite表嗎?
- 4. 只有在相同的包和子包中才可以訪問接口嗎?
- 5. HTML網站和aspx都可以共享相同的域名嗎?
- 6. WCF TCP和HTTP端點可以有相同的端口嗎?
- 7. 任何人都可以從CDN訪問jQuery Tools嗎?
- 8. WCF服務可以訪問在同一進程中運行的其他ServiceHosts嗎?
- 9. 我可以在Azure WCF服務Web角色中訪問ServiceEndpoint嗎?
- 10. 兩個類可以相互訪問嗎?
- 11. Facebook可以離線訪問相冊嗎?
- 12. 兩個應用程序可以訪問相同的Cookie嗎?
- 13. Diffrerent用戶都可以訪問相同的變量在我的servlet
- 14. C++標準算法中的ForwardIterator和OutputIterator可以相同嗎?
- 15. 這個角度在任何寬度都可以相同嗎?
- 16. C++訪問節可以交錯嗎?
- 17. 可以從C#訪問Beanshell對象嗎?
- 18. 我可以在jQuery驗證中訪問HttpPostedFileBase的屬性嗎?
- 19. 任何時候都可以啓動相同的任務嗎?
- 20. GWT - TabPanel下的所有子控件都可以相同嗎?
- 21. 不同級別的功能層次可以訪問相同的數據嗎?
- 22. Resharper和代碼合同都可以使用共同的PureAttribute嗎?
- 23. 任何人都可以訪問我的PHP源代碼嗎?
- 24. 我可以在TCP和UDP中使用相同的sockaddr_in嗎?
- 25. CFFI可以在Python 3.4和3.5中使用相同的DLL嗎?
- 26. WCF Web服務可以執行大量的SQL表訪問嗎?
- 27. 同一類中定義的兩個結構體可以互相訪問嗎?
- 28. 局部變量和函數在C中可以有相同的名字嗎?
- 29. 你可以訪問C#中的Outlook AppointmentItem中的窗體嗎?
- 30. 我們可以在C++/VC++中訪問ODB ++文件(PCB)嗎?
是的,你可以。如果需要,您可以更改其綁定/ Ednpoint。 –