Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17



Windows Communication Foundation (WCF) is a tool used to implement and deploy a service-oriented architecture (SOA) to support distributed computing where services have remote consumers. It features a runtime and a set of APIs in the .NET Framework for building connected, service-oriented applications. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, regardless of which platform the service is hosted on. WCF implements many advanced Web services (WS) standards such as WS-Addressing, WS-ReliableMessaging, WS-Security, RSS Syndication Services, WS-Discovery, routing and better support for REST services.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a C# WCF Service which is hosted in IIS 8.5 and has a number of web services. One of these web services is called MobileRegistration and when called from the Client works correctly (see below)

using (var svc = new DCRulesServiceRef1.TransactionClient())
{string returnval = svc.MobileRegistration(enterpriseId, userId, deviceId, qrcode);}

Open in new window

However I also need to be able to call the webservice MobileRegistration directly via a URL without having to go through the client. The URL I created is as follows
This fails with HTTP400 Webpage cannot be found.  does return the TransactonService Service page successfully.  So why can it not find my service. Is the format of the URL incorrect for a WCF web service ? Below is some of the relevant code and WSDL. Appreciate if someone can point out what I am doing wrong


Operation Contract for MobileRegistration web service
[WebGet(UriTemplate = "MobileRegistration?enterpriseId={enterpriseId}&userId={userId}&deviceId={devicerId}&qrcode={qrcode")]

        string MobileRegistration(string enterpriseId, string userId, string deviceId, string qrcode);

Open in new window

Web.config file
   <!-- Required to prevent error

Open in new window

On Demand Webinar: Networking for the Cloud Era
LVL 10
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

I have WCF service which emails invitation for members to join a particular enterprise. The URL sent to the users is as follows:

Please respond to invitation using the Link below:

This would take this to the Invite Page where they could accept or reject the invitation. This all worked fine until recently. However now when the URL is clicked, instead of going to the invite page , it seems to be trying to redirect to the Login Page. Nothing is displayed but the URL displayed on the browser is as follows:

I am not sure why this is happening or how I would go about debugging. Appreciate some suggestions.
I am part of a development for a SOAP web services client on WCF/.NET. After a session of sending request, team for server side left feedback "extend someAction from schema i am mentioning below", and mentioned an URL. In this context, what does it mean to extend from schema?
Hello sir , i'm using WCF services in both web application and android . Now i want to implement encryption and decryption of various id's  so if i apply the encryption and decryption then on the web end i can easily manage the code but for android developer this is very hectic problem therefore suggest me how can i manage the code.
I have a class called "globals" which holds multiple classes that are use by my WCF application. So for example globals consists of up to 50 classes. Until now I have been defining classes with globals  as follows:

   public class Commands
        DataSet ds = new DataSet();
        DataTable dt1=new DataTable("dt1");
        DataSet ds2 ;//= new DataSet("ds2");
        DataTable dt2; //= new DataTable("dt2");
        DataRow dr2;
        string[] delimitedList1;
        string[] delimitedList2;
        string[] delimitedList3;
        string[] delimitedList4;
        string[] delimitedList5;

        string currentDataType = null;
        string ds1XmlString = " ";
        string ds2XmlString = " ";
        string myStringValue = "";
        int cnt = 0;
        DataSet dsCopy = null;
        DataSet dsCopy2 = null;
        DataSet cltDS = null;
        DataSet dsSav1 = null;
        DataSet dsSav2 = null;
        DataSet dsSav3 = null;
        DataTable fileSchema;
        public Commands()


Open in new window

      globals g;

I now realize that by placing globals into class Commands that it is part of this class rather than a reference.I want to create class Commands and be able to reference variables that are available in globals without having to imbed globals as part of class commands. Appreciate if someone can explain how I can achieve this ?

I have a simple page (SOAP Request) I can call in  a browser or from app

I type in the two variables and it returns a success or fail string

How do I call that in a C# Web Page?
I have a WCF Service written in C# which makes extensive user of global variables. The Service runs menus and transaction which are made up of sequenced database records with each database record capable of calling specific logic based on inbuilt commands. A typical simplistic example could be:

  05  Start
  10  Display Screen
  20  Input Range of Items
  30  run SQL statement to retrieve item details from Item master table
  40  Display Item Details
  50  Confirm selected Items
*60  Run SQL statement to report on Item Usage
*70  Output SQL results to CSV  
*80  Email usage report to user
  90  Goto Start

Those marked with * should run in a background thread so that after seq 50 the user will be returned to seq 05 whilst the background thread takes over. The issue I have is that Many of the variables controlling the transactions are global variables and so when the user returns to 05 and then exists to a new transactions this effects the background job since the background job is running the same code as the UI , except in the background thread.

I have copied all of the variables from UI to the background thread however the UI continues to update these global background thread variables after the background thread is launched. How can I stop the UI from affecting the background thread global variables ?

Hi Team,

We would like to secure our API so that no body can hack the same.
We are working in .Net platform. Please provide some input to implement the same.

Reason to secure

1) Hacking
2) Data security

