wcf-client

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

a 夏天 提交于 2019-11-28 00:23:05
问题 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! 回答1: 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

Intercept messages in a WCF Client

帅比萌擦擦* 提交于 2019-11-28 00:17:19
Has anyone got any experience with Web Service Extensions? I spent time trying to make a web service extension from the MS examples. I have an .net 3.5 web service client, built by adding a reference to the WSDL, via the VS IDE "Project > Add Service Reference". This built my web service client, and all works OK. I need to intercept the request and response body for my web service client. I have found lots of references to Web Service Extensions, but am having an attack of the tired, and just can't get my extensions to fire. I've used the MS example from here "How to implement a SOAP extension

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

无人久伴 提交于 2019-11-27 09:16: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

Error consuming webservice, content type “application/xop+xml” does not match expected type “text/xml”

馋奶兔 提交于 2019-11-27 07:46:51
I'm having a weird issue when consuming a webservice for a product that my company has bought. The product is called Campaign Commander and it's made by a company called Email Vision. We're trying to use the "Data Mass Update SOAP API". Whenever I try to call any of the methods on the webservice, the call actually succeeds but the client fails when processing the response and I get an exception. The details of the errors are below, thanks for any help you guys can offer. Error using Web Reference (old style webservice client) When consume the service as a Web Reference I get an

How to consume WCF web service through URL at run time?

独自空忆成欢 提交于 2019-11-27 04:50:28
I want to access all the methods exposed in the service through the URL. if suppose the URL will be : http://localhost/MyService/MyService.svc How can I access methods: if suppose I have a ServiceReference and what should I do if don't have the Service Reference. In order to use a WCF service, you will need to create a WCF client proxy. In Visual Studio, you would right-click on the project and pick the "Add Service Reference" from the context menu. Type in the URL you want to connect to, and if that service is running, you should get a client proxy file generated for you. This file will

WCF change endpoint address at runtime

梦想的初衷 提交于 2019-11-26 21:45:15
I have my first WCF example working. I have the host on a website which have many bindings. Because of this, I have added this to my web.config. <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> This is my default binding http://id.web , which works with the following code. EchoServiceClient client = new EchoServiceClient(); litResponse.Text = client.SendEcho("Hello World"); client.Close(); I am now trying to set the endpoint address at runtime. Even though it is the same address of the above code. EchoServiceClient client = new EchoServiceClient(); client.Endpoint.Address = new

Specify the outgoing IP address to use with WCF client

依然范特西╮ 提交于 2019-11-26 21:43:19
问题 How to define the LocalEndPoint to use by a WCF client when calling a WCF service (if the client machine has multiple IP addresses) ? I have a machine located in a DMZ with two IP addresses, the external IP address can be reached through the firewall via a VPN connection from our webserver, located at an external service provider. On this machine runs a WCF and Unity-based custom app server, which should act as proxy or application level gateway (ALG). It shall accept the service calls from

Intercept messages in a WCF Client

孤人 提交于 2019-11-26 21:40:44
问题 Has anyone got any experience with Web Service Extensions? I spent time trying to make a web service extension from the MS examples. I have an .net 3.5 web service client, built by adding a reference to the WSDL, via the VS IDE "Project > Add Service Reference". This built my web service client, and all works OK. I need to intercept the request and response body for my web service client. I have found lots of references to Web Service Extensions, but am having an attack of the tired, and just

How to programmatically connect a client to a WCF service?

时光怂恿深爱的人放手 提交于 2019-11-26 12:47:46
I'm trying to connect an application (the client) to an exposed WCF service, but not through the application configuration file, but in code. How should I go about doing this? Enrico Campidoglio You'll have to use the ChannelFactory class. Here's an example: var myBinding = new BasicHttpBinding(); var myEndpoint = new EndpointAddress("http://localhost/myservice"); using (var myChannelFactory = new ChannelFactory<IMyService>(myBinding, myEndpoint)) { IMyService client = null; try { client = myChannelFactory.CreateChannel(); client.MyServiceOperation(); ((ICommunicationObject)client).Close();

How to consume WCF web service through URL at run time?

ぐ巨炮叔叔 提交于 2019-11-26 11:21:42
问题 I want to access all the methods exposed in the service through the URL. if suppose the URL will be : http://localhost/MyService/MyService.svc How can I access methods: if suppose I have a ServiceReference and what should I do if don\'t have the Service Reference. 回答1: In order to use a WCF service, you will need to create a WCF client proxy. In Visual Studio, you would right-click on the project and pick the "Add Service Reference" from the context menu. Type in the URL you want to connect