Absolute path is not working for WCF Service - wcf

I have a service file available in the following location.
C:\Documents and Settings\U16990\My Documents\Visual Studio 2010\Projects\CalculationService\CalculationService\CalculationService.svc
When I browse the svc file, it is working fine. The service endpoint is as listed below. It is currently a relative address used for address.
<service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="CalculationService" behaviorConfiguration=""
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CalculationServiceInterface"
contract="ICalculationService" />
</service>
IP address of my machine is 10.10.179.180 //InterNetwork AddressFamily
When I change the address to use absolute path it is throwing error:
<services>
<service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint
address="http://10.10.179.180/C:/Documents and Settings/U16990/My Documents/Visual Studio 2010/Projects/CalculationService/CalculationService/CalculationService.svc/CalculationService"
behaviorConfiguration=""
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CalculationServiceInterface"
contract="ICalculationService" />
</service>
</services>
Error:: No protocol binding matches the given address 'http://10.10.179.180/C:/Documents and Settings/U16990/My Documents/Visual Studio 2010/Projects/CalculationService/CalculationService/CalculationService.svc/CalculationService'. Protocol bindings are configured at the Site level in IIS or WAS configuration.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
What can we do to correct it?
Note: I am testing the service with Visual Studio 2010.
Reference:
Hosting a Simple Wcf Service in Console
error "No protocol binding matches the given address ..."
How to derive a website absolute file path from a WCF service hosted in IIS?

An endpoint address is not a location of a file, but the URI at which the client can/will find the service. You should probably use something like this:
<service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint
address="http://10.10.179.180/CalculationService/CalculationService.svc"
behaviorConfiguration="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_CalculationServiceInterface"
contract="ICalculationService" />
</service>
In this case you're using a full URI instead of a relative one. In your client you must make sure that the endpoint refers to the same address, and you're good to go.

Related

WCF failing when service is impleneted over HTTP AND HTTPS

<system.serviceModel>
<services>
<service name="foo">
<endpoint address="" behaviorConfiguration="testbehaviour" binding="webHttpBinding" contract="testcontact" bindingConfiguration="webBinding" />
<endpoint address="" behaviorConfiguration="testbehaviour" binding="webHttpBinding" contract="testcontact" bindingConfiguration="webBindingHttps" />
</service>
</services>
<system.serviceModel>
As shown in the the web.config extract above, on our windows server 2008 machines, we had one endpoint that could be reached over HTTP and HTTPS.
I have just done an install of server 2012 (with iis8), and I now get the message
"Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http]."
The very odd thing is - if I comment one endpoint element out (leaving just one active endpoint left), then the remaining endpoint will work fine?
I had set the site up in IIS wrongly - I had created a separate website for the HTTP version and one for the HTTPS version, when infact they should be the same website, but with HTTPS and HTTP bindings

wcf endpoint relative address

I'm just learning wcf and can't understand one very basic thing.
I'm creating a WCF service which I want to be hosted in IIS just like web application with it's own path like http://myhost/myapp/ and everything.
I'm creating the WCF service project in VS, I've got an *.svc file describing it, then I define a simple endpoint to it like that:
<endpoint address=""
binding="basicHttpBinding"
contract="wcf_service_auth.IPshService" />
Then I publish this service like an IIS web application to a virtual directory, let's assume it's name psh_pub, so I can access the service via url http://localhost/psh_pub/pshservice.svc/. It shows me WCF greetings page and gives me a link to WSDL, which gives me correct wsdl description.
That's ok.
The next step - I want to add a MEX endpoint. I add to config:
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
That's ok too, the endpoint is accessible at address http://localhost/psh_pub/pshservice.svc/mex and WcfTestClient.exe gives me correct config from that url.
Here the problem comes.
I have a WCF service working under IIS and I want to add one more endpoint to it. For example let it be a net.tcp endpoint. The IIS is configured by default to accept net.tcp connections at port 808 and I'm adding net.tcp protocol to properties of my web app, and I want to add an endpoint to my service like that:
<endpoint address=""
binding="netTcpBinding"
contract="wcf_service_auth.IPshService" />
and now I assume that my service should be accessible via the url net.tcp://localhost:808/psh_pub/pshservice.svc. But it's not. And every "how-to" and manual on the web tells that I should specify full address in the config file like that:
<endpoint address="net.tcp://localhost:808/psh_pub/pshservice.svc"
binding="netTcpBinding"
contract="wcf_service_auth.IPshService" />
And if I do so, it works. But if host the service in another virtual directory, I'll need to change the config. If I host it on the other server, I'll need to change config. If I host it on multiple servers, I'll have to maintain as many configs as servers I have.
So the main questions is:
Is there any way in WCF to specify a net.tcp (or https) endpoint of a IIS-hosted WCF service without specifying absolute url for it?
You should be able to define a base address for your net.tcp service endpoints:
<service name="YourServiceName">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:808/psh_pub/" />
</baseAddresses>
</host>
Then you should be able to use relative addresses in your actual endpoints:
<endpoint name="Tcp01"
address="pshservice.svc"
binding="netTcpBinding"
contract="wcf_service_auth.IPshService" />
</service>
WCF file-less activation (.Net 4.0) will let you register under a relative virtual path using the relativeAddress attribute:
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress="relative-virtual-path/yourservice.svc"
service="YourServiceImpl" />
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
relative to the base address of the Web application
This link talks about it: http://msdn.microsoft.com/en-us/library/ee354381.aspx

