I have gotten my config to work correctly now, there was a mismatch between the actual file structure and the project structure in visual studio. Stupid silly mistake :)
However, now I have the issue of transitioning from basicHttpBinding to WsHttpBinding. This is the webconfig. As you can see I have changed the first endpoint to be of the type wsHttpBinding.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="RENTIT05ConnectionString" connectionString="Data Source=rentit.itu.dk;Initial Catalog=RENTIT05;Persist Security Info=True;User ID=Rentit05db;Password=omitted" providerName="System.Data.SqlClient" />
<add name="RENTIT05Entities" connectionString="metadata=res://*/RentIt.csdl|res://*/RentIt.ssdl|res://*/RentIt.msl;provider=System.Data.SqlClient;provider connection string="Data Source=rentit.itu.dk;Initial Catalog=RENTIT05;Persist Security Info=True;User ID=Rentit05db;Password=omitted;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="10000000"/>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<services>
<service name="RentIt05.Services.Service" behaviorConfiguration="ServiceBehavior">
<endpoint address="RentIt05.Services.AgeRatingService" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="RentIt05.Interfaces.IAgeRatingService"></endpoint>
<endpoint address="RentIt05.Services.CommentService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.ICommentService"></endpoint>
<endpoint address="RentIt05.Services.ItemService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IItemService"></endpoint>
<endpoint address="RentIt05.Services.ItemTypeService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IItemTypeService"></endpoint>
<endpoint address="RentIt05.Services.LabelService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.ILabelService"></endpoint>
<endpoint address="RentIt05.Services.LoginService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.ILoginService"></endpoint>
<endpoint address="RentIt05.Services.RatingService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IRatingService"></endpoint>
<endpoint address="RentIt05.Services.SectionService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.ISectionService"></endpoint>
<endpoint address="RentIt05.Services.StateLogService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IStateLogService"></endpoint>
<endpoint address="RentIt05.Services.StateService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IStateService"></endpoint>
<endpoint address="RentIt05.Services.UserGroupService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IUserGroupService"></endpoint>
<endpoint address="RentIt05.Services.UserService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.IUserService"></endpoint>
<endpoint address="RentIt05.Services.TransferService" binding="basicHttpBinding" bindingConfiguration="RentItBinding" contract="RentIt05.Interfaces.ITransferService"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="RentItBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="StreamedRequest">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
When I try to run this locally on localhost, I get the following error message:
Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]..
I have found some artiles talking about IIS resolving multiple base addresses, but this is locally, so I don't know why it is not working.
Is there something I'm missing here? The config file works fine as long as I only use basicHttpBindings.
Any help will be greatly appreciated, tyvm!
Do you need security enabled? You have transport security enabled on the wsHttpBinding which will look for ssl. Your basicHttpBinding isn't using any. The error will go away if you set
<binding name="wsHttpBinding">
<security mode="None">
</security>
</binding>
Another option is to set up ssl on IIS.
Related
Getting the error only on Uploading a byte[] of nearly 250k but downloading of the same byte[] array are fin using the same config.
I've looked into Streaming but the single parameter doesnt work and these file sizes are huge. I have been able to upload a simple text file of 630 bytes and it works fine.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IGenerateLetterWcf"
maxBufferSize="20000000" maxReceivedMessageSize="20000000"
closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:61394/GenerateLetterWcf.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateLetterWcf"
contract="GenerateLetterWcfSvc.IGenerateLetterWcf" name="BasicHttpBinding_IGenerateLetterWcf" />
</client>
</system.serviceModel>
</configuration>
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="DTPLibrary.Properties.Settings.XXXXConnectionString1" connectionString="data source=XXXXX;initial catalog=XXXXXX;User ID=SQLAdmin;Password=XXXXXX" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.net>
<settings>
<servicePointManager expect100Continue="false"/>
</settings>
</system.net>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000000"
maxSizeOfMessageToLog="2000000"/>
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IEntitySearchWcf" maxBufferSize="10000000" maxReceivedMessageSize="10000000" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" />
<binding name="BasicHttpBinding_IBrokerWcf" maxBufferSize="6500000" maxReceivedMessageSize="6500000" />
<binding name="BasicHttpBinding_IProjectWcf" maxBufferSize="9900000" maxReceivedMessageSize="9900000" />
<binding name="BasicHttpBinding_ILoginWcf" maxReceivedMessageSize="20000000" maxBufferSize="20000000" />
<binding name="BasicHttpBinding_ISupportWcf" maxBufferSize="9900000" maxReceivedMessageSize="9900000" />
<binding name="BasicHttpBinding_IInscoWcf" maxBufferSize="100000000" maxReceivedMessageSize="100000000" />
<binding name="BasicHttpBinding_IClientMaintenanceWcf" maxReceivedMessageSize="9900000" />
<binding name="BasicHttpBinding_IWebUserWcf" maxReceivedMessageSize="9900000" />
<binding name="BasicHttpBinding_IRoleWcf" maxReceivedMessageSize="9900000" />
<binding name="BasicHttpBinding_ILabelWcf" maxReceivedMessageSize="10000000" maxBufferSize="10000000" />
<binding name="BasicHttpBinding_IProjectTypeWcfSvc" maxReceivedMessageSize="9900000" />
<binding name="BasicHttpBinding_IDropDownWcf" maxBufferSize="100000000" maxReceivedMessageSize="100000000" />
<binding name="BasicHttpBinding_IDefaultCertLimitWcf" maxBufferSize="100000000" maxReceivedMessageSize="100000000" />
<binding name="BasicHttpBinding_IConfigurationWcf" />
<binding name="BasicHttpBinding_IEndorsementsWcf" />
<binding name="BasicHttpBinding_IProjectCertReqWcf" maxBufferSize="2000000000" maxReceivedMessageSize="2000000000" />
<binding name="BasicHttpBinding_IInsuredEntryWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
<binding name="BasicHttpBinding_ICertWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
<binding name="BasicHttpBinding_IDocumentWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
<binding name="BasicHttpBinding_IReportsWcf" />
<binding name="BasicHttpBinding_ICertGenLetterTemplWcf" />
<binding name="BasicHttpBinding_IGenerateLetterWcf" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
/>
<binding name="BasicHttpBinding_ILinkImagesWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
<binding name="BasicHttpBinding_IErrorLogWcf" />
<binding name="BasicHttpBinding_IDashBoardWcf" />
<binding name="BasicHttpBinding_IReviewScannedCertificateWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
<binding name="BasicHttpBinding_IAllEndorsementsWcf" />
<binding name="BasicHttpBinding_IScanDocumentWcf" />
<binding name="BasicHttpBinding_IUserWcf" />
<binding name="BasicHttpBinding_IOutputLogWcf" />
<binding name="BasicHttpBinding_IStreamServiceWcf" closeTimeout="00:20:00"
openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" transferMode="Streamed" messageEncoding="Mtom"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:61394/EntitySearchWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEntitySearchWcf" contract="EntitySearchWcfSvc.IEntitySearchWcf" name="BasicHttpBinding_IEntitySearchWcf" />
<endpoint address="http://localhost:61394/BrokerWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IBrokerWcf" contract="BrokerWcfSvc.IBrokerWcf" name="BasicHttpBinding_IBrokerWcf" />
<endpoint address="http://localhost:61394/ProjectWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectWcf" contract="ProjectWcfSvc.IProjectWcf" name="BasicHttpBinding_IProjectWcf" />
<endpoint address="http://localhost:61394/SupportWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISupportWcf" contract="SupportWcfSvc.ISupportWcf" name="BasicHttpBinding_ISupportWcf" />
<endpoint address="http://localhost:61394/LoginWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILoginWcf" contract="LoginWcfSvc.ILoginWcf" name="BasicHttpBinding_ILoginWcf" />
<endpoint address="http://localhost:61394/InscoWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInscoWcf" contract="InscoWcfSvc.IInscoWcf" name="BasicHttpBinding_IInscoWcf" />
<endpoint address="http://localhost:61394/ClientMaintenanceWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IClientMaintenanceWcf" contract="ClientMaintenanceWcfSvc.IClientMaintenanceWcf" name="BasicHttpBinding_IClientMaintenanceWcf" />
<endpoint address="http://localhost:61394/WebUserWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWebUserWcf" contract="WebUserWcfSvc.IWebUserWcf" name="BasicHttpBinding_IWebUserWcf" />
<endpoint address="http://localhost:61394/RoleWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRoleWcf" contract="RoleWcfSvc.IRoleWcf" name="BasicHttpBinding_IRoleWcf" />
<endpoint address="http://localhost:61394/LabelWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILabelWcf" contract="LabelWcfSvc.ILabelWcf" name="BasicHttpBinding_ILabelWcf" />
<endpoint address="http://localhost:61394/ProjectTypeWcfSvc.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectTypeWcfSvc" contract="ProjectTypeWcfSvc.IProjectTypeWcfSvc" name="BasicHttpBinding_IProjectTypeWcfSvc" />
<endpoint address="http://localhost:61394/DefaultCertLimitWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDefaultCertLimitWcf" contract="DefaultCertLimitWcfSvc.IDefaultCertLimitWcf" name="BasicHttpBinding_IDefaultCertLimitWcf" />
<endpoint address="http://localhost:61394/DropDownWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDropDownWcf" contract="DropDownWcfSvc.IDropDownWcf" name="BasicHttpBinding_IDropDownWcf" />
<endpoint address="http://localhost:61394/ConfigurationWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IConfigurationWcf" contract="ConfigurationWcfSvc.IConfigurationWcf" name="BasicHttpBinding_IConfigurationWcf" />
<endpoint address="http://localhost:61394/EndorsementsWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEndorsementsWcf" contract="EndorsementsWcfSvc.IEndorsementsWcf" name="BasicHttpBinding_IEndorsementsWcf" />
<endpoint address="http://localhost:61394/ProjectCertReqWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectCertReqWcf" contract="ProjectCertReqWcfSvc.IProjectCertReqWcf" name="BasicHttpBinding_IProjectCertReqWcf" />
<endpoint address="http://localhost:61394/InsuredEntryWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInsuredEntryWcf" contract="InsuredEntryWcfSvc.IInsuredEntryWcf" name="BasicHttpBinding_IInsuredEntryWcf" />
<endpoint address="http://localhost:61394/CertWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICertWcf" contract="CertWcfSvc.ICertWcf" name="BasicHttpBinding_ICertWcf" />
<endpoint address="http://localhost:61394/DocumentWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDocumentWcf" contract="DocumentWcfSvc.IDocumentWcf" name="BasicHttpBinding_IDocumentWcf" />
<endpoint address="http://localhost:61394/ReportsWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReportsWcf" contract="ReportsWcfSvc.IReportsWcf" name="BasicHttpBinding_IReportsWcf" />
<endpoint address="http://localhost:61394/CertGenLetterTemplWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICertGenLetterTemplWcf" contract="CertGenLetterTemplWcfSvc.ICertGenLetterTemplWcf" name="BasicHttpBinding_ICertGenLetterTemplWcf" />
<endpoint address="http://localhost:61394/GenerateLetterWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateLetterWcf" contract="GenerateLetterWcfSvc.IGenerateLetterWcf" name="BasicHttpBinding_IGenerateLetterWcf" />
<endpoint address="http://localhost:61394/LinkImagesWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILinkImagesWcf" contract="LinkImagesWcfSvc.ILinkImagesWcf" name="BasicHttpBinding_ILinkImagesWcf" />
<endpoint address="http://localhost:61394/ErrorLogWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IErrorLogWcf" contract="ErrorLogWcfSvc.IErrorLogWcf" name="BasicHttpBinding_IErrorLogWcf" />
<endpoint address="http://localhost:61394/DashBoardWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDashBoardWcf" contract="DashboardWcfSvc.IDashBoardWcf" name="BasicHttpBinding_IDashBoardWcf" />
<endpoint address="http://localhost:61394/ReviewScannedCertificateWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReviewScannedCertificateWcf" contract="ReviewScannedCertificateWcfSvc.IReviewScannedCertificateWcf" name="BasicHttpBinding_IReviewScannedCertificateWcf" />
<endpoint address="http://localhost:61394/AllEndorsementsWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAllEndorsementsWcf" contract="AllEndorsementsWcfSvc.IAllEndorsementsWcf" name="BasicHttpBinding_IAllEndorsementsWcf" />
<endpoint address="http://localhost:61394/ScanDocumentWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IScanDocumentWcf" contract="ScanDocumentWcfSvc.IScanDocumentWcf" name="BasicHttpBinding_IScanDocumentWcf" />
<endpoint address="http://localhost:61394/UserWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserWcf" contract="UserWcfSvc.IUserWcf" name="BasicHttpBinding_IUserWcf" />
<endpoint address="http://localhost:61394/OutputLogWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOutputLogWcf" contract="OutputLogWcfSvc.IOutputLogWcf" name="BasicHttpBinding_IOutputLogWcf" />
<endpoint address="http://localhost:61394/StreamServiceWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStreamServiceWcf" contract="StreamServiceWcfSvc.IStreamServiceWcf" name="BasicHttpBinding_IStreamServiceWcf" />
</client>
<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="true"/>
<dataContractSerializer maxItemsInObjectGraph="1365536" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" maxReceivedMessageSize="65536000"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
<source name="System.ServiceModel"
switchValue="Warning, Critical, Error, Verbose"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\logs\service.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
I have a question about your present configuration. Why you use the absolute service address in your endpoint address? if the service is hosted in IIS, the base address is provided by the IIS site binding module.
Thereby I suspect the current live connection doesn’t use this endpoint address, which results in the failure of the MaxReceivedMessageSize setting. I would like to know what the service address the client actually used is. Only apply the configuration on the correct service endpoint address can take effect.
Updated.
It seems that the above configuration is on the client-side, and the below configuration is on the server-side. Also, the WCF service contains multiple service contracts.
The configuration on the server-side doesn’t explicitly declare how does the service is created. There are neither Services section nor ProtocolMapping section in the configuration file. like the below form.
<services>
<service name="ConsoleApp3.TestService">
<endpoint address="" binding="basicHttpBinding" contract="ConsoleApp3.ITestService" ></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
And,
<protocolMapping>
<add binding="webHttpBinding" scheme="http"/>
</protocolMapping>
Namely, it uses the default Basichttpbinding to create the service. there is no way to apply the setting to the right service endpoint.
I suggest you attempt the below configuration on the server-side.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="mybinding" maxBufferSize="20000000" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" bindingConfiguration="mybinding"/>
</protocolMapping>
</system.serviceModel>
It can also support multiple service contracts.
Feel free to let me know if the problem still exists.
Here is the situation, I want many clients to call my web service using username authentication over https. Security is the first priority so I am thinking of using wshttpbinding with message security. I don't know though if my thoughts are correct.
The thing is that I have already something that works but I don't know if it needs changes to achieve better security.
Here is what it's done by now.
<services>
<service name="myService" behaviorConfiguration="myBehavior" >
<endpoint address="" binding="basicHttpBinding" contract="myIService" bindingConfiguration="RequestUserName_BasicHttp" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/myService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="RequestUserName_BasicHttp">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="myvalidator, myNamespace"/>
</serviceCredentials>
So, by this way (which works) I don't think that I have best security (at least I need to send requests over https). What can I do to achieve better/best security? I have tried with wshttpbinding and https but I have some problems with certificates.
The development enviroment is Windows XP, VS2010, IIS7.5 express.
And there are a class library describing the Service and a consoleClient app for consuming it...The client has it's own app.config file in which there are the credentials (username and password).
you are already implementing user id and password verification and if you want to perform encryption and decryption of messages you must use Certificates with HttpsBinding or WsHttpBinding. More information about authentication and authorization in wcf please go through this MSDN documentation
Ok, I took into consideration Ramesh Babu answer and I change a little bit my project.
So instead of creating a class library for wcf service I created a WCF Service Application (there is this option in VS2010).Everything else remained unchanged so I made a new Web.config file like this
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinding">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyBehavior" name="myName">
<endpoint address="myService.svc" binding="wsHttpBinding"
bindingConfiguration="MyBinding"
contract="myService.ImyService" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:44400/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebugincludeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="myService.Authentication.CustomValidator, myService" />
<serviceCertificate
findValue="MyCertificate"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
storeName="My" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
<connectionStrings>
<add name="myEntities" connectionString="......" />
</connectionStrings>
</configuration>
so I needed to create a certificate and I used SelfCert to create one and copy it to TrustedPeople (typing mmc in run).
After this I created a console app to consume thw service and app.config file of app was built automatically.
I new to wcf however i'm attempting to use net.tcp binding wcf service to transmit an xml file to the client.
I can get up to creating the xml file and upon attempting to connect to my wcf service fails.
I followed this guide http://msdn.microsoft.com/en-us/library/ff647180.aspx up to creating the windows test app, i'm using a web project for this.
I have added the service reference to project and below is the code i'm attempting to execute:
public string SendXMLDocument(XmlDocument xDoc)
{
var message = Message.CreateMessage(MessageVersion.Soap11, "Request_for_action", new XmlNodeReader(xDoc));
var factory = new ChannelFactory<IActionServiceLibrary>("IMMS.ActionsServiceLibrary.IActionServiceLibrary");
var channel = factory.CreateChannel();
var response = channel.Request(message);
channel.Close();
return response.ToString(); //this should come back okay..
}
my library appconfig looks like:
<?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>
<client>
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IActionServiceLibrary" contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary"
name="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="IMMS.ActionsServiceLibrary.ActionServiceLibrary">
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding" bindingConfiguration=""
contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080/ActionService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="Action_Service" sendTimeout="00:01:00" transactionFlow="false"
listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" portSharingEnabled="false">
<reliableSession enabled="false" />
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
<binding name="NetTcpBinding_IActionServiceLibrary" />
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
the app config for the service:
<?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>
<client>
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IActionServiceLibrary" contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary"
name="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="IMMS.ActionsServiceLibrary.ActionServiceLibrary">
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding" bindingConfiguration=""
contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080/ActionService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="Action_Service" sendTimeout="00:01:00" transactionFlow="false"
listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" portSharingEnabled="false">
<reliableSession enabled="false" />
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
<binding name="NetTcpBinding_IActionServiceLibrary" />
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
i get a name mismatch on the channel creation.
any help to point me in the right direction for transmitting a xml file through wcf would be great.
I found out that my config file was messed up after fixing the errors it works now.
Question 1: Is there a way to make setspn.exe take effects without the need to restart the computer?
Question 2: I did set the SPN and ran my WCF service on the server. The client connected using Kerberos, then I changed the Identity element at client side and tried again. I found it was using NTLM instead of Kerberos but this is fine.
When I did change the SPN in the WCF service configuration file and re-ran the service (without changing the registered SPN), I found it used Kerberos authentication at client side. why changing the identity element of WCF service doesnt make any effect?
How can this be?
NOTE: I am using fiddler to check the authentication.
Server side config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress = "https://FQDN:PORT/TESTSVC/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="service_binding" contract="WcfServiceLibrary1.IService1">
<identity>
<servicePrincipalName value="svc1/FQDN:PORT" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="service_binding">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Client side config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1">
<security mode="Transport" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://FQDN:PORT/TESTSVC/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
<identity>
<servicePrincipalName value="ismine/nhdc1.nhandal2.local:8730" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
I am using VSTS 2008 + C# + .Net 3.0. I am using self-hosted WCF. When executing the following statement, there is the following binding not found error. I have posted my whole app.config file, any ideas what is wrong?
ServiceHost host = new ServiceHost(typeof(MyWCFService));
Error message,
Configuration binding extension 'system.serviceModel/bindings/MyBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Full app.config,
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinding"
closeTimeout="00:00:10"
openTimeout="00:00:20"
receiveTimeout="00:00:30"
sendTimeout="00:00:40"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="WeakWildcard"
maxReceivedMessageSize="100000000"
messageEncoding="Mtom"
proxyAddress="http://foo/bar"
textEncoding="utf-16"
useDefaultWebProxy="false">
<reliableSession ordered="false"
inactivityTimeout="00:02:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Digest"
proxyCredentialType="None"
realm="someRealm" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyWCFService"
behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9090/MyService"/>
</baseAddresses>
</host>
<endpoint address="" binding="MyBinding" contract="IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
thanks in advance,
George
You've misunderstood how to configure bindings - your binding in the endpoint needs to be a known protocol;
<endpoint address="" binding="wsHttpBinding" contract="IMyService"/>
Once you have that you can then specify the binding configuration you have defined within the settings for that protocol using the bindingConfiguration element thus
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="MyBinding" contract="IMyService"/>