wcf-client

How can I specify an alternate config file for a WCF client?

一世执手 提交于 2019-11-29 10:25:43
I am working on a large system, for which I have to use WCF to access a web service. My test code works fine, now I need to integrate my WCF client code into the larger system. I cannot add to the existing 'app.config' file, and would like specify a separate .config file for use by my client code. How best can I accomplish this? Thanks! There are 2 options. Option 1. Working with channels. If you are working with channels directly, .NET 4.0 and .NET 4.5 has the ConfigurationChannelFactory . The example on MSDN looks like this: ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

WCF client-side error-handling

↘锁芯ラ 提交于 2019-11-29 10:19:23
I'm consuming a clunky WCF server that occasionally throws various exceptions, and additionally returns some of its errors as string . I have no access to the server code at all. I want to override the inner WCF-client request invocation method and handle all inner exceptions and hard-coded errors returned by the server and raise the Fault event if an error occurs, pseudo: class MyClient : MyServiceSoapClient { protected override OnInvoke() { object result; try { result = base.OnInvoke(); if(result == "Error") { //raise fault event } catch { //raise fault event } } } So that when I call

WCF -> ASMX and Cookies

荒凉一梦 提交于 2019-11-29 08:46:50
I have a web application that communicates to a WCF service through a WCF client. At the point my code is invoked, authentication cookies have been issued and I have a dependency on an ASMX service that expects those authentication cookies. I need to pass the cookies from the web application through the WCF client to the WCF service to the ASMX service. Any ideas? It looks like my best bet may be setting allowCookies to false, parsing out the cookie headers, attempting to re-create them on the WCF service and then attaching them to the SOAP request. Note: I looked at this article , which seems

How can I set the maxItemsInObjectGraph property programmatically from a Silverlight Application?

假如想象 提交于 2019-11-29 06:55:25
I have a Silverlight 3.0 application that is using a WCF service to communicate with the database, and when I have large amounts of data being returned from the service methods I get Service Not Found errors. I am fairly confident that the solution to it is to simply update the maxItemsInObjectGraph property, but I am creating the service client progrogrammatically and cannot find where to set this property. Here is what I am doing right now: BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None) { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue };

Problem with generating WebService proxy using svcutil

可紊 提交于 2019-11-29 06:51:27
In our application we are forced to consume several WebServices. In the beginning we used just the "Add Service Reference" menu option, in order to create a WCF proxy. The wizard didn't generate a DataContract, but much rather an XML-Serializable class. So far, so bad, but this wasn't the killer. However, later we noticed, that we were losing data, because the generated proxy was adding the Order property when attributing and this was causing problems. Now we are trying to generate proxy classes from the WSDL using the SVCUTIL.EXE, but we are all the time getting the following error message: C

WCF Service Client Lifetime

徘徊边缘 提交于 2019-11-29 02:08:54
I have a WPF appliction that uses WCF services to make calls to the server. I use this property in my code to access the service private static IProjectWcfService ProjectService { get { _projectServiceFactory = new ProjectWcfServiceFactory(); return _projectServiceFactory.Create(); } } The Create on the factory looks like this public IProjectWcfService Create() { _serviceClient = new ProjectWcfServiceClient(); //ToDo: Need some way of saving username and password _serviceClient.ClientCredentials.UserName.UserName = "MyUsername"; _serviceClient.ClientCredentials.UserName.Password = "MyPassword"

How to make sure you don't get WCF Faulted state exception?

不想你离开。 提交于 2019-11-28 15:31:31
I am getting this exception: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. The WCF service uses the default wsHttpBinding. I am using WCF in the following way wherever I am using it: using (var proxy = new CAGDashboardServiceClient()) { proxy.Open(); var result = proxy.GetSiteForRegion(ddlRegions.SelectedValue); ddlSites.DataSource = result; ddlSites.DataBind(); proxy.Close(); } The error line shown in the message seems to be after last proxy.close. Not sure what is going on. I am launching the

There was no endpoint listening at <URI> that could accept the message. This is often caused by an incorrect address or SOAP action

☆樱花仙子☆ 提交于 2019-11-28 12:07:35
I have two WCF clients consuming a 3rd party web service. These two clients execute the same method call. In the one case it works every time, in the other I get the "There was no endpoint listening ..." message. As far as I can tell, the only difference between the two calls is that they are in two different client exes, and that means that the .exe.config files are not the same. They use the same source code, which is shared between the two projects in Visual Studio, so that's not different. But in fact the content of those two exe.config files is (almost) exactly the same; the only

Accessing PerSession service simultaneously in WCF using C#

前提是你 提交于 2019-11-28 09:03:48
问题 1.) I have a main method Processing, which takes string as an arguments and that string contains some x number of tasks. 2.) I have another method Status, which keeps track of first method by using two variables TotalTests and CurrentTest. which will be modified every time with in a loop in first method(Processing). 3.) When more than one client makes a call parallely to my web service to call the Processing method by passing a string, which has different tasks will take more time to process.

WCF client-side error-handling

纵饮孤独 提交于 2019-11-28 03:15:11
问题 I'm consuming a clunky WCF server that occasionally throws various exceptions, and additionally returns some of its errors as string . I have no access to the server code at all. I want to override the inner WCF-client request invocation method and handle all inner exceptions and hard-coded errors returned by the server and raise the Fault event if an error occurs, pseudo: class MyClient : MyServiceSoapClient { protected override OnInvoke() { object result; try { result = base.OnInvoke(); if