What kinds of non-HTTP addresses are allowed in WCF endpoints?

I'm just trying to save time by not learning about IIS and WAS, so I made a console application to host my WCF service. However, that leaves me uncertain as to how to specify an endpoint address that is not an HTTP address. Could the following config be the source of my runtime error? The exception description was: Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [].
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<endpoint
contract="WcfService1.IService1"
binding="wsHttpBinding"
address="c:\users\owner\documents\visual studio 2010\projects\wcftest\wcfservice1\wcfservice1\service1.svc"/endpoint>
</service>
</services>
The word you're looking for is bindings. You change the binding attribute to match a binding that supports your desired protocol. For a simple console service host, I'd probably start with the netTcpBinding, which allows binding to an ipaddress:port combination.
Example:
net.tcp://localhost:8000/myservice

WCF Deployment to IIS 6 Results in 403 Permission Error

I've never deployed a WCF service to IIS 6 before. I've got a service that I'm deploying to IIS 6 by using the default configuration as part of the WCF project. I since simplified the configuration thinking that might have been the issue. Here is the error I'm getting if I browse to the service in a browser:
HTTP Error 403.1 - Forbidden: Execute
access is denied.
My configuration now looks like this:
<system.serviceModel>
<services>
<service name="MyCompany.WebServices.MyService">
<endpoint address="" binding="basicHttpBinding" contract="MyCompany.WebServices.IMyService" />
</service>
</services>
</system.serviceModel>
If I try adding it as a reference in ASP.NET MVC, I get the following:
There was an error downloading
'http://ws.mycompany.com/MyService.svc'.
The request failed with HTTP status
403: Forbidden. Metadata contains a
reference that cannot be resolved:
'http://ws.mycompany.com/MyService.svc'.
The HTTP request was forbidden with
client authentication scheme
'Anonymous'. The remote server
returned an error: (403) Forbidden. If
the service is defined in the current
solution, try building the solution
and adding the service reference
again.
Any ideas what might be going on?
UPDATED:
It appears to be a configuration issue on my IIS 6 box. I'd assume this because I've created a brand new ASP.NET 3.5 WCF Application and deployed it to a new URL at http://ws.unitedoneresources.com/Service1.svc. If I try to call that service, I get the same HTTP Error listed above. The entire service configuration is the following:
<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Again, this is a brand new ASP.NET 3.5 WCF Application so I haven't modified anything on the project itself.
I wacked the I wacked the website, installed WCF on IIS 6 (using ServiceModelReg.exe /i /x at a command prompt), and redeployed. It worked!
Thanks!
Found this question searching for a solution to the same problem. I had forgotten to changes permissions to 'Scripts and Executables' on the services directory. I was on II7
You don't really give us a lot to go on here - what's missing are the server side configuration bits that show us how you set up security - can you please update your question and show us everything inside the <system.serviceModel> tag on your server side config and on your client calling the server??
Just guessing from the system defaults, using the basicHttpBinding would result in a default security setting of nothing - and it would appear as if your server-side config requires some form of security. It almost seems as if your security settings are out of sync, thus resulting in this error.
Another point is: how did you set up the IIS side? Did you create a virtual directory for your service? Basically, when hosting in IIS, your service URL is determined by server name (plus possibly the port), the virtual directory your *.svc file lives in, and the name and extension of the svc file itself.
We had similar symptoms, but only with PUT and DELETE verbs under IIS 6.0.
By default, the .svc extension within our IIS application was only allowing GET, POST verbs.
Adding the verbs (or allowing all verbs) for the .svc extension for the application fixed the issue.

WCF address does not match what I specify in my web.config

In my web.config, I have specified
<services>
<service name="Querier.WCF.Querier"
behaviorConfiguration="QuerierServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://myserver:8000/SearcherService"/>
</baseAddresses>
</host>
<endpoint address="net.tcp://myserver:9000/SearcherService"
binding="netTcpBinding"
bindingConfiguration="Binding1"
contract="Querier.WCF.IQuerier" />
</service>
</services>
However, the site is not available at http://myserver:8000/SearcherService,
I for some reason have to go to:
http://myserver/SearcherService/SearcherService.svc
(notice the port is missing)
When I go there, it tells me to run
svcutil.exe http://myserver.mycompanyname.com/SearcherService/SearcherService.svc?wsdl
It added a domain name for some reason and when I try to access the service with WCF storm,
I put in http://mymachine/SearcherService/SearcherService.svc, it discovers all the function names fine, but when I try to run one, I get:
There was no endpoint listening at
net.tcp://myserver:9000/SearcherService
that could accept the message. This is
often caused by an incorrect address
or SOAP action. See InnerException, if
present, for more details.
Any ideas as to why my service URL doesn;t match what I specified in the web.config?
NOTE:
I have set nettcp on the app in IIS and enabled the binding on 9000:*
When you host a WCF service in IIS it is IIS and its configuration who decides the base address for your service and you can only specify relative addresses. The baseaddress only applies to self hosted services.