I had made a service using wcf i tested it by making a project to a client of type asp.net and it works perfect.I hosted the service and the client on the IIS i wanted to run without opening the visual studio.when i closed the visual studio and put my URL of the client project it gives me this error
Could not find default endpoint element that references contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Could not find
default endpoint element that references contract
'ServiceReference1.IService1' in the ServiceModel client configuration
section. This might be because no configuration file was found for
your application, or because no endpoint element matching this
contract could be found in the client element.
Source Error:
Line 27: Line 28: System.IO.FileInfo fileinfo = new
System.IO.FileInfo(FileUpload1.PostedFile.FileName); Line 29:
ServiceReference1.IService1 clientupload = new
ServiceReference1.Service1Client(); Line 30:
ServiceReference1.RemoteFileInfo uploadRequestInfo = new
ServiceReference1.RemoteFileInfo(); Line 31: Link =
FileUpload1.PostedFile.FileName;
Source File: C:\Users\KHALED\documents\visual studio
2010\Projects\WcfServicefiles\WebApplication2\Default.aspx.cs Line:
29
here's the web.config of the service
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime maxRequestLength="2097151"
useFullyQualifiedRedirectUrl="true"
executionTimeout="14400"/>
</system.web>
<system.serviceModel>
<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="6553600"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="Service1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfServicefinal.Service1" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="WcfServicefinal.IService1" >
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Here it is the web.config of the client
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WcfServicefinal/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
It may be a good idea to try hosting your service in a console app as a first go. Sean is right, it would be helpful to see your configuration.
When running your service in visual studio, the service is automatically hosted for you. When testing outside visual studio: Run your service host, open a browser and enter the BASE address of your host. You should see a page with a link to the wsdl definition if meata data is available.
A base address may look like http://192.168.89.73:8080/base with the IP address of your machine, port number....
WCFTestClient shipped with VS is for testing the WCF.
Related
Let me explain you from the begining. There are 3 projects in my solution explorer window in Visual Studio. Let me explain them one by one. First one is Web Project(ASP.NET Form Based). I need to get some data from 2 different sources. So I have added two different WCF projects in to my solution explorer window in Visual Studio.
Let me tell you about these 2 WCF projects. First WCF is connected to SOAP web service. Message Encoding type should be Mtom for this SOAP service. By the way this SOAP web service returns byte data(like picture). That's why I have right clicked and then Add> Service Reference option to complete this operation.
And as you known this operation updates Web.config file automatically. That's why you see ' binding="wsHttpBinding" ' in Web.config file.
Beside this there is one more WCF project like I mention above. But this works well. I don't have any problem with it.
I have added these two WCF projects in to my Web Project with right clicking Add>Service Reference option. Actually it was working fine until i have try it with large byte data(picture) Let me explain with data sizes: First WCF project is able to bring me a data(picture) with a small size 1.84 KB (1,890 bytes). But same WCF project is not able to bring me a data(picture) with a larger size 164 KB (168,423 bytes). This is the problem. That's why I have shared web.config file of the web project and the web.config file of the First WCF project.
I'm sharing web.config files that are giving errors when displaying a large photo. (You can see web.config file of the web project and web.config file of the first WCF project below)
I have founded&tried lots of solution. But I am still getting same error.
Here is the error:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element
IIS Version of the web server is: Windows Server 2012 R2, IIS: Version 8.5.9600.16384. I have made a research about this problem. I have found&tried lots of solution. But it did not work.
Here is the web.config file of the WCF project
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="abcdPortBinding">
<mtomMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
</customBinding>
<wsHttpBinding>
<binding name="SecureHttpBinding"
closeTimeout="00:10:00"
openTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://abc.abc.com:443/abc-srv/abcPort"
binding="customBinding" bindingConfiguration="abcdPortBinding"
contract="mobilSignatureServiceReference.abcdsrv" name="abcdPort" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="Servicebehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service behaviorConfiguration="Servicebehavior" name="abcdWcfServisi.abcdServisim">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="SecureHttpBinding" name="SecureHttp" contract="abcdWcfServisi.IabcdServisim"/>
<host>
<timeouts closeTimeout="00:10:00" openTimeout="00:10:00"/>
</host>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Here is the Web.config file of the web project(asp.net form based project)
<?xml version="1.0"?>
<configuration>
<appSettings>
</appSettings>
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
<machineKey validation="3DES"/>
<pages viewStateEncryptionMode="Always" enableViewStateMac="true" controlRenderingCompatibilityVersion="4.0"/>
<trace enabled="false" localOnly="true"/>
<httpCookies httpOnlyCookies="true"/>
<sessionState cookieless="UseCookies"/>
<httpModules>
<add name="myHttpModule" type="myHttpModule"/>
</httpModules>
<compilation debug="true" targetFramework="4.6.1">
<assemblies>
<add assembly="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms name="abc" loginUrl="login.aspx" defaultUrl="abc.aspx" timeout="50000"/>
</authentication>
<customErrors mode="RemoteOnly" defaultRedirect="https://abctest.com">
</customErrors>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false"/>
<defaultDocument>
<files>
<clear/>
<add value="abc.aspx"/>
<add value="abcSecureSrv.svc"/>
</files>
</defaultDocument>
<httpErrors>
<remove statusCode="502" subStatusCode="-1"/>
<remove statusCode="501" subStatusCode="-1"/>
<remove statusCode="500" subStatusCode="-1"/>
<remove statusCode="412" subStatusCode="-1"/>
<remove statusCode="406" subStatusCode="-1"/>
<remove statusCode="405" subStatusCode="-1"/>
<remove statusCode="403" subStatusCode="-1"/>
<remove statusCode="401" subStatusCode="-1"/>
<remove statusCode="404" subStatusCode="-1"/>
<error statusCode="404" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="401" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="403" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="405" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="406" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="412" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="500" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="501" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="502" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
</httpErrors>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="HttpBinding_abcd"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Streamed"
messageEncoding="Text" />
</basicHttpBinding>
<wsHttpBinding>
<binding name="SecureHttp" messageEncoding="Mtom">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://abctest.com/abcdesube.svc?wsdl"
behaviorConfiguration="SertifikaDavranisi" binding="basicHttpBinding"
bindingConfiguration="HttpBinding_abcd" contract="abcdesube"
name="HttpBinding_abcd" />
<endpoint address="http://localhost:37377/abcdServisim.svc" binding="wsHttpBinding"
bindingConfiguration="SecureHttp" contract="abcdSignature.IabcdServisim"
name="SecureHttp" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="SertifikaDavranisi">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SertifikaDavranisi">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
How can I solve this problem?
How do you call the service, by adding service reference? it seems that you call the service in the web project. but why does the WCF project have the Client section? This indicates that the WCF project has referred to other projects.
I would like to know that the detail steps you take in the client-side for calling the service, including the service metadata URL you typed.
Besides, try to remove all other irrelevant project configuration and adding the service reference again and share it with me. these configurations appear not generated automatically.
Look forward to your reply.
Updated.
I suggest you create a new console application to test again and remove irrelevant configuration in the WCF project. please replace the system.servicemodel configuration with the below code.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<protocolMapping>
<add binding="wsHttpBinding" scheme="http" bindingConfiguration="mybinding"/>
</protocolMapping>
</system.serviceModel>
Feel free to let me know if the problem still exists.
<httpsTransport..> tag has solved the problem.
<customBinding>
<binding>
<httpsTransport maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
I am trying to write a webforms application that can consume a wcf service. The WCF service is used by windows application as well as a windows service I created. Both can consume the WCF service fine, my website however cannot when being deployed. I've followed guides on how to properly consume a web service within asp.net. I've created the client and called the function in the code behind. My bindings seem to be correct.
I've researched and it shows me to enable Tls and I have and it still will not worked.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or
SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
I've added the above code in my global.asax.vb file as well as before calling my web service function.
What am I missing here? This is my error message:
[CommunicationException: An error occurred while making the HTTP request to
https://myserviceD.net/Service.svc.This could be due to the fact that the
server certificate is not configured properly with HTTP.SYS in the HTTPS case.
This could also be caused by a mismatch of the security binding between the
client and the server.]
Here is my WCF config file:
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5">
</compilation>
<httpRuntime targetFramework="4.5"/>
<pages>
<namespaces>
<add namespace="System.Runtime.Serialization"/>
<add namespace="System.ServiceModel"/>
<add namespace="System.ServiceModel.Web"/>
</namespaces>
</pages>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text"/>
</basicHttpBinding>
<basicHttpsBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpsBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<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>
And a winforms config file that successfully consumes the web service:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<appSettings>
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
<binding name="BasicHttpsBinding_IService1">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://myserviceD.net/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_IService1" contract="myserviceD.ServiceReference.IService"
name="BasicHttpsBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
Adding config file from my web app
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
</configSections>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5.1"/>
<httpRuntime targetFramework="4.5.1"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_IService">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https:///myserviceD.net/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_IService" contract="myserviceD.net.ServiceReference.IService"
name="BasicHttpsBinding_IService" />
</client>
</system.serviceModel>
</configuration>
The error details mainly indicate that there is something wrong with the service, such as the service is not working properly over https.
How do you call the service on the client-side? In the other application which can consume the service properly what is the auto-generated configuration? I suspect there is something wrong with the service over HTTPS. It might only work over HTTP. Besides, this issue has nothing to do with the TLS version, The OS will decide on the TLS version.
I would like to know the WCF configuration on the server-side and the client configuration that can call the service properly.
Feel free to let me know if there is anything I can help with.
Turns out the problem was modifying the host file and I had the wrong ip mapped to domain name
I referenced the Wcf service library project to my ASP.NET Web application's Service references.
I published the Web application alone in Local IIS server. But FinananceService.svc service file didnt add in the publiashed folder after publishing. So I manually pasted FinananceService.svc file in published folder. Hence I able to browse the FinananceService.svc file using "http://localhost:8080/FinanceService.svc"
3.But when I run the application, Wcf service is not getting called from asp.net web pages.
Web.config file:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<sessionState mode="InProc" timeout="360"></sessionState>
<compilation targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<connectionStrings>
<add name="SqlConn" connectionString="Data Source=HASHBYTESSERVER;Initial Catalog=Swasthik;Persist Security Info=True;User ID=sa;Password=hasH35" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.serviceModel>
<client>
<endpoint address="http://localhost:8080/Swas/FinanceService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFinanceService1" contract="HashFinanceService.IFinanceService" name="BasicHttpBinding_IFinanceService"/>
</client>
<services>
<service name="HashFinanceService.FinanceService" behaviorConfiguration="ServiceBehaviour" >
<endpoint address="http://localhost:8080/FinanceService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFinanceService"
contract="HashFinanceService.IFinanceService" name="BasicHttpBinding_IFinanceService" listenUri="/">
</endpoint>
<host>
<baseAddresses >
<add baseAddress="http://localhost:8080/"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFinanceService" closeTimeout="00:20:00" openTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
<binding name="BasicHttpBinding_IFinanceService1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="CustomWSBindingTcp">
<reliableSession enabled="true"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true "/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<defaultDocument>
<files>
<clear/>
<add value="Login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
</configuration>
Published folder structure:
Please guide me how to handle this.
I try to implement a WCF service that is hosted on IIS, the users ask for some templates files transformation and it return them the processed file (If they are authorized for the template they asked for).
I selected the visual studio project template "WCF Service Application" and got a project with aspNetCompatibilityEnabled set to true etc.
I thought on implementing my need using AzMan authorization since I am fimiliar with that mechanism and did similiar things with it.
However, I can't debug the service since I get 401 unauthorized.
I assume the user token is not being sent.
1. How can I enable Azman usage for WCF, IIS hosted service?
2. Is there similiar mechanism embedded in WCF that can assist checking if a user belongs to a group that allowed to access some site folder?
Confiuration:
<configuration>
<connectionStrings>
<add name="LocalPolicyStore"connectionString="msxml://c:/RolesData/azmanstore.xml" /> </connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="RoleManagerAzManProvider" cookieName=".ASPXROLES" cookiePath="/" cookieTimeout="30" cookieRequireSSL="true" cookieSlidingExpiration="true" createPersistentCookie="false" cookieProtection="All">
<providers>
<add name="RoleManagerAzManProvider" type="System.Web.Security.AuthorizationStoreRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, publicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalPolicyStore" applicationName="DRP" />
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<!-- 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"/>
<serviceAuthorization principalPermissionMode="UseAspNetRoles"
roleProviderName="RoleManagerAzManProvider" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ExcelGeneratingService.ExcelGeneratorService" behaviorConfiguration="metadataBehavior">
<endpoint
address=""
binding="basicHttpBinding" bindingConfiguration="excelGeneratorServiceBinding"
contract="ExcelGeneratingService.IExcelGeneratorService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="excelGeneratorServiceBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<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>
Code:
//Check if the user is allowed to access this path
if (!UrlAuthorizationModule.CheckUrlAccessForPrincipal(virtPath, user, "GET"))
{
return false;
}
I have solved it. I hope it will help someone.
Some fixes to the configuration (Attached). All users allowed but filtered at lower level folders.
Installing missing authorization handlers at the IIS on the OS (Turn windows features on...)
Use the local IIS and not IIS Express from the visual studio
Clean the IIS Express configurations at the user data folder (C:\Users\\Documents\IISExpress\config) if the IIS visrtual folder creation fails
Give my azman store a reader security privilege (at the azman console) for the service application pool user (from the IIS).
Configuration:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add name="LocalPolicyStore" connectionString="msxml://c:/RolesData/ExcelGeneration.xml" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<authorization>
<allow users="*" />
</authorization>
<identity impersonate="false" />
<roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="RoleManagerAzManProvider" cookieName=".ASPXROLES" cookiePath="/" cookieTimeout="30" cookieRequireSSL="true" cookieSlidingExpiration="true" createPersistentCookie="false" cookieProtection="All">
<providers>
<add name="RoleManagerAzManProvider" type="System.Web.Security.AuthorizationStoreRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, publicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalPolicyStore" applicationName="ExcelGeneration" />
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="UseAspNetRoles"
roleProviderName="RoleManagerAzManProvider" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ExcelGeneratingService.ExcelGeneratorService" behaviorConfiguration="metadataBehavior">
<endpoint address="" bindingConfiguration="excelGeneratorServiceBinding" binding="basicHttpBinding" contract="ExcelGeneratingService.IExcelGeneratorService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="excelGeneratorServiceBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<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>
I'm getting the following error while deploying my ASP.NET MVC 4 application (Code First) to IIS:
"An error occurred while getting provider information from the database.
This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."
I've been looking around for answers, but none of the situations matches mine:
I got 2 projects
BackEnd (DataAccess with Code First + WCF services)
FrontEnd MVC 4 application (only service references to WCF services)
On my local IIS + SQL Server 2008 it works fine. Even if I change connectionstring to production database everything works as espected.
The problem occurs when deploying the BackEnd + FrontEnd to IIS.
The only connection string that accesses db is located in my BackEnd application:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="fromMail" value="xxx#gmail.com" />
</appSettings>
<connectionStrings>
<add name="TTCWestelDbContext" connectionString="Data Source=192.168.2.14\SQLSERVER2008;Initial Catalog=TTCWestel001;Persist Security Info=True;User ID=XXX;Password=XXX" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="102400" executionTimeout="3600" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<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="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\Temp\WCFTracesTTCWestel.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
Any help appreciated!!
Thanks
Micclo