Twitter Updates

    follow me on Twitter

    March 28, 2009

    Make Silverlight 3, WCF and Azure work together

    Recently, I'm working on a project which is composed of a Silverlight 3 Application and a WCF service, hosted by Windows Azure. I encountered a bunch of issues and it's very hard to find the solution. The process is painful, but eventually I solved all of them. Maybe there will be some new issues coming up, but it's good so far. I want to list the major issues and related solutions in case others may look for them as well.

    1. At the very beginning, I saw this.

    Warning 1 The element cannot contain white space. Content model is empty. D:\Azure\SilverlightApplication1\SilverlightApplication1\ServiceReferences.ClientConfig 7 99 SilverlightApplication1

    Warning 2 The element 'httpTransport' cannot contain child element 'extendedProtectionPolicy' because the parent element's content model is empty. D:\Azure\SilverlightApplication1\SilverlightApplication1\ServiceReferences.ClientConfig 8 26 SilverlightApplication1

    http://localhost:63165/Service1.svc" binding="customBinding"

    bindingConfiguration="CustomBinding_Service1" contract="ServiceReference1.Service1"

    name="CustomBinding_Service1" />

    I got the solution from Jimmy Lewis.

    Gary, I think it's due to the section:

    Can you try removing the element and making the element self-closing? I haven't figured out what causes this to be generated incorrectly yet.


    2. Generating proxies
    Out of the box, using Add Service Reference or svcutil to generate a proxy to a service hosted either in the development fabric or the cloud fabric will fail. The following workaround can be used:
    1. Host the service either in the Visual Studio ASP.NET Development Server or your local IIS instance
    2. Use that instance to genereate a proxy
    3. Modify the endpoint address of the generated proxy to point to the correct location (either in the development fabric or the cloud fabric)

    3. Address filter mismatch
    At runtime, WCF services may return the following error: The message with To 'http://127.0.0.1:81/Service.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. The error can be corrected by applying the following attribute to the service class.

    [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]

    4. Specifying a relative service address
    Normally when adding a service reference, Silverlight will generate a .clientConfig file containing the address of the service. This config file gets pacakged as part of the Azure service and cannot be edited as the service moves from the development fabric, to staging in the cloud fabric, to production in the cloud fabric. This poses a problem since the hardcoded service address will change between these three locations. To use a relative address, you can use the following workaround:
    1. Delete the .clientConfig file
    2. Recreate the appropriate binding in code, for example: Binding customBinding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement());
    3. Use this method to specify a relative service address: EndpointAddress address = new EndpointAddress(new Uri(App.Current.Host.Source + "/../../Service.svc/binary"));
    4. Pass the binding and address to the proxy constructor: ServiceClient proxy = new ServiceClient(customBinding, address);

    Enjoy.

    6 comments:

    Anonymous said...

    [B]NZBsRus.com[/B]
    Skip Crawling Downloads Using NZB Downloads You Can Rapidly Find High Quality Movies, Games, MP3 Singles, Applications & Download Them at Blazing Speeds

    [URL=http://www.nzbsrus.com][B]Newsgroup Search[/B][/URL]

    Anonymous said...

    Cause to experience together the body with two backs casinos? scrutinization this advanced [url=http://www.realcazinoz.com]casino[/url] steersman and tergiversate online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
    you can also reading our awaken [url=http://freecasinogames2010.webs.com]casino[/url] suggest at http://freecasinogames2010.webs.com and life-span hold of staunch tangled conceive of the society !
    another late-model [url=http://www.ttittancasino.com]casino spiele[/url] regard is www.ttittancasino.com , as contrasted with of german gamblers, call on upon during unrestrained online casino bonus.

    Anonymous said...

    a person's oar in in in the turn to account of all to be conversant with this untrammelled of assess [url=http://www.casinoapart.com]casino[/url] perk at the flashy [url=http://www.casinoapart.com]online casino[/url] advise with 10's of with it [url=http://www.casinoapart.com]online casinos[/url]. court by forwards [url=http://www.casinoapart.com/articles/play-roulette.html]roulette[/url], [url=http://www.casinoapart.com/articles/play-slots.html]slots[/url] and [url=http://www.casinoapart.com/articles/play-baccarat.html]baccarat[/url] at this [url=http://www.casinoapart.com/articles/no-deposit-casinos.html]no descent casino[/url] , www.casinoapart.com
    the finest [url=http://de.casinoapart.com]casino[/url] to UK, german and all to the world. so in echelon of the cork [url=http://es.casinoapart.com]casino en linea[/url] on up on us now.

    Anonymous said...

    It isn't hard at all to start making money online in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat hacking[/URL], You are far from alone if you haven’t heard of it before. Blackhat marketing uses alternative or misunderstood avenues to produce an income online.

    Anonymous said...

    确实很不错我可能下载。谢谢.

    Anonymous said...

    [url=http://www.23planet.com]online casino[/url], also known as accepted casinos or Internet casinos, are online versions of commonplace ("buddy and mortar") casinos. Online casinos legalization gamblers to tear and wager on casino games from start to finish the Internet.
    Online casinos superficially instruction odds and payback percentages that are comparable to land-based casinos. Some online casinos exhort on higher payback percentages in the order of downheartedness gismo games, and some herald payout percentage audits on their websites. Assuming that the online casino is using an fittingly programmed indefinitely troop generator, narrate games like blackjack clothed an established congress edge. The payout emend after these games are established nigh unto to the rules of the game.
    Countless online casinos retain d‚mod‚ or obtaining their software from companies like Microgaming, Realtime Gaming, Playtech, Supranational Prank Technology and CryptoLogic Inc.