views:

203

answers:

2

I modified my web.config to add a custom binding in order to increase the buffer and message size, and it seems like in creating the service element explicitly, it has somehow broken the reference to my behavior element.

When I try to run my web service from VS using the WCF Test Client, or I go to the service page, I get the error:

Metadata publishing for this service is currently disabled.

I've compared my web.config to a few different sources on this and everything seems to match. I've no idea what the issue is.

Here is the System.serviceModel element:

<system.serviceModel>    
<services>
  <service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="http://localhost:1895/BIMIntegrationService.svc" 
              binding="customBinding" bindingConfiguration="customBinding0" 
              contract="BIMIntegrationWS.IBIMIntegrationService"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadataBehavior">
      <!-- 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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <customBinding>
    <binding name="customBinding0">
      <binaryMessageEncoding />
      <httpTransport maxReceivedMessageSize="262064"
                   maxBufferSize="262064"
                   maxBufferPoolSize="262064" />
    </binding>
  </customBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"  aspNetCompatibilityEnabled="true"/>

It almost seems like either the web service page is not finding the element. I don't get an error complaining that the target behaviorConfiguration doesn't exist, or anything like that, just that Metadata publishing is not enabled.

Any help would be greatly appreciated.

Thanks.

+1  A: 

I think i've "fixed" the issue. More coming later.

EDIT: In order to "fix" my issue, I basically added a new WCF service to my application, and had it implement my previous interface, I then copied all the code from my original service and when I tweaked the .config file (to look pretty much like the one posted in the question), everything worked fine.

Ofcourse, I know, like we all know, that there is no magic here, that there must be some discrepancy. This is when I noticed/remembered, that after I had created my original service, called "BIMIntegrationService.svc", I had decided that this was too long of a name, so I renamed/refactored my class to "BIMIntegrationWS". Doing this, however, does not change the name of the service file (and therefore the name of the file in the http:// address).

Long story short, I made 2 changes to my .config and everything worked:

1) I changed:

<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">

to

<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="metadataBehavior">

After running the service like this, I got an error (a helpful one this time) complaining that if multipleSiteBindings was enabled, the endpoint address had to be relative. So:

2) I set that to false (because I don't remember why it was in there in the first place) and everything worked fine.

I guess I should have taken a hint when it seemed like my web service was not using my "service" element at all. :\

EDIT 2:

Actually, you can see in my second comment, in the original question, that the auto-generated tag was pointing to: , as opposed to "BIMIntegrationService". That should have given it away.

I doubt many other people will have this same issue, but just in case.

Overhed
A: 

I've had the same trouble; I've gotten everything configured correctly (even copied the code from a previous service I have running) and yet no change on allowing the service to expose metadata. yet, if I make a spelling error, parse error, etc. to the app.config I'm given exceptions telling me to correct the problem (which tells me the service is reading the config, just disregarding it.

I was able to bypass it by generating the config settings in the host application:

System.ServiceModel.Description.ServiceMetadataBehavior smb = new System.ServiceModel.Description.ServiceModelBehavior();
smb.HttpGetEnabled = true;
ServiceBase host = new Servicebase(typeof(MyService), new Uri("http://localhost:1234/"));
host.Description.Behaviors.Add(smb);
host.Open();

...

host.Close();

Basically allow the code to override and push the config file changes i wanted applied. I know it's not ideal, but I was exposing the service through a windows service which made this do-able. if you do get your problem resolved, please pass along the solution though as I'd be curious to know why (at least in yours, if not both our cases) it's failing.

bradchristie