I am struggling to display metadata while using WCF.
I have looked all over the place. I'm not sure if it is a setting in my web.config file, or my actual service is not working properly. But I get the "Metadata publishing for this service is currently disabled." page when I debug.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="myWebHttp"/>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="EDSCoastmap">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
<behavior name="jsonWebHttp">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="EDSCoastmap" name="EDS_CoastmapRest.EDSCoastmap">
<endpoint behaviorConfiguration="webHttp" binding="webHttpBinding"
bindingConfiguration="myWebHttp" contract="EDS_CoastmapRest.IEDSCoastmap" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
</configuration>
Your service doesn't have SOAP endpoint so there are no valid metadata to be exposed. You don't need neither serviceMetadata behavior or MEX endpoint if you don't have SOAP service.
Btw. how do you debug the service?
Related
I am using .NET 3.5 framework and I have large amount of parameters passing to my wcf:
Is there any configuration I can set either in the web.config or IIS?
http://localhost:61819/Services/IRAWorkLoad.svc/GetDLNs?sEcho=1&iColumns=23&sColumns=%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C&iDisplayStart=0&iDisplayLength=100&mDataProp_0=0&sSearch_0=&bRegex_0=false&bSearchable_0=true&bSortable_0=true&mDataProp_1=1&sSearch_1=&bRegex_1=false&bSearchable_1=true&bSortable_1=true&mDataProp_2=2&sSearch_2=&bRegex_2=false&bSearchable_2=true&bSortable_2=true&mDataProp_3=3&sSearch_3=&bRegex_3=false&bSearchable_3=true&bSortable_3=true&mDataProp_4=4&sSearch_4=&bRegex_4=false&bSearchable_4=true&bSortable_4=true&mDataProp_5=5&sSearch_5=&bRegex_5=false&bSearchable_5=true&bSortable_5=true&mDataProp_6=6&sSearch_6=&bRegex_6=false&bSearchable_6=true&bSortable_6=true&mDataProp_7=7&sSearch_7=&bRegex_7=false&bSearchable_7=true&bSortable_7=true&mDataProp_8=8&sSearch_8=&bRegex_8=false&bSearchable_8=true&bSortable_8=true&mDataProp_9=9&sSearch_9=&bRegex_9=false&bSearchable_9=true&bSortable_9=true&mDataProp_10=10&sSearch_10=&bRegex_10=false&bSearchable_10=true&bSortable_10=true&mDataProp_11=11&sSearch_11=&bRegex_11=false&bSearchable_11=true&bSortable_11=true&mDataProp_12=12&sSearch_12=&bRegex_12=false&bSearchable_12=true&bSortable_12=true&mDataProp_13=13&sSearch_13=&bRegex_13=false&bSearchable_13=true&bSortable_13=true&mDataProp_14=14&sSearch_14=&bRegex_14=false&bSearchable_14=true&bSortable_14=true&mDataProp_15=15&sSearch_15=&bRegex_15=false&bSearchable_15=true&bSortable_15=true&mDataProp_16=16&sSearch_16=&bRegex_16=false&bSearchable_16=true&bSortable_16=true&mDataProp_17=17&sSearch_17=&bRegex_17=false&bSearchable_17=true&bSortable_17=true&mDataProp_18=18&sSearch_18=&bRegex_18=false&bSearchable_18=true&bSortable_18=true&mDataProp_19=19&sSearch_19=&bRegex_19=false&bSearchable_19=true&bSortable_19=true&mDataProp_20=20&sSearch_20=&bRegex_20=false&bSearchable_20=true&bSortable_20=true&mDataProp_21=21&sSearch_21=&bRegex_21=false&bSearchable_21=true&bSortable_21=true&mDataProp_22=22&sSearch_22=&bRegex_22=false&bSearchable_22=true&bSortable_22=true&sSearch=&bRegex=false&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&assignType=1
My web.config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Treasury.IRS.HCTC.IRAWorkload.Web.Services.IRAWorkLoadAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="Treasury.IRS.HCTC.IRAWorkload.Web.Services.IRAWorkLoad">
<endpoint address="" behaviorConfiguration="Treasury.IRS.HCTC.IRAWorkload.Web.Services.IRAWorkLoadAspNetAjaxBehavior"
binding="webHttpBinding" contract="Treasury.IRS.HCTC.IRAWorkload.Web.Services.IRAWorkLoad" />
</service>
</services>
</system.serviceModel>
I am deploying a WCF Service to IIS 7 and when I navigate to the service URL I get a page like this:
I do not get the typical landing page like this (copied from the web just to show example, data blurred to protect the innocent):
Can someone tell me what I am doing wrong? The service works as expected but there is nothing for a user of this service to view to know what the methods are or where to get the WSDL.
Here are my relevant files:
App.Config (in service project and copied to service site as Web.Config for IIS)
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<services>
<service name="MyService.MyService" behaviorConfiguration="Web">
<clear />
<endpoint address=""
binding="wsHttpBinding"
name="ws"
behaviorConfiguration="Web"
contract="MyService.IMyService" />
<!--
<endpoint address=""
behaviorConfiguration="Web"
binding="webHttpBinding"
bindingConfiguration=""
name="web"
contract="MyService.IMyService" />
-->
<host>
<baseAddresses>
<add baseAddress="http://services.mydomain.com/MyService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Web">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
MyService.svc
<%# ServiceHost Service="MyService.MyService"
Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
I also tried using 'webHttpBinding' instead of 'wsHttpBinding' and it didn't seem to make a difference.
ServiceHost Service="MyService.MyService" ... is this line correct?
what is the "behaviorConfiguration" attribute of service?
<services>
<service name="WcfServiceNetMSMQ.Service1" behaviorConfiguration="WcfServiceNetMSMQ.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8010/WcfServiceNetMSMQ/Service1/" />
</baseAddresses>
</host>
<endpoint address ="net.msmq://localhost/private/myqueue" binding="netMsmqBinding" contract="WcfServiceNetMSMQ.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
There are 3 important sections when you configure a WCF service.
1) Defining the Services:
<services>
<service behaviorConfiguration="SOAPRESTDemoBehavior" name="SOAPRESTDemo">
<endpoint address="rest" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" binding="webHttpBinding" contract="ISOAPRESTDemo" />
<endpoint address="soap" binding="basicHttpBinding" contract="ISOAPRESTDemo" />
</service>
</services>
NOTE the value of behaviorConfiguration is a reference to a section further on in the config see below...
2) Defining the 'Service Behaviours'
<serviceBehaviors>
<behavior name="SOAPRESTDemoBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
3) Defining the 'Endpoint Behaviours'
<endpointBehaviors>
<behavior name="SOAPRESTDemoEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
All 3 sections are the basics for what you need to set up a service (although this can be done programatically).
With regard to your question the behaviorConfiguration section relates to point 2 and 3 in my points above. Its where you lay out the sort of actions you want your service to have. for example above I have said that I want to allow MetaData to be published. This will essentially create a WSDL which describes the service.
The full config is here:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<!--Set up the service-->
<services>
<service behaviorConfiguration="SOAPRESTDemoBehavior" name="SOAPRESTDemo">
<endpoint address="rest" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" binding="webHttpBinding" contract="ISOAPRESTDemo" />
<endpoint address="soap" binding="basicHttpBinding" contract="ISOAPRESTDemo" />
</service>
</services>
<!--Define the behaviours-->
<behaviors>
<serviceBehaviors>
<behavior name="SOAPRESTDemoBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SOAPRESTDemoEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
It is a reference to another configuration section:
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceNetMSMQ.Service1Behavior">
</behaviors>
</serviceBehaviors>
</behaviors>
Where this section contains some global configuration for the whole service.
here's an example of it, it carries some properties of the connection of the service.
<serviceBehaviors>
<behavior name="WcfServiceNetMSMQ.Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
Notice that the name in this service behavior corresponds to the one you specified earlier.
Hope that helps.
You will get this error with Behavior name is not setup correctly.
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'http://blabla.com/WebService/Processor.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service 'http://blabla.com/WebService/Processor.svc'. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
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>
I have a self-hosted server (Windows service) that is supporting both SOAP/RPC (this may go away in the future) and REST. The RESTful GETs are working as expected, but PUT/POST are giving a 405 error (Method Not Supported). I'm pretty sure this is a configuration issue with my app.config, but I'm pretty new to this and am not sure what to try.
Below is my config file. Any help would be greately appreciated...
<system.serviceModel>
<!-- bindings -->
<bindings>
<basicHttpBinding>
<binding name ="soapBinding">
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webBinding" />
</webHttpBinding>
</bindings>
<!-- behaviors -->
<behaviors>
<endpointBehaviors>
<!-- plain old XML -->
<behavior name="poxBehavior">
<webHttp/>
</behavior>
<!-- JSON -->
<behavior name="jsonBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DSServerBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- services -->
<services>
<service behaviorConfiguration="DSServerBehavior" name="dsServer.DSServer">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/DecisionSupportServer" />
</baseAddresses>
</host>
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="soapBinding"
contract="dsServer.IDSServer" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<endpoint address="rest"
binding="webHttpBinding"
bindingConfiguration="webBinding"
behaviorConfiguration="poxBehavior"
contract="dsServer.IDSServer" />
</service>
</services>
</system.serviceModel>
I double-checked this using CURL and made a small change to my client. This was straight User Error. :(