Metadata doesn't appear - wcf

I'm trying to create a WCF service, but the metadata doesn't appear, i try:
<system.serviceModel>
<services>
<service
name ="MyNamespace.IMyContract"
behaviorConfiguration="mex">
<endpoint
address = ""
binding = "wsHttpBinding"
contract = "MyNamespace.IMyContract"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mex">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I try to access with http://MyServer/receptor.svc but shows that Metadata publishing for this service is currently disabled. and http://MyServer/mex shows 404, why? What am i doing wrong?
OBS1: i publish my service in IIS7.5 on Windows 7.
OBS2: if i remove behaviorConfiguration="mex" the metadata works, but with basicHttpBinding not with wsHttpBinding.

I forget to put:
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />

Related

I'm not able to run WCF service on IIS 5.1

I have WCF service that works fine on VS2008's Development Server, but after I deployed it on IIS 5.1 and ran the following error message comes up:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
The appropriate section in web.config file looks as following:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Parus.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Parus.ServiceBehavior" name="Parus.Service">
<endpoint address="" binding="basicHttpBinding" contract="Parus.IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
I've tried to follow this article:
http://blogs.msdn.com/b/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx
But it's not working.
Does anybody know to resolve this issue?
Goran

how to configure wcf endpoints?

<system.serviceModel>
<services>
<service
name="myClass.IService1" behaviorConfiguration="myService">
<endpoint
name="ep1"
address="http://localhost:57582/Service1.svc"
contract="IService1"
binding="basicHttpBinding"
/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myService">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
but still i am getting the following error::
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
your service name IService1 - this looks like it might in fact be
the contract. If you are using the normal templates then remove the
I from IService1
If you are IIS hosting you can remove the address as the location of the .svc file is automatically the address.
The contract needs to be fully qualified including the namespace of the contract interface
with this in place your metadata should be served from <.svc file location>?wsdl

Azure web service URL issue

I wrote a simple webget service , added this code at web.config..
Then in order to access it i had to type this http://127.0.0.1/service1.svc/data?value=4
I searched all the config files but couldnt find how to get rid of service1.svc part..
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webby">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WCFServiceWebRole1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint
address="/"
binding="webHttpBinding"
contract="WCFServiceWebRole1.IService1"
behaviorConfiguration="webby"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
If you're on Azure, you'll most likely be hosting on IIS.
This article: http://social.technet.microsoft.com/wiki/contents/articles/hosting-a-wcf-rest-service-on-iis.aspx explains nicely how to use ASP.NET routing to re-route requests for Service1.svc to your service.

How to change address of WSDL?

I host simple WCF service in IIS in web application.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SimpleServiceBehavior" name="SimpleService">
<endpoint address="" binding="basicHttpBinding" contract="ISimpleService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
When I run service hosted on http://projects.mydomain.com/application/SimpleService.svc it shows default service page with link to WSDL:
svcutil.exe http://terminal.mydomain.local/application/SimpleService.svc?wsdl and so on
Clients can create service reference but fail to execute methods because cannot resolve host name terminal.mydomain.local
The question is why server name is its local name 'terminal.mydomain.local' instead of 'projects.mydomain.com' ?
I found answer: http://forums.asp.net/p/1096811/1659596.aspx
I needed to change host headers.

WCF MetaData not working

I have tried several times to have my WCF service expose MetaData. Instead, I keep keeping the exception:
The contract name 'IMetadataExchange'
could not be found in the list of
contracts implemented by the service
SecurityBroker. Add a ServiceMetadataBehavior to the
configuration file or to the
ServiceHost directly to enable support
for this contract.
... when manually browsing to the service using IE.
(I am presuming this is the same reason why my client application isn't able to generate a service reference. Baby steps and all)
And yet my web.config looks okay:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="webHttpEnablingBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="webHttpEnablingBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="IWW.MIGTurbo2.WCF.Security.SecurityBroker">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="default"
contract="IWW.MIGTurbo2.WCF.Security.ISecurityBroker"
behaviorConfiguration="webHttpEnablingBehaviour">
</endpoint>
</service>
</services>
<client />
<bindings>
<webHttpBinding>
<binding name="default" />
</webHttpBinding>
</bindings>
</system.serviceModel>
So I have my IMetadataExchange contract defined with mex fine, and hooked up, as far as I can see. Have I missed something daft?
Edit
My Service definition is shown below, if this is useful:
<%# ServiceHost Language="C#" Debug="true" Service="IWW.MIGTurbo2.WCF.Security.SecurityBroker" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
Your config file has the behaviorConfiguration attribute on the "endpoint" element, but you also need it on the "service" element.
I am using NetTcpBinding for all. In my case I was having the same issue and resolved it by adding:
(a) a behaviorConfiguration="" to the mex endpoint
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" behaviourConfiguration="" />
(b) a behaviorConfiguration="mex" to the service definition:
<services>
<service name="AcmeService" behaviorConfiguration="mex">
(c) The behaviour entry
<behaviors>
<serviceBehaviors>
<behaviour name="mex">
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>