Skip to main content
Home Forums General Silverlight Hosting and Streaming how to use jquery to get silverlight enable wcf service?
5 replies. Latest Post by kkdhf on June 11, 2009.
(0)
kkdhf
Member
3 points
32 Posts
06-06-2009 6:33 AM |
hi ,
i don't know how to get data through silverlight enable WCF Service by using JQuery.
i get aspx page right but failed at WCF.
can u give me simple sample?
thx.
06-07-2009 1:50 AM |
i test create new website and new WCF ,
and use the reference silverlight enable WCF and call it at my new WCF.
but failed for occurs :
415 Unsupported Media Type.
i googled something but i don't unstand .
how to solve this exception?
davidezo...
Contributor
5614 points
863 Posts
06-07-2009 7:46 AM |
Hi,
are you using Silverlight 2 or 3 Beta? Can you post your code?
06-07-2009 9:07 PM |
i use 3 beta. follow is code:
silverlight enable WCF :
[ServiceContract(Namespace = "sunnhoo.Service")][AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]public class ChatService{[OperationContract]public string GetChat(string owenerID, string userID){ //... return "";}
silverlight enable config:<serviceBehaviors> <behavior name="ChatServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <customBinding> <binding name="customBinding1"> <binaryMessageEncoding /> <httpTransport /> </binding> </customBinding> <service behaviorConfiguration="ChatServiceBehavior" name="ChatService"> <endpoint address="" binding="customBinding" bindingConfiguration="customBinding1" contract="ChatService" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service>
and seems i cann't use jquery get touch with WCF Service.and then , i create a new website and new Service ,Ajax WCF Service:[ServiceContract(Namespace = "")][AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]public class SSSSService{ // 添加 [WebGet] 属性以使用 HTTP GET [OperationContract] public string GetChat() { try { ChatService.ChatService service = new ChatService.ChatService(); return service.GetChat("23", "23"); } catch (Exception err) { return err.ToString(); } }
[OperationContract] public string ConnectionTest() { return "jQuery client connected to WCF service via AJAX"; }}
i use jquery get the data for Method ConnectionTest,but get exception for Method GetChat :Unsupported Media Type.
something happend?
06-08-2009 6:49 AM |
I'd suggest to use REST, read this article for more info: http://tech2update.com/blog/?p=94
06-11-2009 1:40 AM |
oh, thx a lot. i have read some files.
it's really good.
thx again.