setting maxBufferPoolSize of basicHttpBinding programmatically - wcf

I am trying to set the maxBufferPoolSize along with MaxReceivedMessageSize and MaxBufferSize. However, when I try to set it, i got the message "'maxBufferPoolSize' is not a member of 'System.ServiceModel.BasicHttpBinding'." I am using VS 2010. From MS Documentation, MaxBufferpoolSize is a member ( http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpbinding.maxbufferpoolsize). Why am I getting this error??? Please help. Thank you.
Dim basicHttpBinding As BasicHttpBinding = New BasicHttpBinding()
Dim endpointAddress As EndpointAddress = New EndpointAddress("/test.svc")
basicHttpBinding.MaxReceivedMessageSize = "2147483647"
basicHttpBinding.MaxBufferSize = "2147483647"
**basicHttpBinding.maxBufferPoolSize = "2147483647"**
basicHttpBinding.OpenTimeout = New TimeSpan(0, 20, 0)
basicHttpBinding.CloseTimeout = New TimeSpan(0, 10, 0)
basicHttpBinding.ReceiveTimeout = New TimeSpan(0, 10, 0)
basicHttpBinding.SendTimeout = New TimeSpan(0, 10, 0)
Dim Svc As Svc= New ChannelFactory(Of Svc)(basicHttpBinding, endpointAddress).CreateChannel
'... do the binding

Per the comments, you're using Silverlight, so that property doesn't exist in that framework. There's no buffer pooling in Silverlight, which is why it doesn't compile.

Related

.Net Core 2.0 timeout for WCF web service in c#

I am doing a .NET Core 2.0 App. I am calling a webService. I added a Reference to a local Service and call it from my Application.
ServiceReference1.QueryCalendarClient servicio = null;
ServiceReference1.ListCalendarDayTypeRequest request = new ServiceReference1.ListCalendarDayTypeRequest();
ServiceReference1.ListCalendarDayTypeResponse response = null;
var binding = new BasicHttpBinding();
binding.ReceiveTimeout = new TimeSpan(0, 25, 0);
binding.SendTimeout = new TimeSpan(0, 25, 0);
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.TransportCredentialOnly,
Transport = new HttpTransportSecurity()
{
ClientCredentialType = HttpClientCredentialType.Basic
}
};
servicio = new ServiceReference1.QueryCalendarClient(binding, new EndpointAddress("http://WebBasica?wsdl"));
servicio.ClientCredentials.UserName.Password = "123456789";
servicio.ClientCredentials.UserName.UserName = "user";
response = new ServiceReference1.ListCalendarDayTypeResponse();
response = servicio.Method(request.CalendarInquireRequest_MT).Result;
I have an time Out Exception.
The request channel timed out while waiting for a reply after
00:24:58.3211575. Increase the timeout value passed to the call to
Request or increase the SendTimeout value on the Binding. The time
allotted to this operation may have been a portion of a longer
timeout.
Any timeOut I set, gave me a TimeOut error...
Where can I set the time out?
What I am missing?
Thank

InsertAll using C# not working

I´d like to know why this code is not working. It runs without errors but rows are not inserted. I´m using C# client library.
Any ideas? Thanks!!
string SERVICE_ACCOUNT_EMAIL = "(myserviceaccountemail)";
string SERVICE_ACCOUNT_PKCS12_FILE_PATH = #"C:\(myprivatekeyfile)";
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate =
new System.Security.Cryptography.X509Certificates.X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret",
System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(SERVICE_ACCOUNT_EMAIL)
{
Scopes = new[] { BigqueryService.Scope.BigqueryInsertdata, BigqueryService.Scope.Bigquery }
}.FromCertificate(certificate));
// Create the service.
var service = new BigqueryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "test"
});
Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest tabreq = new Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest();
List<Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData> tabrows = new List<Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData>();
Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData rd = new Google.Apis.Bigquery.v2.Data.TableDataInsertAllRequest.RowsData();
IDictionary<string,object> r = new Dictionary<string,object>();
r.Add("campo1", "test4");
r.Add("campo2", "test5");
rd.Json = r;
tabrows.Add(rd);
tabreq.Rows = tabrows;
service.Tabledata.InsertAll(tabreq, "(myprojectid)", "spots", "spots");
I think you should add the Kind field [1]. It should be something like this:
tabreq.Kind = "bigquery#tableDataInsertAllRequest";
Also remeber that every request of the API has a response [2] with additional info to help you find the issue's root cause.
var requestResponse = service.Tabledata.InsertAll(tabreq, "(myprojectid)", "spots", "spots");
[1] https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/csharp/latest/classGoogle_1_1Apis_1_1Bigquery_1_1v2_1_1Data_1_1TableDataInsertAllRequest.html#aa2e9b0da5e15b158ae0d107378376b26
[2] https://cloud.google.com/bigquery/docs/reference/v2/tabledata/insertAll

