Here, when i am trying to send byte array it is giving me bad request error. I have checked with maximum values for all message limits. All are set to maximum value. However i am able to send string values to service method by keeping byte array parameter as null. I don't know why this happening here. I have also checked the service behavior configuration name and binding configuration names(i.e., included namespace) which seems to be fine.Any help is greatly appreciated.
This is my client side code:
....
ServiceClient ac = new ServiceClient();
string ServiceUrl = "http://localhost:20314/Service.svc";
EndpointAddress address = new EndpointAddress(ServiceUrl);
BasicHttpBinding httpbinding = new BasicHttpBinding();
using (ChannelFactory<IServiceChannel> factory = new ChannelFactory<IServiceChannel>(httpbinding))
{
factory.Endpoint.Address = address;
using (IServiceChannel oService = factory.CreateChannel())
{
using (OperationContextScope scope = new OperationContextScope(oService))
{
Guid myToken = new Guid("guid here");
MessageHeader<Guid> mhg = new MessageHeader<Guid>(myToken);
MessageHeader untyped = mhg.GetUntypedHeader("identity", "ns");
OperationContext.Current.OutgoingMessageHeaders.Add(untyped);
// here i am getting bad request error
var fdt = (oService).GetData(bytearray, value);
}
}
}
.......
client web config:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime maxRequestLength="500000000" executionTimeout="360"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="01:01:00"
openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" 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:20314/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="LocalService.IService"
name="BasicHttpBinding_IService"/>
</client>
<services>
<service name="LocalService.Service" behaviorConfiguration="ServiceBehavior">
<endpoint address="http://localhost:20314/Service.svc" binding="wsHttpBinding" contract="LocalService.IService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Service Web Config
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="500000000" executionTimeout="360"/>
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthorization serviceAuthorizationManagerType="ServiceApp.APIKeyAuthorization, ServiceApp" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint
automaticFormatSelectionEnabled="true"
helpEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>