Link to home
Start Free TrialLog in
Avatar of wint100
wint100Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Silverlight 4 Application with Custom USer controls not return data in browser

I'm using SL4 to create a widget framework, where several widgets are loaded onto the page on load.

The widgets use WCF to get their data (weather data, twitter feeds etc..). All widgets as well as the main framework page, are seperate projects in the solution. The Main framework page, has references to the different widget projects, for use as user controls on the page. So, I reference the project, then drag the control from the toolbox. All silverlight projects contact a WCF service on the ASP.NET web app.

This all works well OOB, but in the browser, none of the data is retrieved, the widgets just sit there trying to load data from the WCF service.

Is the a reason why this would work OOB, but not in browser? I'm using the client access policy file on the wwwroot folder, but still get no data.

Cheers
Avatar of Gautham Janardhan
Gautham Janardhan

can you give some more info, like what the user control is trying to do, how it communicates with the WCF service.
Avatar of wint100

ASKER

The user control is trying to contect the WCF Service on the Server ASP.NET, to retrieve weather info, RSS feeds etc.. When run OOB, or if running on localhost, the data is retrieved, but when run in browser on a client machine, the data is not retrieved.

The user control is host inside the silverlight client application, although I've just noticed on each usercontrol serviceconfig, that the endpoint is set for localhost:

<endpoint address="http://localhost:52878/Services/WeatherService.asmx"
                binding="basicHttpBinding" bindingConfiguration="WeatherServiceSoap"
                contract="WeatherService.WeatherServiceSoap" name="WeatherServiceSoap" />

Why would this still work OOB on remmote clients though??
Avatar of wint100

ASKER

I've also had to add all endpoints from widgets(user controls) to the client app to get it to work at all:

<client>
            <endpoint address="http://localhost:52878/Services/SilverlightService.svc"
                binding="customBinding" bindingConfiguration="CustomBinding_SilverlightService"
                contract="SilverlightService.SilverlightService" name="CustomBinding_SilverlightService" />
            <endpoint address="http://localhost:52878/Services/WeatherService.asmx"
                binding="basicHttpBinding" bindingConfiguration="WeatherServiceSoap"
                contract="WeatherService.WeatherServiceSoap" name="WeatherServiceSoap" />
          <endpoint address="http://localhost:52878/Services/SilvTwitService.svc"
        binding="customBinding" bindingConfiguration="CustomBinding_SilvTwitService"
        contract="SilvTwitSvc.SilvTwitService" name="CustomBinding_SilvTwitService" />
        </client>
Avatar of wint100

ASKER

It seems the issue it with a standard webservice(asmx) that link through to a web reference, for the weather service. The User contorl for weather contacts the asmx, whihc in turn gets data from a web reference, so this is where the lack of data exists, not in WCF.
are you getting any errors when calling the service ?? If it's working on local host and stops working when you deploy it, then it would be a security issue.
Avatar of wint100

ASKER

No errors, it just doesn't get any data. Why would it work OOB but not in browser though? Wouldn't security affect both?

It works for http://localhost/mypage.aspx but not http://{myipaddress}/mypage.aspx. Soe ven though both local, it doesn't like anything other than localhost, even on local machine.
then the problem will be with the service... if SL is not throwing up any errors then it is able to connect to the service but there it may not be ale to retrieve the data.

Also Do you have any error logging in place which might be swallowing the error thrown ??
Avatar of wint100

ASKER

Not at present, the app just continues to run, trying to fetch the data.

I'll have to play around with the asmx service. Is there a cross domain issue with asmx, like with WCF services?
Under normal scenarios there wont be any problem, unless you are explicitly set up the website to do so. I would say that you take a look at your service a bit closely , to see why it is not returning data or it is swallowing any exceptions it's encountering

If any exceptions is thrown in the service the it has to be brought to the UI side as a response or if in the case of WCF as a fault exception.
Avatar of wint100

ASKER

I've checked the web.config and there are no entries for the asmx service at all, should there be an endpoint and binding for asmx services?
i dont hink so. can you see what is authentication mdoe for this web service ?
Avatar of wint100

ASKER

Security Mode is set to "None"
i think then the problem is with your service. Either it's not able to contact the data store from where you are getting the data from , and whatever the error that is happening is not getting propagated to the UI. So from the UI it looks like no data is retrieved.
Avatar of wint100

ASKER

Why would it work OOB on the remote client though?
not sure... are you able to identify which is the service request that is failing ??? is it the web service or the WCF service..By looking through the endpoints i saw that you are using basicHttp for web service while custom for the other.. can you try making these also basicHTTP and try...
Avatar of wint100

ASKER

It is the web service that is failing, WCF seems ok.
ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wint100

ASKER

Setup logging but got nothing. For my WCF Service I'm using the following to get the absolute path on the production server:


Uri address = new Uri(Application.Current.Host.Source, "../Services/Service.svc");
private SilverlightServiceClient dbAccess;

dbAccess = new SilverlightServiceClient("CustomBinding_Service", address.AbsoluteUri);

I copied the same principal for teh web service, and it seems to work well now.

Thanks for your help.
Cool. Good one!