Animate a canvas programatically using StoryBoard API in Windows Store App

I am animating a canvas in a Windows Store app using StoryBoard API:
DoubleAnimation widthAnimation = new DoubleAnimation();
DoubleAnimation heightAnimation = new DoubleAnimation();
widthAnimation.BeginTime = new TimeSpan(0, 0, 0, 0, outDuration + inDuration);
heightAnimation.BeginTime = new TimeSpan(0, 0, 0, 0, outDuration + inDuration);
widthAnimation.Duration = new TimeSpan(0, 0, 0, 0, collapseDuration);
heightAnimation.Duration = new TimeSpan(0, 0, 0, 0, collapseDuration);
Storyboard.SetTarget(widthAnimation, target);
Storyboard.SetTargetProperty(widthAnimation, "Width");
Storyboard.SetTarget(heightAnimation, target);
Storyboard.SetTargetProperty(heightAnimation, "Height");
widthAnimation.From = beginSize.Width;
widthAnimation.To = endSize.Width;
heightAnimation.From = beginSize.Height;
heightAnimation.To = endSize.Height;
Storyboard stb = new Storyboard();
stb.Children.Add(widthAnimation);
stb.Children.Add(heightAnimation);
stb.Begin();
However the width and height animation does not work. Any pointers on how to resolve it?
Fixed this issue using a related post in MSDN forums - http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/e660077c-1a8f-463c-a118-ebb4de008176/
Width and Height are dependent animations and hence it must be enabled explicitly using the following code:
widthAnimation.EnableDependentAnimation = true;
heightAnimation.EnableDependentAnimation = true;

Restlet WebService returning a PDF

I have a Restlet Web Service that is returning a PDF document and the client side needs to receive this docuement and display it.
Server Side Code:
orderNumber = f.getFirstValue(PARAM_ORDER_NUMBER);
orderType = f.getFirstValue(PARAM_ORDER_TYPE).toUpperCase();
String fileName = OrderDM.getPDF(orderNumber, orderType);
pdfRep = new FileRepresentation(new File(fileName), MediaType.APPLICATION_PDF, 0);
return pdfRep;
Client Side:
ClientResource client = getClientResource(PRINTER_FRIENDLY_DOCUMENT_RESOURCE);
Reference reference = client.getReference();
reference.addQueryParameter(PARAM_ORDER_TYPE, orderType);
reference.addQueryParameter(PARAM_ORDER_NUMBER, orderNumber);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
client.get().write(outputStream);
byte[] fileContent = outputStream.toByteArray();
Will this work and is this the best way to do this.

How to programmatically set WCF client maxBufferSize parameters?

I am setting wcf client parameters programmatically like below:
try
{
ServiceReference1.MyDbServiceClient webService =
new ServiceReference1.MyDbServiceClient(new System.ServiceModel.BasicHttpBinding(),
new System.ServiceModel.EndpointAddress((string)((App)Application.Current).Resources["wcfMyDBServiceEndPoint"]));
webService.GetSeriesImagesCompleted += new EventHandler<ServiceReference1.GetSeriesImagesCompletedEventArgs>(webService_GetSeriesImagesCompleted);
webService.GetSeriesImagesAsync(index);
}
It works just fine for the default maxBufferSize. However when a client exceeds the default size, an exception is throughn: "the maximum message size quota for incoming messages (65536) has been exceeded."
How to set this parameter in code?
Thanks.
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.CloseTimeout = new TimeSpan(00, 05, 00);
binding.OpenTimeout = new TimeSpan(00, 05, 00);
binding.ReceiveTimeout = new TimeSpan(00, 05, 00);
binding.SendTimeout = new TimeSpan(00, 05, 00);
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, XmlDictionaryReaderQuotas.Max, null);
Create binding based on your requirement.