this is my first project in developing web service.
Its existing application. My project is classlibrary ..to this we added webservice.svc..
To see webservice wsdl ..what are the steps..? how to publish service in IIS.
please can anyone suggest me..
when i publish website i should publish as web deploy?
i tried to publish as webdeploy.. before that i created web site in IIS and tried to publish to hosted site in IIS ..publish succeed.. when i browse the service am getting below error, what does it mean..please help me..
provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
copied my web config file..
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
I fixed my issue. Service Host service name not matching.. i tried to add test WCh service and compare .svc file..
fixed and running in IIS to..
Related
I'm trying to get the simplest WCF Service Application to work with net.tcp and it's not working. Using VS2022, if I create a new project and select the WCF Service Application Template, the new project opens with a Web.config file, Service1.svc file and a IService.svc.
The Web.config looks like this,
<?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>
<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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
If I run this sample project it loads the WCF Test client and shows the service running with the BasicHttpBinding. Perfect.
If I change the binding in the config file from <add binding="basicHttpsBinding" scheme="https" /> to <add binding="wsHttpBinding" scheme="http" /> and run the project, the WCF Test Client shows the WSHttpBinding. Great! Now if I change the binding in the config file from <add binding="wsHttpBinding" scheme="http" /> to <add binding="netTcpBinding" scheme="net.tcp" /> and run the project, the WCF Test Client shows the service running with the BasicHttpBinding. THERE'S NOT EVEN A BasicHttpBinding BINDING IN THE CONFIG FILE!!!!! WHERE THE HELL IS IT GETTING THAT FROM? I've been trying for days to netTcpBinding to work and no matter I do, nothing works. I figured I'd try the simplest thing I could do, which was start with a fresh blank project and make the simplest change, and still no luck. What am I missing. I can find nearly no information on getting this work.
First you have to understand the meaning of <protocolMapping>. The configuration in shows the default protocol mapping in the machine.config file.
You need to override this default mapping at the machine level by
modifying the machine.config file. Alternatively, if you just want to
override it application-wide, you can override this section in the
application configuration file and change the mapping for the
individual protocol schemes.
More generally, the HTTP system-provided bindings such as wsHttpBinding and basicHttpBinding are configured to turn things on by
default, whereas the netTcpBinding binding turns things off by default so that you have to opt-in to get support, for example, for one of the WS-* specifications.
You need to modify the configuration file, you can see how <netTcpBinding> is configured. If you host your service on IIS, you need IIS to have net.tcp enabled.
netTcpBinding In WCF Service With IIS Hosting
nettcpbinding
default-nettcpbinding
If you need simple projects to start with, I suggest you start with wcf's beginners tutorial.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/getting-started-tutorial
I'm using a third party library to fetch a collection of items
The API is based on DotNetOpenAuth.
The api call to fetch data works fine when tested through a simple console application.
However, My goal is to use this API within a web service.
When I test my Web service, the same API call to fetch data throws an exception:
"Error occurred while sending a direct message or getting the
response."
and the error code is 500 .
I find it strange that the same API call works from a console app but not from a web service call. Help!
the webconfig:
<?xml version="1.0"?>
<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>
<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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</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>
I figured out what was going on.
1) in the API, I was requesting for paged results, and it does not start with 0. It worked when I sent > 1 as the page offset.
2) I should have noticed that underneath this ambiguous error message, a server error code (500) was being returned . 90% of the time it means your sending crap to the server hehe.
problem solved!
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 am having an issue building and deploying WCF Rest services with IIS 7.5. If I open Visual Studio 2010 and create a new project of type "WCF Service Application" and then publish that to IIS it works fine. However, when I try to specify a WebGet Property on the operation contract from the IService.cs interface I get an error.
Interface (from IService.cs):
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "hello/?n={name}")]
Message SayHello(string name);
}
Corresponding Method (from Service.svc):
public Message SayHello(string name) {
return Message.CreateMessage(MessageVersion.None, "*", "Hello "+name+"!");
}
I try to publish this to an IIS application I created (http://localhost/rest/) under my root site (http://localhost/) and the publish works successfully, however when I attempt to visit any page from the browser I get the following error:
Failed to map the path '/rest'.
I also tried changing the UriTemplate to [WebGet(UriTemplate = "rest/hello/?n={name}")] and I get the same error.
I am using the default configuration file from IIS:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I should also mention that I am using an application pool for .NET 4.0.
Please help as I am very puzzled by this.
Thanks in advance!
Jeffrey Kevin Pry
Since no one seemed to be interested in the question :) I figured it out on my own.
It seems that I had to do the following to get it working:
Open Command Prompt (cmd.exe)
cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ (will vary depending on setup)
Execute aspnet_regiis.exe -i
That did the trick. It is all working now. Hopefully I can save someone a few hours or so of Googling.
Thanks,
Jeffrey Kevin Pry
I just created a new WCF Service Application project in VS2010 (Premium), and it works out-of-the-box, but when I opened up the web.config file there are no endpoints present. The application works fine and I can open the address (http://localhost:50639/Service1.svc?wsdl) in a browser and I can see the contract and it all looks fine.
So my question is if the default project has uses a different approach rather then placing the information in the web.config? I can't see anything in the code either.
To show my point this is all that the web.config contains:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
And still this service works and I can both connect and call the default methods (e.g. GetData())
That is not a "different" approach. It is a new approach in WCF 4.0 called simplified configuration. If you create project in .NET 4.0 you will get this simplified mode. If you create project in .NET 3.5 you will get old chatty configuration.