Please let me know
SRCarrierInfo.CarrierAgentActInfoServiceClient cgsClient = new SRCarrierInfo.CarrierAgentActInfoServiceClient();
cgsClient.GetCarrierWebsiteInformation(); //this is custom class library it will be returned. The name is likes: List<Domain.Carrier>

how can i expose my class library to the public? I use DNN 8 as client to call above object. and I can not reference my custom class library inside of DNN module project.
How can a WCF Service return a file (perhaps in stream?) based on its file type?

The idea is to let the end user calling the web method and then to get the file downloaded to end user.

Thank you.
Enroll in September's Course of the Month
LVL 10
Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!


My question is simple; i am gonna to call below service :

But; something is wrong, it is returning to me Data Not Found. How can i fire it? My c# code is :

  myService.GlobalWeatherSoapClient client = new myService.GlobalWeatherSoapClient();
            Console.WriteLine(client.GetWeather("Stockholm", "Sweden"));
            Console.WriteLine(client.GetWeather("Berlin", "Germany"));

Open in new window

I need to update an existing WCF service to allow labels to be printed from locally attached DYMO Labelwriter 450 printers (attached by USB port to the client). In the client application I have installed the following from nuget packages.

DYMO SDK Library with default label V1.0.1
DYMO Label Framework TypeScript.Definitily.Typed V0.6.3

If I specify the code below I get a  Namespace error. I have checked the assemblies after the Nugut upload but there are no DYMO assemblies present.  What am I doing wrong. How can I get the client to recognise the DYMO Labelprinter. Appreciate any help or examples that anyone can give me.

using DYMO;  
public void PrintLabel(string serial_num, string part_Num)
            var label = DYMO.Label.Framework.Label.Open(AppDomain.CurrentDomain.BaseDirectory + "Barcode.label");
            label.SetObjectText("Bar_code", serial_num);
            label.SetObjectText("text_box", part_Num);
            label.Print("DYMO LabelWriter 450 Turbo");
I've built the default Visual Studio 2015 C# WCF Service Application.  Runs fine with the included client using the default connection http://localhost:50127/Service1.svc

For further testing I'm using Terra Term with the same URL, with and without the service1.svc, http, :50127 etc. Always get an Invalid Host error!

When I publish to a server (with its own IP) I have the same problem

Might this be related to the 50127 port and if so how would I change that?
I am having problems connecting to an Oracle database from my C# WCF service. In the WCF service I am already connecting to multiple DB2 and SQL databases successfully via the following ole connection string.

mySqlStmt =  "select * from myfile"
myConnectionString =  "Provider=sqloledb; Data Source=DEV\SQLEXPRESS;Initial Catalog=MyDataBase;User Id=user123; Password=pass123"

OleDBConnection conn = new OleDBConnection(myConnectionString);
OleDbCommand cmd = new OleDbCommand(mySqlStmt, conn);

This has worked well for me. However I now need to connect to an Oracle database with the existing software. I have been given the connection details

Data Source=TestDB
User Id= User123
Password= Pass123

I downloaded Oracle XE to our Windows 2012 server and updated the TNSNAMES.ORA file with the connection details and then created a .UDL file to test the connection to the oracle database.  By keying in the above Data Source, User name and Password to the test connection properties I got "Test connection Succeeded"  The Oracle provider listed in the test connection is "Oracle Provider for OLE DB"

I then set up a new connection string in my application as follows:

Provider=OraOLEDB.Oracle;Data Source=TestDB;User Id=User123;Password=Pass123;

However when my application tries to connect to the database via my application I get an error message "
I have a WCF service that can only be accessed by domain users. I used the following config:
        <authentication mode="Windows" />
            <deny users="?" />

Open in new window

The service is hosted on IIS 6, where Windows authentication is enabled and anonymous - disabled. the above worked fine for me but now i want to limit access to only a single uers. i tried the following:

        <authentication mode="Windows" />
            <allow users="DOMAIN\user1" />
            <deny users="*" />

Open in new window

but that did not work - all the domain users have access, not just user1.

I also tried:
            <allow users="DOMAIN\Group1"/>
            <deny users="DOMAIN\Domain Users"/>

Open in new window

I also tried to utilize PrincipalPermission attribute to limit access to a method:

 [PrincipalPermission(SecurityAction.Demand, Role = "Group1")]

Open in new window

But it did not make any difference at all. What can i do to limit the access to a user or group?
I have a WCF Service which I need to host on an old IIS 6 server. The server has a name Server1 but also has an alias used for the website. Apparently the server and the website resolve to different IP addresses.

So WCF Service path is

Open in new window

But when I look at xml generates, the schemaLocation shows up as:

      <xsd:schema targetNamespace="">
         <xsd:import schemaLocation="" namespace="" /> 
         <xsd:import schemaLocation="" namespace="" /> 
         <xsd:import schemaLocation="" namespace="" /> 

Open in new window

If I try accessing the schema specified in the xml

Open in new window

I get "Page cannot be displayed" error, and if I use Network tab in Chrome debug tools, it shows the call has been aborted. But if I try accessing the schema at

Open in new window

Then I can get to it without a problem but, unfortunately this is not the one used by the service.

