WCF and .NET 3.5: receiving large arrays - c#

I am struggling to understand what I am doing wrong. I have a simple interface that accepts an array. I can't make it to handle more than ~150 items - getting back 400 Bad Request. What am I doing wrong? Can anyone spot anything? I looked thru this post and it appears to be the answer but it doesn't work for me: WCF maxReceivedMessageSize not being read from config.
The service is hosted in IIS7 and uses .NET 3.5. Here is my web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyService.basicHttpBinding" maxReceivedMessageSize="5000000" maxBufferSize="5000000">
<readerQuotas maxStringContentLength="5000000" maxArrayLength="5000000" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- Please set this to false when deploying -->
<serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyService.Service1Behavior" name="MyService">
<endpoint address="ws" binding="wsHttpBinding" contract="IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint binding="basicHttpBinding" bindingConfiguration="MyService.basicHttpBinding" contract="IMyService" />
</service>
</services>
</system.serviceModel>

To troubleshoot turn on tracing both on the server and on the client, then inspect the log file. The error message points more to an object not being marked as [Serializable].
See http://msdn.microsoft.com/en-us/library/ms732023.aspx for guidance.

What's the config on the receiving end? I found the serializer blew up on receipt of lots of data.

Related

Problems with Hosting WCF service on IIS (Using WAS) for netTCP bindings?

I created a simple WCF service and hosted it in IIS by creating a new website. In Web.config file,I am providing bindings for http and net tcp.
I created a console client and adding service reference. It generates two binding in client config - for http and for tcp. When I try to invoke the service using tcp, I get this error -
An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll
Additional information: There was no endpoint listening at net.tcp://computername/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action.
when I run using Http endpoint , it works fine.
Note -
I am using Windows 10 OS, IIS 10.0 and WPAS\WAS (Windows Process Activation Service) are installed. I already enabled\checked HTTP Activation, TCP Activation in .Net framework in Windows features. And modified IIS server settings to include net tcp. Please check it in attached image.
My website Web.config file looks like
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NewBinding0" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="My" name="WCFServiceOM.Service1"> <!-- the service name must match the configuration name for the service implementation. -->
<endpoint address="" binding="basicHttpBinding" contract="WCFServiceOM.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint binding="netTcpBinding" bindingConfiguration="NewBinding0" contract="WCFServiceOM.IService1" />
<endpoint address="mexOM" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8087/Service1" />
<add baseAddress="http://localhost:7777/Service1"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehanior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="My">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
And my client App.Config look like
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IService1">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://computername:7777/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
<endpoint address="net.tcp://computername/Service.svc" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
name="NetTcpBinding_IService1" />
</client>
</system.serviceModel>

WCF strange Behavior

I have a strange WCF behavior. When the service is hosted on IIS I can navigate to the service url and see the service wsdl, but any hit on the service operations return a 404.0 not found exception.
so this works
http://localhost:8000/Simulators/BackendService/service.svc
and this doesn't work
http://localhost:8000/Simulators/BackendService/service.svc/ProcessRequest
The behavior happens on one machine only and I tried the same source code with the exact same web.config on 2 other machines and they work perfectly fine. Which makes me sure that the problem is the IIS configuration on my machine but I couldn't figure out what is the problem.
Would anybody know what could be causing that problem?
Thanks,
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
<bindings>
<customBinding>
<binding name="POXConfig">
<customTextMessageEncoding messageVersion="None" />
<httpTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="MSAD.Bawaba.Backend.WebHost.BawabaBackendServiceBehavior" name="BawabaTestingTool.Simulators.BackendService.Service">
<endpoint address="ProcessRequest" binding="customBinding" bindingConfiguration="POXConfig" contract="MSAD.Bawaba.Backend.Service.IBackendService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MSAD.Bawaba.Backend.WebHost.BawabaBackendServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<bindingElementExtensions>
<add name="customTextMessageEncoding" type="MSAD.Bawaba.Backend.CustomEncoderBinding.CustomTextMessageEncodingElement, MSAD.Bawaba.Backend" />
</bindingElementExtensions>
</extensions>

