My server config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="500000000"></requestLimits>
</requestFiltering>
</security>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="HttpEndpointBinding" receiveTimeout="00:10:30" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="524288">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="mobservice.ImobService">
<endpoint address="" binding="basicHttpBinding" contract="mobservice.ImobService" bindingConfiguration="HttpEndpointBinding" name="BasicHttpBinding_MobileService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior >
<serviceMetadata httpGetEnabled="true" httpGetUrl="" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" httpHelpPageUrl="" />
<dataContractSerializer maxItemsInObjectGraph="60000000"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
My client config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ImobService" sendTimeout="00:10:30" maxBufferSize="250000000" maxBufferPoolSize="250000000" maxReceivedMessageSize="250000000">
<readerQuotas maxDepth="4500000" maxStringContentLength="4500000" maxArrayLength="4500000" maxBytesPerRead="40960000" maxNameTableCharCount="250000000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://anishk.india-powai.orioninc.com/mobservice/MobService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ImobService" contract="MobileService.ImobService" name="BasicHttpBinding_ImobService" />
</client>
</system.serviceModel>
</configuration>
Service contract:
[OperationContract]
void InsertEmployeeData(EmployeeDetail empName);
Method definition:
public void InsertEmployeeData(EmployeeDetail empName)
{
ctx.EmployeeDetails.AddObject(empName);
ctx.SaveChanges();
}
Call from client:
EmployeeDetail data = new EmployeeDetail();
data.EmployeeName = collection.Get("EmployeeName");
data.Designation = collection.Get("Designation");
data.EmailID = collection.Get("EmailID");
data.City = collection.Get("City");
data.State = collection.Get("State");
data.Country = collection.Get("Country");
data.Photo = ConvertImage(@"E:\Anish\S6M0.png");
conn.InsertEmployeeData(data);
while trying to pass EmployeeDetail object with photo as byte array to wcf service gets exception. Image with 6kb gets inserted .but image with size 50 kb throws exception:
The remote server returned an unexpected response: (400) Bad Request.
But i need to do with image size up to 2 mb.