Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Web Services: ConfigUnrecognizedElement error RSS

18 replies

Last post Sep 10, 2008 12:12 PM by HarjinderSilverLight

(0)
  • CoderX

    CoderX

    Member

    178 Points

    96 Posts

    Web Services: ConfigUnrecognizedElement error

    Jun 10, 2008 12:34 AM | LINK

    I upgraded to Beta 2 today, and all my web services are not functioning. I get the following anytime I try to instantiate them:

    "An unhanded exception ('Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'Xaml1': System.InvalidOperationException: ConfigUnrecognizedElement at System.ServiceModel.Configuration.BindingsSection.ReadXml(XmlReader reader)"

    I get this on both ASMX and WCF web services (all of which previously worked quite well in Beta 1).

    I even created a brand new SL app added a Service Reference to one of the WebServices, and I still get this error.

    I tried re-adding them, changing them to give Array instead of ObservableCollection, everything I can think of.  Nothing seems to work.

    It looks like it is choking on the ServiceReferences.ClientConfig... but I don't know for sure.

    Any ideas?
     

    web service

  • snelldl

    snelldl

    Star

    8567 Points

    2070 Posts

    Re: Web Services: ConfigUnrecognizedElement error

    Jun 10, 2008 12:47 AM | LINK

    Can you update your existing references without getting an error?

  • CoderX

    CoderX

    Member

    178 Points

    96 Posts

    Re: Web Services: ConfigUnrecognizedElement error

    Jun 10, 2008 02:07 AM | LINK

    Yes, I can update them without issue. It is only when I try to instantiate that I have the problem. It is very strange because it worked fine before I upgraded to Beta 2. Even basic test projects fail in exactly the same manner.

    snelldl

    Can you update your existing references without getting an error?

  • snelldl

    snelldl

    Star

    8567 Points

    2070 Posts

    Re: Re: Web Services: ConfigUnrecognizedElement error

    Jun 10, 2008 09:04 AM | LINK

    Is the problem occurring on yur development machine or a live site?

  • CoderX

    CoderX

    Member

    178 Points

    96 Posts

    Re: Re: Web Services: ConfigUnrecognizedElement error

    Jun 10, 2008 02:24 PM | LINK

    I'm doing the B1->B2 update on my development machine. I've tried WebServices that are both live and part of the project. I get the same thing for both. I don't want to post the live WS URL publicly, but I'd be happy to send it directly to anyone who would like to try it.
  • CoderX

    CoderX

    Member

    178 Points

    96 Posts

    Re: Re: Web Services: ConfigUnrecognizedElement error

    Jun 10, 2008 11:09 PM | LINK

    Ok, further work on this issue has narrowed it down to an issue with the ServiceReferences.ClientConfig file. It appears that Silverlight is choking on the customBinding section that is being created in that file. For some reason it cannot parse it. In fact even the IDE marks the customBinding tag with squiggles saying "The element 'bindings' has invalid child element 'customBinding'. List of possible elements expected: 'basicHttpBinding'."

    There appears to be two workarounds:

    1) Remove the customBinding section from the ServiceReferences.ClientConfig file.

    2) Explicitly set the binding and endpoints when you instantiate your service:

        BasicHttpBinding bind = new BasicHttpBinding();
        EndpointAddress endpoint = new EndpointAddress("http://myservices.mysite.edu/MyService.asmx");

        MyService.MyServiceSoapClient ws = new  MyService.MyServiceSoapClient(bind, endpoint);

    ...
     

    The latter seems to avoid trying to parse the customBinding section.

     

    So why is that customBinding section not parseable? Is there a .dll or something that did not get installed properly? Is there a hot-fix that needs to me installed/made? Is any one else seeing this kind of behavior?
     

  • Yi-Lun Luo - MSFT

    Yi-Lun Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: Re: Re: Web Services: ConfigUnrecognizedElement error

    Jun 11, 2008 09:52 AM | LINK

    Hello, how did you make the service reference tool to generate a custom binding in the configuration file? Are you using a WCF custom binding on the server side? Silverlight currently only supports SOAP 1.1 (BasicHttpBinding). If you indeed need a custom binding, you should write this on the server side:

    <customBinding>
    <binding name="myBinding">
    <textMessageEncoding messageVersion="Soap11"/>
    <httpTransport/>
    </binding>
    </customBinding>

    But this will also generate a BasicHttpBinding on the Silverlight client configuration file... Yes, there is a CustomBinding class in Silverlight. But currently it can do nothing more than BasicHttpBinding. Also you can't write it in the configuration file...

    shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
  • CoderX

    CoderX

    Member

    178 Points

    96 Posts

    Re: Re: Re: Web Services: ConfigUnrecognizedElement error

    Jun 11, 2008 03:56 PM | LINK

    Visual Studio is making the custom binding in the .ClientConfig file, not me (I don't want one).

    All I'm doing is adding a service reference to a .asmx web-service.

    Steps:

    1) Create new SilverLight Application as Web application Project

    2) Right-click the main SL project (not _Web project)

    3) Select "Add Service Reference..."

    4) Enter URL to .asmx web-service (I'll send it to you in private message, but any one should work), Click Go, Select it, Click Ok.

    5) Open ServiceReferences.ClientConfig and note the presence of the customBinding section.

    6) Attempt to instantiate your web-service in the Page.xaml.cs file...

    7) Witness error

     

  • AlbertasA

    AlbertasA

    Member

    18 Points

    7 Posts

    Re: Web Services: ConfigUnrecognizedElement error

    Jun 11, 2008 07:20 PM | LINK

    I got exactly the same exception. Your work-around solution fix'es the problem.

  • Yi-Lun Luo - MSFT

    Yi-Lun Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: Re: Re: Re: Web Services: ConfigUnrecognizedElement error

    Jun 12, 2008 02:28 AM | LINK

    Replied to your private message. The problem is your service is using SOAP 1.2. Currently Silverlight only supports SOAP 1.1. You can configure your service application to remove support for SOAP 1.2:

     <webServices >
    <protocols>
    <remove name="HttpSoap12"/>
    </protocols>
    </webServices>

    Also you may want to migrate to WCF. Generally it's easier to configure a WCF service.

    shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.