IIS hosting WCF service error - c#

I am using IIS 7.0 to host a simple WCF service. I write it by using VSTS 2008 + .Net 3.5 + C#. The issue is when I access http://localhost:9999/service.svc (I suppose in web browser we can browse the content of WSDL, and I create a new web site which uses port 9999 and run application pool under administrator account), I am met with the following error, any ideas what is wrong?
http://i27.tinypic.com/a9r8cz.jpg
Here is my service.svc:
<%# ServiceHost Language="C#" Service="Gu.WCF.StudentManagement" %>
Here is my web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="Gu.WCF.ServiceBehavior"
name="Gu.WCF.StudentManagement">
<endpoint address="" binding="basicHttpBinding" contract="Gu.WCF.IStudentManagement">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Gu.WCF.ServiceBehavior">
<!-- 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>
</configuration>

Sounds like the .NET 3.0 ISAPI mappings have vanished. In the .NET 3.0 WCF directory (C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation) run ServiceModelReg -r

Please make sure that you have the .svc extension mapped to the ISAPI handler.

Related

WCF service not running on other devices except server

I have WCF service which runs fine on my server machine using IP, it was working on client side(android studio) but suddenly it stopped working, I tried all solutions from internet but nothing seems to help, Service is sill working on Server browser/Postman.
Here's my web.config file if it is required:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<services>
<service name="WcfService.Service1" behaviorConfiguration="WCFService.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="myWeb" contract="WcfService.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>
<endpointBehaviors>
<behavior name="myWeb">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WCFService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false 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>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Also my Firewall is disabled completely.
When I ping service from mobile or other pc it gives error:
This site can't be reached.
Err_Address_Unreachable
First, can you call the service successfully from the other computer in the same LAN?
Second, what is the IP of your mobile device?
Finally, have you tried to restart your router/switch device in the current LAN? It is possible that there is something wrong with the router device which provides the Addressing function.
Feel free to let me know if there is anything I can help with.
If your computer's firewall is disabled check if your router has firewall and disable it.

call a wcf that is uploaded to a host 404 not found why?

I develop a wcf application ,so it works fine in local pc ,but when i publish it and i upload the published file i couldn't reference that service to my third application .
let me explain that ,the published file is like this :
The config file is like this :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary1.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>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="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>
</configuration>
as you know in webconfig there is http://localhost:8733 and i change it to asp.spadsystem.com but no result.
So i added this reference to my application asp.spadsystem.com/WcfServiceLibrary1.Service1.svc ,but the visual third application can't find the service .
I am so new in wcf.

Adding Service Reference to ASP.NET application

I have searched on here for the exact solution to my problem to no avail.
I have added a Web Service to my project but am unable to reference it. Clicking Discover works fine - the service is available but when it comes to retrieving a list of services at its location the following text appears:
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved:
Metadata contains a reference that cannot be resolved:
'http://localhost:57657/Services/AFDiscovery.svc'.
If the service is defined in the current solution, try building the solution and
adding the service reference again.
How do I fix this? I am attempting to run the service locally so I do not need to add it within IIS.
Web.config information:
<services>
<service name="WebServiceInterface.AFDiscovery">
<endpoint address="" binding="wsHttpBinding" contract="WebServiceInterface.AFDiscovery" />
</service>
</services>
You can add the project containing the WebServiceInterface.AFDiscovery in your solution. Then in the project using the web service, when you add your reference, instead of clicking "Discover", use the load from project option.
If you want to load the reference via a URL (Discover button), try browsing to "http://localhost:57657/Services/AFDiscovery.svc?WSDL" in your browser. If you get a message saying the metadata isn't accessible, you must modify your web service web.config.
Check this link for configuring the web.config: http://msdn.microsoft.com/en-us/library/aa751951.aspx
It should look similar to:
<configuration>
<system.serviceModel>
<services>
<service
name="WebServiceInterface.AFDiscovery"
behaviorConfiguration="SimpleServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="WebServiceInterface.IAFDiscovery" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
One of the possibility is the service name in your Web.config does not
match the namespace in your class file.Make sure the names are the
same then try again.
Refer
And double Check your Service MarkUp code by reghclick and Choose MarkUp

Client cannot connect host WCF service only if the service running from windows services

Continue with this post
I created WCF Project host service on my machine from this tutorial:
http://www.aspdotnet-suresh.com/2011/06/introduction-to-wcf-wcf-tutorial-wcf.html
After my WCF service run on my machine i cannot connect with my client to my service and received EndPointNotFoundException (this happen from local and from remote machines) and this is not the case if my service running through visual studio.
what could cause this error ?
App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WCFService.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="WCFService.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>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="False"/>
<!-- 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>
</configuration>
You should run Service under administrator privileges. Windows services already have that's why you can run it without problem.

cosume a WCF windows service from another PC

I have created a WCF service and hosted it in a windows service. Testing this service with visual studio works fine and I can consume it. Now I have installed the service on a PC (called PC1) and using another PC (called PC2) I wish to be able to discover it and consume it. I imagine that I will have to modify the app.config file to achieve this.
Here is my current app.config, what do I need to modify to get this to work from other networked computers? I'm guessing the base address is a start?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfAVOLibrary.AVOs">
<endpoint address="" binding="wsDualHttpBinding" contract="WcfAVOLibrary.IAVOs">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false 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>
</configuration>
oh and i'm running .Net 4.5
(if the web service is not implemented, I recommend this link
http://www.codeproject.com/Articles/28693/Deploying-ASP-NET-Websites-on-IIS-7-0)
You should try to modify the web.config in this place:
<baseAddresses>
<add baseAddress="http://192.168.1.2/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
</baseAddresses>
where 192.168.1.2 is your current ip, or localhost works too, it would see like this:
<baseAddresses>
<add baseAddress="http://localhost/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
</baseAddresses>
At first place, change localhost by pc1 on base address, like
http://pc1:8733/Design_Time_Addresses/WcfAVOLibrary/AVOs/
After it, try to open the base address url from browser on pc2 (yes, never mind that it is win. service - this is your service url and should be accessible). It should be ok, you need not to continue before you get it work.
When it done - review client's config to match service address.
Was facing the same issue. Added inbound rule to open the port 8733 in Windows Firewall. It worked!

Categories