To change that I added httpsGetURL in my config file:

<serviceMetadata httpGetEnabled="true" httpsGetUrl=""  />

Open in new window

that caused error: "A registration already exists for URI"

which I was able to get rid of by adding "/mex" after ".svc". The strange thing is that I do not have mex endpoint since I cannot use it due to disabled anonymous authentication.

But adding "/mex" caused another error "The message with To ''
cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.
Check that the sender and receiver's EndpointAddresses agree."

So then I added address to my endpoint, changing it from

<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>

Open in new window


<endpoint address="web1" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>

Open in new window

and tried using

Open in new window

that changed my error to

Open in new window

I have a .NET project to which i want to add a reference to my WCF service hosted on a different server. When I open my service in IE, it works fine:

Open in new window

But when I try to create a service reference using the above url, I cannot - getting "The document was understood, but it could not be processed"

Can anyone help?
I ran my WCF service on the server without SSL enabled and now I moved it to one with SSL enabled and I am getting the following error:

Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].

Open in new window

Below are my settings:

        <binding name="basicHTTP">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows">
      <service behaviorConfiguration="basicBehavior" name="ProjectName.MyService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHTTP" contract="ProjectName.IMyService"/>
        <behavior name="basicBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>

Open in new window

This is my first time that I’m trying to setup a service to require SSL connections.  The service is accessible but when I try to run one of the methods (Using both WCF Test Client as well as a Web application) I get this error:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

Value cannot be null.
Parameter name: context

Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
Free Tool: Site Down Detector
LVL 10
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hello Everyone,

I would like to ask you what is the best way to make a single object instance public to other processes ?  
As COM server exe is not directly foreseen is WCF still the right candidate ?

What do you think ?
Thank you very much in advance
Best regards.
I am using Powershell Studio to build a gui and the issue i have here is data is not getting appended... attached is the code.. Can someone help me in this ?
I have a project. basically, create wcf service to allow our clients to consume our wcf services.
In the past, I heard so many issues about cross domain and etc.

In addition, I want to learn how to documentation. basically let our clients' IT team to write PHP or .net and consume our wcf service.
Do you know there is any reference include all above.?

I have a WCF service running with separate client software that connects to it.  All works fine in development when on one PC.  Also works fine in Live as long as client running on the same computer as WCF service but fails with timeout when connecting remotely.  I tried on two different 'live' environments and completely disabled the firewall (while testing) in both cases.

Here's the code that works locally:

Dim WithEvents CommsServerCallback As New AutomatedWeighbridgeInterventionCallback
Dim objClient As InterventionServiceReference.IInterventionService
Dim EndPointAddress As String
If Testing Then EndPointAddress = "http://localhost:8000/InterventionService/" Else EndPointAddress = "http://WCFServerPC:8000 InterventionService/"
Dim iCntx As New InstanceContext(CommsServerCallback)
Dim MyBinding As New WSDualHttpBinding
MyBinding.SendTimeout = New TimeSpan(0, 0, 30)
Dim MyEndPoint As New EndpointAddress(EndPointAddress)
Dim myChannelFactory As DuplexChannelFactory(Of IInterventionService) = New DuplexChannelFactory(Of IInterventionService)(iCntx, MyBinding, MyEndPoint)
objClient = myChannelFactory.CreateChannel()
      If Not objClient.SubscribeClient() Then Throw New Exception("Unable to Connect")
Catch ex As Exception
      Throw ex
End Try

Open in new window

When this runs on the same computer as the WCF service (name: WCFServerPC), both endpoints declared above work.  When this runs on a separate PC on the same network, it fails with a timeout at 'objClient.SubscribeClient()'.  Firewall is disabled.  What am I missing?  (e.g. is there some 'AllowRemoteConnections=False' setting in the app config somewhere or similar?)
I am planning to use WCF rest JSON.  In past I have seen serialization issues it.  I read people using newtonsoft.json as default serializer

I see some explanation below of using it. I need some example where we I can use with newtonsoft.json . also want to handle throw back http errors to the client

One more question Other have to host on windows service so going with WCF . I dont tjhink Web api is solution here??

I built a WCF Service that uses custom username and password authentication and I am testing it from the client app with the following code:

    using (ServiceReferenceClient.TestServiceClient tc = new ServiceReferenceClient.TestServiceClient())
    	tc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        tc.ClientCredentials.UserName.UserName = "User1";
        tc.ClientCredentials.UserName.Password = "Pwd1";
        tc.ServiceMethod(param1, param2, param3);

Open in new window

It works fine but I need to see the actual SOAP request sent to the WCF service and response. How can I do that from my client?


Windows Communication Foundation (WCF) is a tool used to implement and deploy a service-oriented architecture (SOA) to support distributed computing where services have remote consumers. It features a runtime and a set of APIs in the .NET Framework for building connected, service-oriented applications. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, regardless of which platform the service is hosted on. WCF implements many advanced Web services (WS) standards such as WS-Addressing, WS-ReliableMessaging, WS-Security, RSS Syndication Services, WS-Discovery, routing and better support for REST services.

Top Experts In