Okay, I've spent the day looking at this error and all of the posts re, but I still can't seem to find where I've gone wrong. I can communicate with the web service find from an external web service client but I cannot browse the .svc file from within VS or from IIS. I'm publishing to a mapped drive on IIS 6 server, .NET 4.0.
Any help would be greatly appreciated.
Web.config
<services>
<service name="BiteSizeLearningWS.TranscriptService">
<endpoint address=""
binding="wsHttpBinding"
contract="BiteSizeLearningWS.iServiceInterface" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
</serviceHostingEnvironment>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" faultExceptionEnabled="false"></standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Service.svc
<%# ServiceHost Service="BiteSizeLearningWS.TranscriptService" %>
IserviceInterface.cs
namespace BiteSizeLearningWS
{
[ServiceContract]
public interface iServiceInterface
...
Solved. My mistake was that the classname that implemented the service interface did not match my service name in my svc file. I didn't realize that they had to match.
I.e.
My service name was:
<%# ServiceHost Service="BiteSizeLearningWS.TranscriptService" %>
But my implementation was:
public class TranscriptServiceLibrary : iServiceInterface
Rather than
public class TranscriptService : iServiceInterface
Sorry, everyone. I obviously didn't include the one file that everyone needed to determine the problem. Thank you for all of your input.
Related
This is my project diagram:
MyWCFService
(...)
web.config
Friends.Implementation
Friends.svc
Friends.svc.cs
Friends.Contract
IFriends.cs
My endpoint of service:
<service behaviorConfiguration="ServiceBehaviour" name="Friends.Implementation.Friends">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="Friends.Contract.IFriends" />
</service>
My question is: How can I call this service? When I had that service in "Service" folder in MyWCFService project, it was easy - just localhost:XX/Services/Friends.svc.
And now, how can I run it, if everything is in separate class libraries?
Regards
You can create a Services folder in your website root and paste the .svc file there, or you can use service activation:
<configuration>
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<add service="Friends.Implementation.Friends"
relativeAddress="Services/Friends.svc"/>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
</configuration>
I'm struggling to have my WCF web service output a wsdl file with no luck so far (it's empty?).
the svc file:
<%# ServiceHost Language="C#" Debug="true" Service="xxx.WCF.SubsetMID" CodeBehind="SubsetMID.svc.cs"
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
%>
the cs file :
namespace xxx.WCF
{
[ServiceContract(Namespace = "SubsetMID")]
public interface ISubsetMID
{
[OperationContract]
[WebInvoke(BodyStyle=WebMessageBodyStyle.Wrapped)]
long[] GetMIDs(Guid guid, int subsetID);
}
[DataContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class SubsetMID : ISubsetMID
{
public long[] GetMIDs(Guid guid, int subsetID)
{
[...]
return returnValue;
}
}
}
My web config file :
<system.serviceModel>
<services>
<service name="xxx.WCF.SubsetMID">
<endpoint address=""
binding="wsHttpBinding"
contract="xxx.WCF.ISubsetMID" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
multipleSiteBindingsEnabled="true"
aspNetCompatibilityEnabled="true"
/>
</system.serviceModel>
I don't get any error when I access the wsd (http://.../SubsetMID.svc?wsdl) but it's just a blank page.
The following is a best guess based on some research I did - I'm not that familiar with RESTful WCF services, so I might be wrong but this should give you a starting point at least.
You didn't specify, but it looks like you're trying to write a RESTful WCF service. I'm not entirely certain, because you use wsHttpBinding in your endpoint, but you also decorate the method in the service with [WebInvoke].
In any event, REST services do not have WSDLs - that's a SOAP thing. Additionally, I believe WCF supports REST with the webHttpBinding. As you are using WebServiceHostFactory in your .svc file, I think this is what is happening:
You do not have any webHttpBinding endpoints defined. WCF will create a default webHttpBinding endpoint, with the address based on the location of the .svc file. However, when default endpoints are used according to WebServiceHost Class:
...the WebServiceHost also disables the HTTP Help page and the Web Services Description Language (WSDL) GET functionality so the metadata endpoint does not interfere with the default HTTP endpoint.
If you're writing a REST service, you won't need a WSDL. If you're planning on having a SOAP service, then use ServiceHostFactory in your .svc file and remove the [WebInvoke] attribute from the method.
Again, this is a (relatively) educated guess, and it may be wrong, but it's a place to start.
Im guessing that you are using a wcf service website project which contains the svc file. if you dont, i strongly recommend you to do that and set it as the startup project in your solution, so you could debug it properly. for me, and good chances that for you too if you followed codeproject step by step instructions, the problem was that i didn't reference the wcf services from the website, thus the directive in the svc couldn't find the service. hope i helped
I am planning to host multiple RESTful services based on different contracts. There are a lot of similar questions but my web.config file looks different, I don't know why.
Here is part of my web.config file :
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name=""
helpEnabled="true"
automaticFormatSelectionEnabled="true">
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
Here is my service declaration in my web application :
RouteTable.Routes.Add(new ServiceRoute("bob/chocolate", new WebServiceHostFactory(), typeof(RESTchocolate)));
RouteTable.Routes.Add(new ServiceRoute("bob/vanilla", new WebServiceHostFactory(), typeof(RESTvanilla)));
Only the first Route seems to be working (tested using the nice "bob/chocolate/help" endpoint feature of .NET to list the methods available) which does not surprises me really, but how should I modify my web.config file ? Does any of you know how to do this ? Do I need to modify something else ?
For those wondering, my contracts are valid.
I get "Endpoint not found" in a nice .NET display if I try to reach the second endpoint in my browser.
EDIT :
I added the following node to my config file...
<services>
<service name="chocolate">
<endpoint address="bob/chocolate" binding="basicHttpBinding" name="chocolate" contract="RESTapi.IRESTchocolate" />
</service>
<service name="vanilla">
<endpoint address="bob/vanilla" binding="basicHttpBinding" name="vanilla" contract="RESTapi.IRESTvanilla" />
</service>
</services>
But I get the same behaviour. The problem is still here
EDIT : and here is my complete config file as requested (without the node above) :
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="None"></authentication>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
</serviceHostingEnvironment>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I really recommend you install the WCF REST Service Template 40 and take a look at the bootstrap.
Web.config
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
Global.asax
// Edit the base address of Service1 by replacing the "Service1" string below
RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));
I have developed window application and in that i am calling WCF at particular time interval however there is no error in inserting data into database through WCF but in log entry i am getting one error regarding WCF Endpoint as per below
2011-22-09 10:16>>Error: There was no endpoint listening at
myserviceUrl(.svc) that could accept the message. This is often
caused by an incorrect address or SOAP action. See InnerException, if
present, for more details.
app.config file as per below and i guess that probably error should be in below configuration
<client>
<endpoint address="myserviceUrl(.svc)"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
</client>
Below is my (WCF)service's configuration..
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</configSections>
<dataConfiguration defaultDatabase="Connectionstr"/>
<connectionStrings>
<add name="Connectionstr" connectionString="myconnectionstring"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Please help me to sort out of this issues.
Thanks.
You need to make sure that the endpoint is configured at the service side, not just your client. In other words, if the client uses myserviceUrl(.svc), the address needs to be specified in the service's config file.
Based on the error message you got, try this in the service's config file:
<endpoint address="myserviceUrl(.svc)"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
Note that you'll need to ensure your service has the appropriate binding section named "BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF".
If you need a more thorough example, post your service's config file and we'll help you out.
UPDATE
Add an endpoint section, and a binding section if you have any values set to other than the default values:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="myServiceName">
<endpoint address="myserviceUrl(.svc)"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"/>
<endpoint name="mexHttpBinding"
contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
</basicHttpBinding>
</bindings>
In the <binding name="" section is where you'd set the values for the binding. If you don't do this (and don't specify the section in the endpoint's bindingConfiguration attribute) WCF will use the default values for basicHttpBinding.
NOTE: With WCF 4.0 and later, you actually don't need to specify an endpoint (or create a .svc file if hosting under IIS), as WCF will supply a default endpoint based on the URI of the service. See A Developer's Introduction to Windows Communication Foundation 4 for details on this and other new features in 4.0.
You need to specify in address attribute the whole virtual path
for example http://localhost/yousite/myservice.svc
I am trying to use the configuration file to define endpoint and services information. I have a very simple code that contain OneWay service and a Duplex service. The OneWay worked when I haven't try to alter the configuration file.
Now, I want to use the configuration file to define both service.
Service1 contract name is IOneWayService and the Service2 contract name is ICallBackService.
Both have implemented code in their concrete respective classes name OneWayService.svc.cs and CallBackService.svc.cs.
The configuration file at this moment look like that :
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="OneWayService.svc" service="TestingWcf.OneWayService"/>
<add relativeAddress="CallBackService.svc" service="TestingWcf.CallBackService"/>
</serviceActivations>
</serviceHostingEnvironment>
<services>
<service name="TestingWcf.OneWayService">
<endpoint address="http://localhost:60847/One"
binding="wsHttpBinding"
contract="IOneWayService" />
</service>
<service name="TestingWcf.CallBackService">
<endpoint address="http://localhost:60847/Two"
binding="wsHttpBinding"
contract="IDuplexService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I always have this error when trying to execute the OneWayService via this url : http://localhost:60847/OneWayService.svc
The contract name 'IOneWayService'
could not be found in the list of
contracts implemented by the service
'OneWayService'.
Anybody have an idea why?
Edit
I have removed the multipleSiteBindingsEnabled= true from the servinceHostingEnvironment tag and in the contract added the namespace and I could runt the OneWayService.
Also, the Duplex cannot be bound to the wsHttpBinding. I had to change it to NetTcpBinding. But, I had an other error with the Duplex :
Configuration binding extension
'system.serviceModel/bindings/NetTcpBinding'
could not be found. Verify that this
binding extension is properly
registered in
system.serviceModel/extensions/bindingExtensions
and that it is spelled correctly.
From this point, I am lost again.
Edit 2
I did an error in the binding name. I had a capital letter for NetTcpBinding and it does require a lowercase: netTcpBinding. However, it's still not working, now I have:
The protocol 'net.tcp' is not
supported. >.< !!!
OK, that explains it - Visual Studio by default uses the built-in Cassini web server (unless you've already switched to using IIS Express) - and that server doesn't support anything but plain http.
Cassini doesn't support net.tcp and anything like that.
You will need to start using a separate IIS virtual directory and first enable all the necessary support stuff (in the Add/remove Windows Features dialog)