I have a WCF Service Application project in Visual Studio that contains the following files
ZooWebService.svc
WebConfig
I attempted to host the Web Service in IIS but when i browse to my web service from IIS the Web Service does not load at all. It just says "loading" in the browser.
Here is my WebConfig file:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="Default"
name="WCFWebService.ZooWCFService">
<endpoint address="" binding="basicHttpBinding"
contract="WCFWebService.IZooWCFService" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I did the following so what have i done wrong?
Open IIS
Right clicked on Default Website
Selected "Add Application"
Populated "Alias" field
Populated "Physical Path" to directory of where the solution contents are
Clicked OK
Rebuilt the solution in Visual Studio
We don’t need to specify the base address in the configuration file which needs to be set up in the web site binding module.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
then we should enable the WCF feature in the IIS.
At last we could see the web service description in http://ip:port/xxxx.svc.
Feel free to let me know if there is anything I can help with.
For enabling the WCF in IIS, you may have to enable the HTTP activation feature for the .net framework first.
Some of links to do this
https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-326D6F7B-08EC-43EB-A5A7-9C51DD9E555C
https://pubs.vmware.com/mirage-56/index.jsp?topic=%2Fcom.vmware.mirage.api.pg.doc%2FGUID-552D845B-E530-4898-A06B-4F73E668BEFF.html
Once this is done you may try to deploy WCF directly from the visual studio to your local IIS>
Right click on the WCFproject -> go to properties -> in properties window -> select web tab -> in servers section select Local IIS and click on Create Virtual Directory.
Now run the WCF from Visual studio, this will host the WCF in local IIS.
Related
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.
I have a sweet WinForm application (on my computer) and a SQL Server database (on server X). I'm using SqlConnection and everything works fine.
But not I want to change it and use WCF or other technologies to connect and switch information between my app and database.
I also have one more server to use as application server (Server Y).
I've started using WCF: created project, created installer.
Uploaded it on my Y server and installed it. Service started, also I've added Service Reference to my WinForm app, but the ServiceClient is not working properly.
When I call ServiceClient's method it throws exception:
An exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll but was not handled in user code
Additional information: There was no endpoint listening at http://localhost:41272/service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
As I guess my endpoint is blowing things up.
So I want you guys help me how to configure SQL endpoint.
Here is my WCF's web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SampleSvcBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SampleSvcBehavior"
name="FMG_WCF.FmgService">
<endpoint name="SampleSvcBasicHttpEndPoint"
address=""
binding="basicHttpBinding" bindingConfiguration=""
contract="FMG_WCF.IFmgService" />
<endpoint name="SampleSvcMexHttpEndPoint"
address="mex"
binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:41272/service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
This error is not related with SQL endpoint. In facts you do not need endpoints for connecting WCF to database. Here is your answer in another post.
EndpointNotFoundException - 404 - Hosting WCF Service over HTTPS in IIS through Visual Studio
You have two options, if the service has been modified from when you created it you can simply right click on the service reference and configure the service reference. In the popup you can change the Url to point to serverX and you service reference and config file will be automatically updated.
If no changes were made to the service, for example your binding type or security then simply updating the Url in the config file should be enough.
This is a WCF REST service. The service works perfectly fine on my dev machine.
I have the service files in a subfolder of wwwroot called Services\
Admittedly I'm well versed at writing code, but no so well versed at using IIS to host/publish we services.
What I attempted to do was just copy the Services folder from my dev laptop to the server's wwwroot folder.
When this happens and I try to access the service on the server I get some strange error that I don't understand (well I sort of understand it just don't know why it's happening)
"The type 'BooksService.Service1', provided as the Service attribute value in the ServiceHost directive, or profided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found."
Service1.cs looks like so in my project:
namespace BooksService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IDataService
A decent portion of my web.config is based on google recommendations so it's probable I may not understand something or just have it plain wrong.
Web.Config looks like:
***<?xml version="1.0"?>
<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="BooksService.Service1">
<endpoint address="" binding="webHttpBinding" contract="BooksService.IDataService" behaviorConfiguration="restfulBehavior"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/bookservice" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>***
My service file looks like this:
<% #ServiceHost Service="BooksService.Service1" %>
Then there is a bin folder which contains my .dll
So the folder layout is as follows:
c:\inetpub\wwwroot\SERVICES\BookService\bin
Where service.svc is in the BookService folder and the assembly is in the bin folder.
What step(s) might I be missing?
First, you need to create an application in IIS and point the virtual directory to your application folder: c:\inetpub\wwwroot\SERVICES\BookService.
Then you need to update your service base address accordingly:
<baseAddresses>
<add baseAddress="http://localhost/services/bookservice" />
</baseAddresses>
You can test the url by typing it in your browser and browsing to the service location.
Im trying to publish my web services using IIS and there seems to be a problem with my web.config. I want to ultimatly publish my web services to a web host I have. I allready tried publishing the normal file system and uploading thos files to the webhost but I cant seem to get my service.svc to respond. Im thinking its because of my web.config here is the code. If you need anything else of my code please ask :D. Just as a note. The services work just fine when I run them with Visual Studio 2012. Also Im new at this, this is the first time I try to do this. :D
Web.config
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="HotelLock.Service1">
<endpoint binding="webHttpBinding" contract="HotelLock.IService1" behaviorConfiguration="web">
</endpoint>
</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>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" >
</serviceHostingEnvironment>
</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>
I uploaded the svc, the web.config and the bin with the dll to a host I have and all I get when I call the svc is
ServiceHost Language="C#" Debug="true" Service="HotelLock.Service1" CodeBehind="Service1.svc.cs"
I cant seem to call any of the other urls.
When I tried to use the IIS to use my service as localhost, the page does not load. I allready gave permition for the iis to use the webconfig. But I cant seem to get a normal error. I just cant load anything.
The config file looks OK. Maybe you should check the link that you call through the browser. The link should be like the following one:
http://www.yourdomain.com/ServiceName.ClassName.svc/UriTemplate
For your project, I think service name is HotelLock and the classname is Service1. I don't know the UriTemplate of your code but your interface (probably IService.cs) should have that information (e.g. [WebGet(UriTemplate = "ListData")]) Finally, your link looks like http://www.yourdomain.com/HotelLock.Service1.svc/ListData
I hope it works.
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!