Deploying WCF Service Host App without WCF Service Host?

I have a WCF service hosted by a simple WinForms app. In Visual Studio the service is started via the built in WCF Service Host & everything works fine. I now want to host the service in my host app but currently the service doesn't run.
Service App:
ServiceHost host;
private void btnStart_Click(object sender, EventArgs e)
{
host = new ServiceHost(typeof(RegimesService));
host.Open();
lblStatus.Text = "Started...";
}
If I close WCF Service Host in the sys tray & click my start button, the code runs but the service never starts?
Here's my Service Host App config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metaBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="diiRegimesService.RegimesService">
<endpoint address="" binding="basicHttpBinding" contract="diiRegimesService.IRegimesService"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8081" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
& Finally my Service project App.config:
<system.serviceModel>
<services>
<service name="diiRegimesService.RegimesService">
<endpoint address="" binding="basicHttpBinding" contract="diiRegimesService.IRegimesService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
When I run netstat -a from cmd line, the port http://localhost:8080 isn't listening so it's like the service object never actually gets initialized. I'm sure it's a simple mistake in my configs somewhere, any ideas? Thanks
Port 8080 is a reserved port for SQL Server, Also your service App.config and Host App.config are having different ports in their base address
Ok, used the WCF configuration wizard from Solution Explorer & tied the ServiceBehaviour to the Service definition in the Host App's App.Config & hey presto, everything is wired up & working! Thanks for your help #Akshay Choudhary.

Could not find default endpoint element error

I am getting below error while consuming a WCF service. I have developed a wcf service which is being consumed by a usercontrol.And user control is used as module in DNN.
But if i simply consume the wcf in web application it is working fine but consuming in DNN module is giving below error
Could not find default endpoint element that references contract 'OperationService.IOperation' 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.
Please advise.
Client side config is below
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IOperation" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:54147/WCFService/Service.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IOperation"
contract="OperationService.IOperation" name="WSHttpBinding_IOperation">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Added service config of wcf service from comment
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Operation">
<endpoint address="" binding="wsHttpBinding"
contract="IOperation">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
copy the section from the app.config to your site's web.config. you may need to change the endpoint's address attribute.
The contract name needs to be fully qualified (namespace + name) in the <endpoint> element, like this:
<endpoint address="" binding="wsHttpBinding"
contract="OperationService.IOperation">
Also, make sure that the name attribute in the <service> element matches the name attribute in the .svc file markup.

WCF Test Client EndPoint error

IN my WCF Service, the WCF Test Client reports the following error
System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
My App.Config is this:
<?xml version="1.0" encoding="utf-8" ?>
<services>
<service name="Practicon.SAPServiceLibrary.SAPDownloadService" behaviorConfiguration="debug">
<endpoint address="net.tcp://localhost:8082/SAPDownloadService" binding="netTcpBinding" contract="Practicon.SAPServiceLibrary.ISAPDownloadService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<!--add baseAddress="http://localhost:8083/Design_Time_Addresses/Practicon/SAPServiceLibrary/SAPDownloadService/"/> -->
<add baseAddress="net.tcp://localhost:8082/SAPDownloadService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<!--<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>-->
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint name="PracticonSAPDownloadEndPointClient"
address="net.tcp://localhost:8082/SAPDownloadService"
binding="netTcpBinding"
bindingConfiguration="BindingConfiguration"
contract="Practicon.SAPServiceLibrary.ISAPDownloadService">
<identity>
<servicePrincipalName value=""/>
</identity>
</endpoint>
</client>
<bindings>
<netTcpBinding>
<binding name="BindingConfiguration"
transferMode="Buffered"/>
</netTcpBinding>
</bindings>
I have got a net.tcp Endpoint - the Service runs fine, just that this error is reported in the WCF Hosting.
Can someone explain what I've done wrong and how to correct it?
Thanks
MM

Categories

Resources