IIS do not see WCF service - wcf

I have AjaxDataService.svc placed in my root directory.
Since the root folder has its content deployed automatically i se no reason why there should be anything missing.
Only thing that comes to mind is having a bad .config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WashMyCarHomepage.AjaxEntityService">
<endpoint address="" binding="webHttpBinding" contract="WashMyCarHomepage.IAjaxEntityService" behaviorConfiguration="JsonBehavior" />
<host>
<baseAddresses>
<add baseAddress="http://sub.project.com" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
It runs smoothly on localhost. Also the rest of the application runs as expected.
edit:
Could someone list possible reasons?

Related

WCF service with multiple webHttpBinding bindings fails in visual studio test client

I have a service with four endpoints defined, the configuration looks like this:
<service name="Systembolaget.Services.ButikService" behaviorConfiguration="default">
<endpoint
address="xml"
binding="webHttpBinding"
behaviorConfiguration="xml"
contract="Systembolaget.Contracts.Butiker.IButikService" />
<endpoint
address="json"
binding="webHttpBinding"
behaviorConfiguration="json"
contract="Systembolaget.Contracts.Butiker.IButikService" />
<endpoint
address="soap"
binding="basicHttpBinding"
contract="Systembolaget.Contracts.Butiker.IButikService"
bindingConfiguration="default"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
<behaviors>
<endpointBehaviors>
<behavior name="xml">
<webHttp defaultOutgoingResponseFormat="Xml" defaultBodyStyle="Bare"></webHttp>
</behavior>
<behavior name="json">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Bare"></webHttp>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
When using the service with any of the end points it all works fine. However I can't use the test client in Visual Studio 2012 if both the xml and the json end point exists. If I comment out one or the other, the client works, if I keep both in the config file I get the following error:
Error: Cannot obtain Metadata from http://localhost:52832/VarugruppService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
URI: http://localhost:52832/VarugruppService.svc
Metadata contains a reference that cannot be resolved: http://localhost:52832/VarugruppService.svc.
There was no endpoint listening at http://localhost:52832/VarugruppService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.HTTP GET Error
URI: http://localhost:52832/VarugruppService.svc
There was an error downloading 'http://localhost:52832/VarugruppService.svc'.
The request failed with HTTP status 404: Not Found.
Any ideas?
You can achieve this by adding a separate binding configuration for each webHttpBindng:
<bindings>
<webHttpBinding>
<binding name="xmlWebBinding">
</binding>
<binding name="jsonWebBinding">
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="Systembolaget.Services.ButikService" behaviorConfiguration="default">
<endpoint
address="xml"
binding="webHttpBinding"
bindingConfiguration="xmlWebBinding"
behaviorConfiguration="xml"
contract="Systembolaget.Contracts.Butiker.IButikService" />
<endpoint
address="json"
binding="webHttpBinding"
bindingConfiguration="jsonWebBinding"
behaviorConfiguration="json"
contract="Systembolaget.Contracts.Butiker.IButikService" />
<endpoint
address="soap"
binding="basicHttpBinding"
contract="Systembolaget.Contracts.Butiker.IButikService"
bindingConfiguration="default"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="xml">
<webHttp defaultOutgoingResponseFormat="Xml" defaultBodyStyle="Bare"></webHttp>
</behavior>
<behavior name="json">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Bare"></webHttp>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Credit to the answerer at the bottom of this forum:
http://tiku.io/questions/1554725/how-can-basichttpbinding-webhttpbinding-mexhttpbinding-endpoints-coexist-in-o

What do I need to change in web config for deploying WCF service on IIS

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webScriptEndpoint>
<standardEndpoint name="" crossDomainScriptAccessEnabled="true" />
</webScriptEndpoint>
</standardEndpoints>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" binding="webHttpBinding" contract="IService" behaviorConfiguration="EndpBehavior"/>
</service>
</services>
</system.serviceModel>
What do I need to change in web config after deploying my WCF service on IIS?
My code is running with two projects.
Your service and contract name should be a fully qualified names.
check this

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.

what is the "behaviorConfiguration" attribute of service?

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.

PUT/POST not working in self-hosted WCF REST configuration

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. :(