https not working for virtual diractory - c#

I configure the SSL for my website https://www.test.com. i had one virtual diractory in it testwcf. when i access it with https://www.test.com/testwcf/Common.svc. Message shown You have created a service. but when i access any method in service, for example
https://www.test.com/testwcf/Common.svc/select?id=1 i get the error The resource cannot be found.. but it works fine with http i.e.http://www.test.com/testwcf/Common.svc/select?id=1. Can anybody help me to solve this problem. I search on net alot but nothing work for me
Below is my websconfg
<services>
<service name="testwcf.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="testwcf.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>
</system.serviceModel>

You'll need to update the binding for your service to use transport security. Add a secure binding like:
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
And then change your service config to use that binding.
<services>
<service name="MySecureWCFService.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="MySecureWCFService.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
More info at http://msdn.microsoft.com/en-us/library/hh556232(v=vs.110).aspx

Related

WCF error: wshttpbinding The caller was not authenticated by the service

I have created the WCF stateful service and consume it in my window application. I have faced "The caller was not authenticated by the service" issue While running the application.
Web.Config file:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding1" messageEncoding="Text" textEncoding="utf-8">
<!--<security mode="None">-->
<security mode="Message">
<!--<transport clientCredentialType="None"/>-->
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="REST.IPBX" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="WCF_IPBX.IIPBX">
<identity>
<dns value="http://xyz.xxx.w.y/"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>

Windows Service (413) Request Entity Too Large

Please do not delete this as a duplicate
I have a windows service that I am passing an array of objects to. When the array contains less than 150 objects it works successfully. When I pass more than 150 objects I get the (413) Request Entity Too Large Error.
I have tried the feedback from other articles regarding readerQuotas node values and maxReceivedMessageSize, but I am still receiving the error and I am stuck as to what I am still doing wrong.
Here is the app.config of the windows service:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingNoSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None"/>
<message establishSecurityContext="false" negotiateServiceCredential="false"/>
</security>
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="SE.Responder.Integration.AmiOutboundService.AmiObService" behaviorConfiguration="Service1Behavior">
<endpoint address="wsHttp" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoSecurity" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="basicHttp" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" name="basicHttp" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
And here is the app.config of the executable that passes the data to the windows service:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAmiObService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/AmiOBService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAmiObService" contract="AmiObService.IAmiObService" name="WSHttpBinding_IAmiObService" />
</client>
After reviewing the source code for the application that was having this issue, I found that the wcf service was being hosted in the C# code. I then applied the fix in code as described in the following stack overflow issue,
MaxReceivedMessageSize in WCF Hosted Service in console application,
specifically the following lines,
var wsHttpBinding = new WSHttpBinding();
wsHttpBinding.MaxReceivedMessageSize = int.MaxValue;
Service.AddServiceEndpoint(typeof(TInterfaceContract), wsHttpBinding, EndpointAddress);
which corrected the issue.

maxReceivedMessageSize WCF

