I have a wcf service.
It use local IIS server.
My web.config is :
<?xml version="1.0"?>
<configuration>
<system.web>
<authentication mode="Windows"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="InstantMessagingBinding" closeTimeout="00:00:45">
<textMessageEncoding>
<readerQuotas maxStringContentLength="200000" maxArrayLength="200000" />
</textMessageEncoding>
<httpTransport keepAliveEnabled="false" maxReceivedMessageSize="200000" authenticationScheme="Ntlm"/>
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="InstantMessagingBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="Isima.InstantMessaging.WcfService.ContactService" behaviorConfiguration="InstantMessagingBehavior">
<endpoint address=""
binding="customBinding" bindingConfiguration="InstantMessagingBinding"
contract="Isima.InstantMessaging.WcfService.IContactService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
And when I run my service, I get an error
This error is about "This problem can occur when the specified part of the IIS configuration file is locked at a higher level configuration."
Why this error?
Check, if all application development components are installed for IIS. e.g. .NET and ASP.NET. See the add/remove windows-feature dialog in the control panel and check the installed IIS components.
I always install all development components (ASP.NET, ...).
Related
I have set up a WCF service hosted in IIS. The server that it is hosted on does not have a DNS Name (no domain), just an external static WAN IP address.
When I try to connect to the service in either iOS or Windows client using MEX to generate proxies, it uses the domain name which cannot be resolved and fails.
The WSDL document contains links that could not be resolved.
- There was an error downloading 'https://blah.com.au/NimThaiService.svc?xsd=xsd3'.
- The remote name could not be resolved: 'blah.com.au'
How can I change my Web config file or configure IIS so that instead of using the domain name it uses the static IP.
I need the MEX to be https://123.123.123.123/NimThaiService.svc
I've tried to follow directions in other articles. For example one suggests to add <useRequestHeadersForMetadataAddress />. But when I do that I get an error saying that the resource cannot be found.
My Web config file is as follows:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="NimThaiService.Authenticator, NimThaiService" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="NimThaiService.NimThaiService">
<endpoint address="https://mystaticwanipaddress:443/NimThaiService.svc" binding="basicHttpBinding" contract="NimThaiService.INimThaiService" bindingConfiguration="secureHttpBinding">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange">
<identity>
<dns value="mystaticwanipaddress" />
</identity>
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
After some more research I managed to fix this by adding an attribute to the serviceMetadata node.
I needed to add the "httpsGetUrl" attribute as follows:
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="http://mystaticwanipaddress/NimThaiService.svc/basic" />
I am trying to convert a WCF service from http to https.
It is using a self-signed certificate.
I can browse to the service using web browser, but when I try to add it as a web reference in another .Net app, I get the following error:
There was an error downloading https://localhost:40300/DBService/SPService.svc/_vti_bin/ListData.svc/$metadata.
The request failed with HTTP status 403: Forbidden.
I have tried editing the web.config in various ways according to lots of Googling, but still have the above error with no way to narrow down the cause...
Here is my web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="DatabaseServer" value="Server2008"/>
<add key="Database" value="Licensor"/>
<add key="VerboseLogging" value="True"/>
</appSettings>
<system.web>
<compilation targetFramework="4.0"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<services>
<service name="DBService.SPService">
<endpoint address="https://localhost/DBService/SPService.svc"
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="DBService.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Can anyone help to find the cause, or even better point me towards a working sample of WCF over SSL using basicHttpBinding?
I have spent quite a few hours trying to resolve this so will appreciate your time on this one. If you need to I can provide access to my machine.
Asking this question again in stack overflow seems stupid as there are enough posts already on this topic...but i can see that every post has its own way of achieving this..So my config file is specified here below...I have followed up all the relevant posts and wrote this Web config file..But after all efforts also i get this error below :
"Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http]."
Here is my Web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<globalization requestEncoding="utf-8" uiCulture="en" culture="en-US" responseEncoding="utf-8"/>
</system.web>
<system.serviceModel>
<services>
<service name="WcfService.Service1" behaviorConfiguration="ReqServiceBehaviour">
<endpoint address ="" binding="webHttpBinding" contract="WcfService.IService1" behaviorConfiguration="web"/>
<endpoint address="files" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="httpStreamingBinding" name="UploadEndpoint"
contract="WcfService.IService1" />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="WcfService.IService1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="httpStreamingBinding" transferMode="Streamed" />
</webHttpBinding>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ReqServiceBehaviour">
<!-- 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>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment 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>
May be you can try following
In order to use https, you require to set httpsGetEnabled="true" instead of httpGetEnabled="true"
I'm having a simple WCF service, deployed to IIS. I used simplified configuration with BasicHttpBinding, which worked fine.
Now I wanted to add Username/Password authentication and used wsHttpBinding. In the document above it is stated:
In .NET Framework 4, the element is optional. When a service
does not define any endpoints, an endpoint for each base address and
contract implemented are added to the service. The base address is
appended to the contract name to determine the endpoint and the
binding is determined by the address scheme.
What does this mean, how am I supposed to configure the wsHttpBinding binding by address scheme?
My config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding>
<security mode="Message">
<transport clientCredentialType="None"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SampleWebservice.CustomValidator,SampleWebservice" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
This is Windows Server 2008, IIS 7.
It seems, the service is not picking up the wsBinding settings, as I can always see a BasicHttpBinding in the downloaded svc-file. Am I missing something?
EDIT
I applied the changes suggested by user stevedocious to alter my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="SampleWebservice.SampleWebservice.Sample" behaviorConfiguration="customServiceBehaviour">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint contract="SampleWebservice.SampleWebservice.ISample" binding="wsHttpBinding" bindingConfiguration="bindingConfiguration" address="" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="bindingConfiguration">
<security mode="Message">
<transport clientCredentialType="None"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="customServiceBehaviour">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SampleWebservice.CustomValidator,SampleWebservice" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
However, the metadata can't be exposed. Checking the service with the browser states, that my metadata publishing is currently disabled.
You will need to create an endpoint if you want to use anything other than the basicHttpBinding with the http/https address scheme.
In your binding definition add a name attribute
< binding name="myWSBinding" ... >
then add a bindingConfiguration and binding parameter to your endpoint definition
< endpoint binding="wsHttpBinding" bindingCongifuration="myWSBinding" ... >
I almost have everything set up to use my WCF service over https. IIS application is up and running, I can read the svc and wsdl at localhost. So I went back to Visual Studio and tried to write a Client that can call the service. When adding the ServiceReference I get the following error:
Could not find a base address that matches scheme https for the endpoint with binding MetadataExchangeHttpsBinding. Registered base address schemes are [http].
I've tried with the built-in development server and with IIS Express also. They both gave the same error.
Here's my web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SmartCook2.Server.ISmartCookServiceBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="SmartCook2.Server.ISmartCookServiceBehavior"
name="SmartCook2.Server.SmartCookService">
<endpoint address="https://localhost:6344/SmartCookService.svc"
binding="wsHttpBinding" bindingConfiguration="TransportSecurity"
contract="SmartCook2.Server.ISmartCookService" />
<endpoint address="mex" binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
What am I doing wrong?
It seems VS didn't discover the address right, since it left out the application part. So the correct address for the service reference is :
https://localhost/IISHostedSmartCook/SmartCookService.svc