none
WCF throwing erros : Failed to add a service. Service metadata may not be accessible. Make sure your service is running and expo

    Question

  • Hi all, I am new here and new to WCF as well.

     

    I am trying to develop a WCF service using .NET 3.5 Framework. I created a new WCF project and hit F5, WCF test client came up and worked great with default classes...

     

    Now, we have to add some twist to the project... I added a service reference to an external web service, by accessing the WSDL. It created the proxy and serialization object in the service reference. Pretty awesome... However, after that when I F5 to test using the test client, I am getting the following error in a error dialog box.

     

    "Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata."

     

    The following messages appered in a list box... there are tons of these. My guess is there are one per the type generated using the service reference.

     

    c:\Documents and Settings\<<username>>\My Documents\Test Client Projects\49aadcb0-2cbe-4ed5-8595-ee366c63d47e\Client.cs(8781,26) : error CS0644: 'System.ComponentModel.PropertyChangedEventHandler' cannot derive from special class 'System.MulticastDelegate'
    c:\Documents and Settings\<<username>>\My Documents\Test Client Projects\49aadcb0-2cbe-4ed5-8595-ee366c63d47e\Client.cs(26,39) : warning CS0436: The type 'System.ComponentModel.PropertyChangedEventHandler' in 'c:\Documents and Settings\<<username>>\My Documents\Test Client Projects\49aadcb0-2cbe-4ed5-8595-ee366c63d47e\Client.cs' conflicts with the imported type 'System.ComponentModel.PropertyChangedEventHandler' in 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll'. Using the one in 'c:\Documents and Settings\<<username>>\My Documents\Test Client Projects\49aadcb0-2cbe-4ed5-8595-ee366c63d47e\Client.cs'.

     

    Could someone help me to resolve this issue? What could be going wrong?

     

    Thanks and appreciate your help.

    Thursday, March 13, 2008 5:56 AM

Answers

  • Ah, so I did pretty much understand from your original question. From what I can tell (Dan usually knows what he is talking about with these things) It sounds like the whole thing is choking because the classes generated from a WSDL are, themselves, not fit to return through a WCF method (not serializable? hmm). I can't comment on that part, but you seem to have found out the hard way that it doesn't work.

    My solution right now would be a work-around. Architecturally speaking, it seems like you might be better served by creating a custom WCF response anyway. Even if some of the data returned from the 3rd party web service is identical to what you need in your web app, what if that changes tomorrow? Do you re-engineer your web app to keep up with the changes?

    Granted, it is not any easier to re-engineer your middle tier (WCF) layer to keep up with changes, but at least you have the option of performing new types of processing on the web service data, but still returning the original type of data to your web app.

    With that in mind, I would create a custom data object to return to your web app. Use the web service response to populate your data object, and then you can do data processing on the web response but send your own data down to the web app. This model doesn't break as easily in the long term.

    As to your original problem of not being able to use a WSDL-generated proxy as a WCF return type, perhaps someone else could weigh in on that.
    Thursday, March 13, 2008 6:45 PM

