I've been banging my head for a week now, I am trying to run a WCF service on IIS express and do a GET from the browser, everything works fine in HTTP, but the minute I try the HTTPS it fails with
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
I have tried every single config file in stackoverflow answers I also tried this I know it is for IIS but I can't see why it is not working On IIS express. here my config file:
<?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>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="webHttpEnablingBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="webHttpEnablingBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service
name="ElasticSearchAPI.GetElasticService" behaviorConfiguration="webHttpEnablingBehaviour">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="default"
contract="ElasticSearchAPI.IGetElasticService"
behaviorConfiguration="webHttpEnablingBehaviour">
</endpoint>
<endpoint address="other"
binding="basicHttpBinding"
bindingConfiguration="default"
contract="ElasticSearchAPI.IGetElasticService">
</endpoint>
</service>
</services>
<client />
<bindings>
<webHttpBinding>
<binding name="default" ></binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="default" allowCookies="true"></binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<!--
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"/>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
I am sure I am missing something really silly, but I am really out of ideas, your help is much appreciated.
Update
I can get to my .svc with https but when i try a get from a browser or post from fiddler nothing is working
Use ServiceBehaviour like below-
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>
This may help you.
In WCF Service Config file add following :
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
In client application config file add following :
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
This will allow you to host and access WCF service with HTTPS protocol.
Related
We have a simple IIS service just hosting one method via https. The service can be consumed and used w/ SOAPUI and it connects and works just fine. However, we have a client on another network who's consuming our IIS service endpoint and trying to use the service, but the client server is reporting an error:
Could not retrieve the Service Binding
I have no idea what this means exactly and why it works just fine through another network, but fails on another. Does anyone know what I might chase down to solve this error on the failing server. Maybe there's something I need to change in the service, not sure. Thanks.
Here is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_eLink" maxReceivedMessageSize="20000000">
<security mode="Transport" >
<transport clientCredentialType= "None" />
</security>
</binding>
</basicHttpBinding>
<mexHttpsBinding>
<binding name="secureMexBinding" />
</mexHttpsBinding>
</bindings>
<client>
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="eLink.PublishActionWebService">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_eLink"
contract="eLink.IService"/>
<endpoint
address="mex"
binding="mexHttpsBinding"
bindingConfiguration="secureMexBinding"
contract="IMetadataExchange" />
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
I think you need to specify the bindingconfiguration in your <protocolMapping> node since you have a named binding being referenced in your endpoint.
From:
<add binding="basicHttpsBinding" scheme="https" />
to:
<add binding="basicHttpsBinding" scheme="https" bindingConfiguration="basicHttpBinding_eLink" />
I'm working with visual Studio 2015. I have a Xamarin Cross-Platfom's project.
My WCF Rest Service works fine with http. I tried to use HTTPS but I receive a "404 error not found" when I try to access my resource.
You will find below the configs files:
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
<system.serviceModel>
<services>
<service name="PrototypeBHost.PrototypeB" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity"
behaviorConfiguration="restfulBehavior"
contract="PrototypeBHost.IprototypeB" />
<endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSecurity">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpsGetEnabled="true" 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>
<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>
applicationhost.config
<site name="PrototypeBHost" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\Users\Ludovic\Documents\Visual Studio 2015\Projects\PrototypeB\PrototypeBHost" />
</application>
<bindings>
<!-- <binding protocol="http" bindingInformation="*:9612:192.168.1.106" />
<binding protocol="http" bindingInformation="*:8023:localhost" />-->
<binding protocol="https" bindingInformation="*:9612:192.168.1.106" />
<binding protocol="https" bindingInformation="*:8023:localhost" />
</bindings>
</site>
I followed some tutorials about WCF Rest but I'm a little bit confused with the SSL certificat. Do I need it? How can I attach the ssl certificat to the WCF Rest Service? Did I miss something?
My_WCF_proprieties
I finally found where was the problem, the default certificate with IIS Express doesn't work and cause some trouble.
First, I delete one of the certificate, I use command prompt for VS2015
netsh http delete sslcert ipport=0.0.0.0:44300
after that
I add a self-signed certificate
netsh http add sslcert ipport=0.0.0.0:44300 certhash=fb02ea72ab7443604aa8frib298e43l751ce3606 appid={214124cd-d05b-4309-8p76-9caa44b2b74a}
the command to show all certificates
netsh http show sslcert > output.txt
and it works :)
I am facing an issue when working with my WCF service. I consumed my WCF service in a console application and it works fine till 100 requests (in a loop). But it stops working after 100 requests. I have already used
<serviceThrottling
maxConcurrentCalls="500"
maxConcurrentInstances="500"
maxConcurrentSessions="500"/>
in my config but it has not effect on this issue. I have closed the connection after every call to the service but still the issue persists.
Any help is highly appreciated.
Below is my web.config :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add name="PriceGain" connectionString="Server=xyz.abc.com;Database=SomeDB;User Id=appuser;password=xxxxxxx;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<services>
<service name="AirGainUtilities.Service.Utilities" behaviorConfiguration="UtilitiesBehavior">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint address="http://192.168.1.1/AirGain.Utilities.Service/Utilities.svc" binding="basicHttpBinding" contract="AirGainUtilities.Service.IUtilities" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="UtilitiesBehavior">
<!-- 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="true" />
<serviceThrottling
maxConcurrentCalls="5000"
maxConcurrentInstances="5000"
maxConcurrentSessions="5000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
</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" />
<defaultDocument>
<files>
<add value="Utilities.svc" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Apparently, the problem was an open DB connection in the GetDestinationHotelId method in the Package Class. The DB connections were not closed due to an exception and after 100 open connections MAX CONNECTION POOL LIMIT was reached.
Really silly at my end :-(
When I get start to running WCF service.
error message when access .svc
HotelService.scv
<%# ServiceHost Language="C#" Debug="true" Service="HotelService.Hotel" %>
web.Config
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<!-- Service Model-->
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttp" messageEncoding="Mtom"
maxReceivedMessageSize="1000000000">
<readerQuotas maxArrayLength="1000000000"/>
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehavior"
name="HotelService.Hotel">
<endpoint address="http://localhost/HotelService/HotelService.svc"
binding="wsHttpBinding"
bindingConfiguration="wsHttp"
contract="HotelService.IHotel" />
<host>
<baseAddresses>
<add baseAddress="http://localhost"/>
</baseAddresses>
</host>
</service>
</services>
</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>
I enabled https binding, but my WSDL has soap address of http. Any ideas why? Thanks!
<wsdl:service name="XXXX"><wsdl:port name="BasicHttpBinding_XXXXService" binding="i0:BasicHttpBinding_XXXService">
<soap:address location="http://dev-soa-app/XXXX/XXXX/XXXService.svc"/></wsdl:port>
</wsdl:service>
Here is my web.config file:
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<configProtectedData>
<providers>
<add name="ConnStrings" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" keyContainerName="ConnStrings" cspProviderName="" useMachineContainer="true" useOAEP="false"/>
</providers>
</configProtectedData>
<connectionStrings configSource="ConnStrings\ConnStrings.config"/>
<system.serviceModel>
<services>
<service name="XXXXService">
<!-- Use a bindingNamespace to eliminate tempuri.org -->
<endpoint address="" name="XXXXService"
binding ="wsHttpBinding" bindingConfiguration="TransportSecurity"
bindingNamespace="WF.CT2.WebServices.XXXXService"
contract="WF.CT2.WebServices.XXXXService.SAMLService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true" 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
First of all, you should realize that the URL in the service element of the WSDL is only a hint. Your clients should not be depending on this being the correct address of the service.
Second, realize that if your service is hosted in IIS, then it is IIS which determines the address to place in that element, based on your bindings in IIS. I suspect that you have both HTTP and HTTPS enabled on the site hosting the service. You can usually switch this to just HTTPS by setting the "Require SSL" property on the SSL page in IIS Manager.
Remove httpGetEnabled ="false" from your Web.Config and keep httpsGetEnabled="true" as is (see below).
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>