I consume a WCF service, but I have a problem
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.
I have modified MaxReceivedMessageSize, but there is no result (I read many articles in the internet, but anyone can't help)
Who knows about this?
Service.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BindingWithMaxSizeIncreased"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="FootballLife.MyService" behaviorConfiguration="metadataBehavior">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="BindingWithMaxSizeIncreased"
contract="FootballLife.IMyService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Client.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BindingWithMaxSizeIncreased"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:90/MyService.svc"
binding="wsHttpBinding"
contract="IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
You need to give the custom bindingConfiguration to your endpoint in the client configuration:
<endpoint address="http://localhost:90/MyService.svc"
binding="wsHttpBinding"
contract="IMyService"
bindingConfiguration="BindingWithMaxSizeIncreased">
<identity>
<dns value="localhost" />
</identity>
</endpoint>

How to generate Proxy for WCF Service

I have some legacy code here, which has a WCF Service.
The service is called by a client through a generatedProxy.cs
I thought it should be simple and wanted to generate my own
proxy by using svcutil.exe, but I get lots of different errors,
depending on what I try (using running exe for download, using
assembly, using webconfig). For example the svcutil tells me
that the service may not publish metadata (seems to me that
this is not true).
the webconfig has:
<serviceMetadata httpGetEnabled="true"/>
And it has a multisite binding
How can I generate such a proxy? Want to change some things in the contracts
and then have a current version of the proxy generated.
At the moment I have no service reference, as it has the some errors
when adding one as the svcutil does.
Any ideas?
-edit-
The services are published through a selfhosted service, quite similar to
the one in the WCF examples in the msdn. There are the endpoints for
multiple services, which are implemented in dlls.
-edit 2-
Here is the app.config of the self hosting service
I have replaced some names, just to make it less special.
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="PersonDataModelContainer" connectionString="metadata=res://*/PersonDataModel.csdl|res://*/PersonDataModel.ssdl|res://*/PersonDataModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string="Data Source=|DataDirectory|\PersonDatabase.sdf"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<system.serviceModel>
<bindings>
<netMsmqBinding>
<binding name="TransactionalNoSecurity" durable="true" exactlyOnce="true" maxReceivedMessageSize="2147483647" maxRetryCycles="1" receiveRetryCount="20" retryCycleDelay="00:05:00">
<security mode="None"></security>
</binding>
</netMsmqBinding>
<basicHttpBinding>
<binding name="TransportSecurity" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</basicHttpBinding>
<ws2007HttpBinding>
<binding name="NoSecurity" transactionFlow="true" maxReceivedMessageSize="200000" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="None"></security>
</binding>
<binding name="UNMessageSecurity" transactionFlow="true" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="Message">
<message clientCredentialType="UserName" establishSecurityContext="true"/>
</security>
</binding>
<binding name="CertMessageSecurity" transactionFlow="true" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="Message">
<message clientCredentialType="Certificate" establishSecurityContext="true"/>
</security>
</binding>
<binding name="DomainMessageSecurity" transactionFlow="true" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="Message">
<message clientCredentialType="Windows" establishSecurityContext="true"/>
</security>
</binding>
<binding name="RM_NoSecurity" transactionFlow="true" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<reliableSession enabled="true" ordered="false"/>
<security mode="None"></security>
</binding>
</ws2007HttpBinding>
<netTcpBinding>
<binding name="NoSecurity" transactionFlow="true">
<security mode="None"></security>
</binding>
<binding name="DomainMessageSecurity" transactionFlow="true" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
</binding>
<binding name="CertMessageSecurity" transactionFlow="true" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="True" policyVersion="Policy15"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MessagePlatform.LoggingService.GeneralLoggingService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
</baseAddresses>
</host>
<endpoint address="Logging" binding="basicHttpBinding" name="LoggingService" contract="MessagePlatform.LoggingService.Contracts.ILoggingService"/>
</service>
<service name="MessagePlatform.GatewayService.GeneralGatewayService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/"/>
</baseAddresses>
</host>
<endpoint address="gateway" binding="basicHttpBinding" name="GatewayService" contract="MessagePlatform.GatewayService.Contracts.IGatewayService"/>
<endpoint address="gateway" binding="basicHttpBinding" name="Db2GatewayService" contract="MessagePlatform.GatewayService.Contracts.IDb2GatewayService"/>
<endpoint address="gateway" binding="basicHttpBinding" name="Db1GatewayService" contract="MessagePlatform.GatewayService.Contracts.IDb1GatewayService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<client>
<endpoint name="LoggingServiceEP" address="http://localhost/Logging" binding="basicHttpBinding" contract="MessagePlatform.LoggingService.ILoggingService">
</endpoint>
<endpoint name="GatewayServiceEP" address="http://localhost/gateway" binding="basicHttpBinding" contract="MessagePlatform.GatewayService.IGatewayService">
</endpoint>
<endpoint name="GatewayServiceDb2" address="http://localhost/gateway" binding="basicHttpBinding" contract="MessagePlatform.GatewayService.IDb2GatewayService">
</endpoint>
<endpoint name="GatewayServiceDb1" address="http://localhost/gateway" binding="basicHttpBinding" contract="MessagePlatform.GatewayService.IDb1GatewayService">
</endpoint>
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
You also need to enable the Metadata Exchange Endpoint so you can create a new proxy:
<service name="MessagePlatform.GatewayService.GeneralGatewayService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/"/>
</baseAddresses>
</host>
<endpoint address="gateway" binding="basicHttpBinding" name="GatewayService" contract="MessagePlatform.GatewayService.Contracts.IGatewayService"/>
<endpoint address="gateway" binding="basicHttpBinding" name="Db2GatewayService" contract="MessagePlatform.GatewayService.Contracts.IDb2GatewayService"/>
<endpoint address="gateway" binding="basicHttpBinding" name="Db1GatewayService" contract="MessagePlatform.GatewayService.Contracts.IDb1GatewayService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
and run
svcutil http://localhost:8000/mex

WCF binding not found error?

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"/>

Categories