All replies

  • I want to understand the problem better.

    You have a WCF service in one assembly, let's call it "server". You then have a client which references that server. You had your server connect to a web service...or your client is connecting to both the web service and the server? I didn't quite understand that part.

    While my first recommendation would be to check your metadata exchange endpoint, I am wondering about those errors. Are you trying to expose invalid types? Why does it think something is inheriting a multicast delegate? Could you post your operation contract, bindings, and a few more details? I would love to take a look at this.
    Thursday, March 13, 2008 11:50 AM
  • These look like 2 different errors.  I would think you have a metadata service endpoing specified since you generated a proxy, but just to be sure, make sure you service is exposing metadata like this:

    <behaviors>
                <serviceBehaviors>
                    <behavior name="myBevaior">
                        <serviceMetadata httpGetEnabled="True" />
                    </behavior>
                </serviceBehaviors>
    </behaviors>

    And your service woudl be using behaviorConfiguration="myBehavior"


    The error in the proxy looks like it may reference the full qualifed .Net type as a service operation return value.  Check your methods to make sure they arent doing this.  If they are then it wil cause your proxy to generate these classes which will cause conflicts like the errors on the bottom of you post.

    Thursday, March 13, 2008 11:52 AM
    Moderator
  • This post is about a similiar problem wiht .net types getting into the proxy classes:
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2980490&SiteID=1

    Thursday, March 13, 2008 11:53 AM
    Moderator
  • Sorry Charles, the question wasnt clear.  Let me try to add some more details here. Here is little flow chart in text format.

     

    1) Web App   ---HTTP Req--->   IIS Server   --WS Req--->   Partners site

    2) Partners site ---WS Resp ---> IIS Server --- WS Req (sends the WS response)---> WCF Service --- Data processing ---> database

     

    So, now in order for my WCF service to use the .NET serialization of WS response, I added the service reference to the partner's sites WSDL. And thats when the WCF could not publish the meta data. Make sense?

     

    Any ideas?

     

    Thanks.

     

    Thursday, March 13, 2008 4:47 PM
  • Thanks Dan.

     

    You are right on the point. In my operatiion contract, I am trying to use the type that was generated from the WSDL proxy. If I cant use these types, then what are the alternatives? Appreciate your help.

     

    Thanks

    Elangovan

     

     

    • Proposed as answer by laurentB1 Tuesday, February 14, 2012 1:19 PM
    Thursday, March 13, 2008 4:51 PM
  • Ah, so I did pretty much understand from your original question. From what I can tell (Dan usually knows what he is talking about with these things) It sounds like the whole thing is choking because the classes generated from a WSDL are, themselves, not fit to return through a WCF method (not serializable? hmm). I can't comment on that part, but you seem to have found out the hard way that it doesn't work.

    My solution right now would be a work-around. Architecturally speaking, it seems like you might be better served by creating a custom WCF response anyway. Even if some of the data returned from the 3rd party web service is identical to what you need in your web app, what if that changes tomorrow? Do you re-engineer your web app to keep up with the changes?

    Granted, it is not any easier to re-engineer your middle tier (WCF) layer to keep up with changes, but at least you have the option of performing new types of processing on the web service data, but still returning the original type of data to your web app.

    With that in mind, I would create a custom data object to return to your web app. Use the web service response to populate your data object, and then you can do data processing on the web response but send your own data down to the web app. This model doesn't break as easily in the long term.

    As to your original problem of not being able to use a WSDL-generated proxy as a WCF return type, perhaps someone else could weigh in on that.
    Thursday, March 13, 2008 6:45 PM
  • hi I am having a serious issue her when m trying to run the WCF project that i have created.

    When i run the service in the debug mode i am gettin this error

    Failed to add a service. Service metadata may not be accessible. Make sure your Service is running and exposing metadata.

    Error Details

    Error: Unrecognized option 'targetclientverrsion' specified.

    I have installed vs 2008 and i have installed the windows SDK 6.0 as well.

    Please be kind enough to resolve this issue. I have tryied all the option in the msdn

    Thank you
    Wednesday, November 12, 2008 6:19 AM
  • Desmond.Net said:

    hi I am having a serious issue her when m trying to run the WCF project that i have created.


    When i run the service in the debug mode i am gettin this error

    Failed to add a service. Service metadata may not be accessible. Make sure your Service is running and exposing metadata.

    Error Details

    Error: Unrecognized option 'targetclientverrsion' specified.

    I have installed vs 2008 and i have installed the windows SDK 6.0 as well.

    Please be kind enough to resolve this issue. I have tryied all the option in the msdn

    Thank you



    Wednesday, November 12, 2008 6:20 AM
  • Are you getting the below said problem when trying to test the WCF service using WCF test client?

    Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

    Here is one of the solution that caused the service metadata not accessible since the browser settings may have set with the following settings:

    Internet Explorer -> Settings -> Connections -> LAN Settings -> Automatically detect Settings option checked.

    Make sure it should be unchecked. The problem here is if your browser is set with some different other HTTP, FTP ports and proxy settings then WCF test client can not fetch the service from the default port (usually it searches in the default port settings).

    Hope this may help someone...

    Happy Coding..

    Sai
    Thursday, September 10, 2009 9:39 AM
  • Hi,

    I've been having the same problem. Turns out that when I changed the file names within the solution I overlooked renaming a section.

    Go to the solution explorer and find the .svc file (should be above the webconfig file by default)

    Right click and select 'View markup' and you should see a line of code that looks like the following:

    <%@ ServiceHost Language="C#" Debug="true" Service="TimeTrackerService.TimeTrackerService" CodeBehind="TimeTrackerService.svc.cs" %>

     

     

    (My project is called TimeTrackerService) - The Service="TimeTrackerService.TimeTrackerService" should have the same names as your svc file.

    When I looked at it originally it said "TimeTrackerService.Service1". <--Service1 is the svc file I changed the name of

    Changing this should get rid of the error,

    Jonno

     
    • Proposed as answer by the stud Tuesday, February 15, 2011 3:37 PM
    Wednesday, February 09, 2011 4:26 PM
  • i suggest for solve this problem, first comments all operation contracts (all your method) in interfaces and service types. then check your service, if service working properly and not problem, then you one by one uncomment operation contracts and equivalent service type until you find which op contract has potential of error.

    good luck

     

    Tuesday, March 15, 2011 6:06 PM
  • i suggest for solve this problem, first comments all operation contracts (all your method) in interfaces and service types. then check your service, if service working properly and not problem, then you one by one uncomment operation contracts and equivalent service type until you find which op contract has potential of error.

    good luck

    Tuesday, March 15, 2011 6:07 PM
  • Hi Elangovans,

                           i was also having the same problem in framework 4.0.

    first  remove the endpoints and behaviours from web.config like following

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
    </configuration>

    run your application, in the WCF test alient ou will find the setting to ad to you web.config

    now add those properties to your web.config

    like ----->

    <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true" />
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:2257/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="IService1" name="BasicHttpBinding_IService1" />
        </client>
      </system.serviceModel>

    definately te application will run.



    Asit

    Monday, February 04, 2013 11:57 AM