开发者

How to call webservice in Silverlight which is added to Cloud Service Project?

开发者 https://www.devze.com 2022-12-16 16:50 出处:网络
I would like to ask a question. One of my ex-colleague wrote one window azure project and now I need to continue this project. Web Service is in that window azure project and I need to call that web s

I would like to ask a question. One of my ex-colleague wrote one window azure project and now I need to continue this project. Web Service is in that window azure project and I need to call that web service in silverlight. Therefore, I add new silverlight project at that existing Window azure project. And when I am trying to add Service Reference in silverlight application. It shows "No Endpoint compatible with Silverlight3 were found" and it cannot create ServiceReference.config file.

I am not too family with web service and c#. So , could you tell me step by step of using web service at Silverlight.

I also tried to change "basicHttpBinding" and "customBinding" in Web.config file. But it doesn't allow me to change anything. So, without changing anything at serverside, how can I call webservice in silverlight?

Here is some part of code.

IEventHandler.cs
`[OperationContract]
        [WebGet(UriTemplate = "Holidays", ResponseFormat = WebMessageFormat.Xml)]
        List<Holidays> GetHolidays();`

EventHandler.svc
`public List<Holidays> GetHolidays()
        {
            //database declaration for purpose of accessing the db.
            Database db = new Database();

            //dg.getHolidays is found in the Database class.
            List<Holidays> holidays = db.getHolidays();

            return holidays;
        }`

Web.config
`<system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding"
                 maxBufferPoolSize="2147483647"
                 maxBufferSize=开发者_StackOverflow"2147483647"
                 maxReceivedMessageSize="2147483647" >
          <readerQuotas
            maxArrayLength="2147483647"
            maxStringContentLength="2147483647"/>
          <!--<security mode="Transport">
          </security>-->
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp />
          <enableWebScript/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Rest_EventHandler_WebRole.EventHandlerBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="Rest_EventHandler_WebRole.EventHandlerBehavior"
        name="Rest_EventHandler_WebRole.EventHandler">
        <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding"
          bindingConfiguration="webBinding" contract="Rest_EventHandler_WebRole.IEventHandler">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>`

For silverlight, how can I call that WebService? I don't have permission to change the serverside part. Do I need to use sisvcutil.exe? Could you kindly help me my problem?


I don't think you can do this. Silverlight only supports basicHttpBinding and customBinding. I suppose one option would be to create a middle WCF service layer where you just call the azure service and pass the result back to Silverlight.

Silverlight client -> Middle WCF layer -> Azure service

But this seems unnecesssary and overkill. Is there no way you can get control over the web service?

0

精彩评论

暂无评论...
验证码 换一张
取 消