Skip to main content

Microsoft Silverlight

Answered Question how to use jquery to get silverlight enable wcf service?RSS Feed

(0)

kkdhf
kkdhf

Member

Member

3 points

32 Posts

how to use jquery to get silverlight enable wcf service?

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.

Yes,I AM Chinese. And My Height More Than 1.74,
Reach 1.75.....Big Guy. :>

kkdhf
kkdhf

Member

Member

3 points

32 Posts

Re: how to use jquery to get silverlight enable wcf service?

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?

Yes,I AM Chinese. And My Height More Than 1.74,
Reach 1.75.....Big Guy. :>

davidezordan
davidezo...

Contributor

Contributor

5690 points

875 Posts

Silverlight MVP

Re: Re: how to use jquery to get silverlight enable wcf service?

Hi,

are you using Silverlight 2 or 3 Beta? Can you post your code?

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts

kkdhf
kkdhf

Member

Member

3 points

32 Posts

Re: Re: how to use jquery to get silverlight enable wcf service?

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?

Yes,I AM Chinese. And My Height More Than 1.74,
Reach 1.75.....Big Guy. :>

davidezordan
davidezo...

Contributor

Contributor

5690 points

875 Posts

Silverlight MVP
Answered Question

Re: Re: Re: how to use jquery to get silverlight enable wcf service?

Hi,

I'd suggest to use REST, read this article for more info: http://tech2update.com/blog/?p=94

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts

kkdhf
kkdhf

Member

Member

3 points

32 Posts

Re: Re: Re: how to use jquery to get silverlight enable wcf service?

oh, thx a lot. i have read some files.

it's really good.

thx again.

Yes,I AM Chinese. And My Height More Than 1.74,
Reach 1.75.....Big Guy. :>
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities