WCF

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 couple of WCF services to host inside IIS.
Here is a snapshot of web.config
 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add service="ECMS.Business.Managers.SecretaryManager" relativeAddress="~/SecretaryService.svc" factory="ECMS.WebHost.CustomHostFactory" />
        <add service="ECMS.Business.Managers.SettingManager" relativeAddress="~/SettingService.svc" factory="ECMS.WebHost.CustomHostFactory" />
        <add service="SwaggerWcf.SwaggerWcfEndpoint" relativeAddress="~/Swagger.svc" factory="ECMS.WebHost.CustomHostFactory" />
      </serviceActivations>
    </serviceHostingEnvironment>

Open in new window


    <services>   
      <service name="ECMS.Business.Managers.SecretaryManager">
        <endpoint address="" behaviorConfiguration="WebHostFactoryService" binding="webHttpBinding" contract="ECMS.Business.Contracts.ISecretaryService" />
      </service>

         <service name="ECMS.Business.Managers.SettingManager">
        <endpoint address="" behaviorConfiguration="WebHostFactoryService" binding="webHttpBinding" contract="ECMS.Business.Contracts.IEcmsSetting" />
      </service>
      
      <service name="SwaggerWcf.SwaggerWcfEndpoint">
        <endpoint address="" behaviorConfiguration="WebHostFactoryService" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint" />
      </service>

    </services>

Open in new window


I deployed into IIS and when I request http://localhost/SecretaryService.svc

I got 404 not found exception.

Requested URL         http://localhost:80/SecretaryService.svc
Physical Path         D:\Electronic Clinic Management System (eCMS)\eCMS\ECMS.WebHost\SecretaryService.svc

Please help,
0
Why Diversity in Tech Matters
LVL 13
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

I have a remote machine runs a managed windows service which exposed a WCF on a specific port.

<endpoint address="net.tcp://127.0.0.1:8001/SecretaryService" binding="netTcpBinding" contract="ECMS.Business.Contracts.ISecretaryService" bindingConfiguration="EcmsNetTcpBinding" />

Open in new window


I made sure that the service is listening on the port locally by using "portqueryui.exe" utility from Microsoft.

I used the same utility to test the connection to the remote machine, port. It gives that unknown service is NOT LISTENING.

The remote machine is pingable!
I added firewall rules for the port. I turned off the windows defender with no luck.

Please help,
0
I am developing an electronic medical record (EMR) system.

I am designing and implementing the backend APIs using WCF.

Now, I have two system actors: secretary and doctor.

I designed the services according to the actor he/she is concerned.

[ServiceContract]
public interface ISecretaryService
{
}

[ServiceContract]
public interface IDoctorService : ISecretaryService
{
//the doctor has the functions of secretary in case she was absent!
}

Open in new window


The problem is I have duplicate code which is the implementation of the ISecretary contract in doctor service.
0
Hi,

I have a question. I have a existing WCF type framework that has like 8 difference .svc's and in each one of those .svc's there are like 40 different web services (methods) that are called.  This is in ASP.NET and C#.

I am going to start implementing REST aspects as well with ASP.NET and C#.

Is it wise to maintain 2 separate frameworks? One for REST methods (could also be 10-20 different methods) and that over existing SOAP svc's? Or do I combine the REST calls/process into the existing WCF?

If the suggestion is 2 separate frameworks... does anybody have an example of how that would be done in REST?

Any information would be greatly appreciated.

Thanks!
0
Hi,
I am developing on-premise Electronic Medical Records (EMR) app for a clinic.
I architected the solution using Domain Driven Design approach combined with the following architectural styles:
  • Layered architectural style: for structuring the solution and separation of concerns
  • 3-Tier architectural style: for deployment
     
  1. Database tier: Sql Server database
;
      [list=2]Application server tier[/list];
      [list=3]Presentation tier as a desktop app[/list].
  • SOA architectural style: for the communication between the desktop app and the application server; Where the application server exposes the business services.

I have the following error on the application server when I tried to access the WCF security service from the web browser:

"The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)."

Attached the solution source code.
eCMS---Anas.zip
0
I am having trouble while sending the request to a rest service. The service works fine on my desktop, but getting the following error when i host on the IIS.

The remote server returned an error: (400) Bad Request.

After some analysis i noticed that the error i am getting is with the POST. All Get methods are working fine. I am trying to send a JSON string to create a record.

Here is my source code:

ServiceContract

namespace WcfRestService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IOrderService" in both code and config file together.
    [ServiceContract]
    public interface IOrderService
    {
        [OperationContract]
        [WebInvoke(UriTemplate = "/PlaceOrder",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json, Method = "POST")]
        bool PlaceOrder(OrderContract order);

        [OperationContract]
        [WebGet(UriTemplate = "/GetOrderDetails/{OrderID}",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        OrderContract GetOrderDetails(string OrderID);

        [OperationContract]
        [WebGet(UriTemplate = "/GetOrderTotal/{OrderID}",
                ResponseFormat = WebMessageFormat.Json)]
        string GetOrderTotal(string OrderID);
    }
}

Open in new window


Service


namespace WcfRestService
{
    // NOTE: You can use the "Rename" 

Open in new window

0
Given this information...
POST /Sale/Application/v2/mypage.asmx HTTP/1.1
Host: b2b2.mywebsite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Persist"

Open in new window




How would I post my xml data to a service in vb.net web page win 4.5 environment

I do NOT want to import the wsdl
0
We have a new sharepoint online site connected to an on premise WCF service using BCS.  Our Office 365 syncs with our on premise AD server using Azure.  Access to our new sharepoint site works fine for internal users.  We have shared the site with an external user to test.  The person can login and view the site but when that user tries to access anything that uses the WCF service, it says "access denied".  When looking at metadata store permissions.  It does not allow me to add "everyone" or "all users (membership".  I can find it when browsing, but when I try to add it, it says it doesn't exist.  I can only add "everyone except external users".
0
I am attempting to resolve an issue WCF Rest Service and I am able to step through debug in one way:

I am able to step-through by calling on the URL specifying the method on the URL:

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetMember/{strTest}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        string GetMember(string strTest);

Open in new window


But what I really needed is more like an object in the RequestBody. So, I originally had:

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/GetMember",  RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        GetTestMemberRes GetMember(GetTestMemberReq TestMemberReq);

Open in new window


I am getting this:
Results of test
And it does not even hit the breakpoint.

When I do the first operation contract I had to change the signature of the method. But when I do that and use the GET as well as update the URITemplate it works and I hit the break point but when I change it to a POST and use the object GetTestMemberReq. I get the above?

If the first one is working my config changes should be good.

I am using C#, .NET 4.0, and VS 2017.

Any information as to what I might be doing incorrectly.

Very much appreciated.
0
We are trying to POST to a WCF REST method. We can successfully POST using SoapUI, Postman, and YARC but when we try in Angular 5 I'm receiving a NULL object.

Client code:
    const headers: any =  {'Content-Type': 'application/json'};
    return this.ajax.request<any>({
        url: url,
        method: method (POST),
        headers: headers,
        options: {
            body: JSON.stringify(req.body)
        }
        });
    }

    public request<T>(req: AjaxRequest): Observable<HttpEvent> {
        return this.http.request<T>(req.method, req.url, req.options)
    }

    //this.http = HttpClient

    // Component
    public onNext(event: any): void {
        this._saveInfo(getInsertDmgReqPayload({
            data: event.value,
            dmgInfo: this.responses['dmg'],
            emailId: this.util.getQueryStringValue('uname')
        }));

        this.util.navigate('education');
    }

    private _saveInfo(data: any): void {
        this.appraisal.request('saveDmgInfo', null, {body: data})
        .subscribe(v => {
            console.log(v);
        });
    }

Open in new window


Server-side logic:
// WCF Interface definition
    [OperationContract]
    [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    Result InsertDemographicInfo(Demographic d);

    // Service code
    public Result InsertDemographicInfo(Demographic d) // The Demographic object is null when posting from Angular
    {
        Result result = new Result();
        try
        {
            DemographicFactory.InsertDemographicInfo(d);
            result.Status = "Success";
        }
        catch (Exception ex)
        {
            result.Status = "Fail";
            result.Message = ex.Message;
        }
        return result;
    }

Open in new window


Web config:

Open in new window

0
Rowby Goren Makes an Impact on Screen and Online
LVL 13
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

I have a question regarding validation of fields provided from a WCF web service.

Let's say that the web service has 6 fields:

MemberFirstName
MemberLastName
MemberNumber
AptType
City
Referral


Now, I want to check that when a Referral is provided the MemberFirtName *and* MemberLastName are also provided. When a City is provided the AptType *or* a MemberLastName is provided.

What is the best way to achieve something like that?


This is in C# with VS 2015.

Any information would be greatly appreciated.
0
I have the codes below
1. RetrieveData is working fine., but now I want to assign class library value in a loop.
Basically, I have wcf call to get the list of name which is exactly same as class library property name - see newretrievedata
Is it possible to do that?

On another side of class library in c#, i already have all of the property/object in class library.


     
  public JsonResult RetrieveData(string ID)
        {
            Domain.Lead l = new Domain.Lead();
            l.firstname = "John";
            l.lastname = "Smith";
            return Json(l, JsonRequestBehavior.AllowGet);
        }

 
        public JsonResult newRetrieveData(string ID)
        {
            Domain.Lead l = new Domain.Lead();


            foreach (KeyValuePair<string, string> i in Helper.DynamicsCRM.GetAllLeadInfoByMetaData3("a51ec467-7255-e811-81153863bb3c4538"))
            {               
                //Response.Write(i.Key + " >> " + i.Value + "<br>"); Key has firstname, and lastname, etc.
            	l.i.Key = i.Value;
            }
            return Json(l, JsonRequestBehavior.AllowGet);
        }

Open in new window

0
In a very simple Silverlight Application I have a DomainService Class which has a single method that returns a list of Letter Objects.

The application works fine when I run it in VisualStudio. However, when I publish it to a folder on my Windows 10 local machine and run it using IIS (version 10.0.166299.5) I get the following error:
The remote server returned an error: NotFound. at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error) at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.b__17(Object )

I supect this is due to something being wrong in missing in my WebConfig file. My WebConfig Currently looks like this:

<?xml version="1.0"?>

<configuration>


    <system.web>
      <compilation debug="true" targetFramework="4.6" />
      <httpRuntime targetFramework="4.6" />
    </system.web>




  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  

Open in new window

0
Hi, I have 3 years of experience in Release Engineer and Software Engineer,

As I have less work for release management so I request for software development work to manager and got some work parallely. Now I am doing both Release as well as software development work in AngularJS, C#, WCF, MySQL, ASP.NET MVC etc. but my designation is "Release Engineer" . Now I want to switch to software engineer to different organization with this experience.

So is it possible? or how it should be done?

Please Help.

Thanks.
0
Is there any easy way to convert a WCF application to a pure web based application.
0
Hello guys,

I´m getting this error while trying to setup Outlook with autodiscover

Process w3wp.exe (FE_Autodiscover) (PID=8708). WCF request (Get Servers for sametime.cz) to the Microsoft Exchange Active Directory Topology service on server (TopologyClientTcpEndpoint (localhost)) failed. Make sure that the service is running. In addition, make sure that the network ports that are used by Microsoft Exchange Active Directory Topology service are not blocked by a firewall. The WCF call was retried 1 time(s). Error Details
 System.ServiceModel.Security.SecurityAccessDeniedException: Access is denied.

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.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at …
0
Hello,

I have a webservice that I,m trying to apply a custome security, when I try to call the service it display the following error:


http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:FailedAuthentication

At least one security token in the message could not be validated.


To add the security I modify the service config file:

[b][b]<services> <service name = "WcfService1.Service1"> <endpoint address="" binding="customBinding" bindingConfiguration="customBindingOasis" contract="WcfService1.IService1"> <headers> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>USERNAME</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password> </wsse:UsernameToken> </wsse:Security> </headers> </endpoint> </service> </services> <bindings> <customBinding> <binding name ="customBindingOasis"> <security authenticationMode="UserNameOverTransport" includeTimestamp="false" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"> <secureConversationBootstrap /> </security> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8"> <readerQuotas maxDepth="32"
0
Hello,

I have this WCF service that works fine using soap1. I'm trying to change it to run in soap1.2 but I have not been able.

I have try changin diferents things in the webconfig.

First I change the basicHttpBinding for wsHttpBinding.  I also change the protocol , remove the soap1.1 and add the soap 1.2

How I can made that my WCF web service run in soap1.2?
0
what are advantages of creating a REST service in Web API vs some other technologies in .NET like WCF, ASP .NET MVC etc.
0
Introduction to Web Design
LVL 13
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Hello.

When trying to add a service reference I receive the following error:

"The configuration for the service reference could not be added due to the following issue: An error occurred creating the configuration section handler for system.serviceModel/bindings: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) (C:\....\web.config line 154)"

But, looking in web.config I am not seeing the problem.

Thanks. :)
0
Hello,
I have written a mock for a REST service using SoapUI free version. The resource path looks like <webservice>/employees which returns all employees in JSON. Now I want to pass a parameter which is a date range, something like <webservice>/employees?from=01-01-2017&to=31-12-2017
This will return only a few employees who joined during the date range. I am not able to find a way to accept parameters in the mock response and not sure how do i check something like if(date == 01-01-2017 to 01-04-2017) { //pass this json text   } else if(date == 08/08/2017 to 31/12/2017) { pass this text }

Any help would be greatly appreciated as I am new to SoapUI
0
Hi,

We have a server 2012 R2. When we want to add 1 of the 2 features below the installation failes with error 0x800f0922

The 2 features who fail are:
.NET Framework 4.5 Features\WCF Services\Named Pipe Activation
.NET Framework 4.5 Features\WCF Services\TCP Activation

What can we do to solve this? Any help is appreciated.
0
I have a C# WCF Service hosted in IIS 8.5 which has a simple Client webform consisting of a ComboBox for data entry. The ComboBox can be populated manually or via barcode scanner on the users mobile device. Every time the user uses scanned input the scanned value is written to a database table with UserId, dateTime & value. I have an API which will return the last scanned input for a user based on dateTime scanned.

So I now have a webform which can take its input either manually or via scanned input. If there is no selected value in the comboBox then I want to run a background job to call the API and return any scanned input value to the ComboBox.  

CheckForScannedTransactions below is part of the Client WebForm1 and it calls the background job StartBackgroundProcess passing parameters MyBGJobParms. I expected control to return to UI but when there is no scanned input to return control never returns to the UI despite RunWorkerAsync. Why is this ?

In this scenario every logged on user will call CheckForScannedTransactions() to check for their own scanned input. Is there a better way of doing this ? Could I for instance have just 1 background job running continuously and updating scanned input to each users webform page. Is that possible if so How so?



//CheckforSacnnedTransactions will run in background and populate any scanned value to ComboBox if ComboBox is empty 
if (ComboBox1.SelectedIndex == -1 )
{
    CheckForScannedTransactions ();
}

Open in new window



Open in new window

0
I am trying to install Sharepoint 2016 and have just been running into issue after issue. I have tried all suggested solutions available but have had no luck. Any clue why this is happning? The prerequisite installer (such a terrible and useless tool IMO) failed to install anything during the prerequisite installation process so I had to install the prerequisites manually. I tried reinstalling WCF data services 5.6 tools using the prerequisite installer in command line with the correct parameters and had no luck. I have tried reinstalling the .net 4.6.2 framework as well.

I am running a fresh install of Windows Server 2012 R2 and the database server is running Microsoft SQL Server 2014

Here is the error:

One or more configuration settings failed. Completed configuration settings will not be rolled back. resolve the problem and run this configuration wizard again. The following contains detailed information about the failure.

Failed to create the configuration database.

An exception of type Microsoft.Sharepoint.Upgrade.SPUpgradeException was thrown. Additional exception information: One or more types failed to load. Please refer to the upgrade log for more details.

I have also attached the error log. Any suggestions?
PSCDiagnostics_9_22_2017_15_31_48_91.log
0
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

http://xx.xx.xx.xxx/DCRules2Alias/Service.svc/MobileRegistration/?&userId=TESTUSER&enterpriseId=TESTENTERPRISE&deviceId=TESTDEVICE&qrcode=TESTQRCODE
This fails with HTTP400 Webpage cannot be found.

http://xx.xx.xx.xxx/DCRules2Alias/Service.svc  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

regards
Pat

Operation Contract for MobileRegistration web service
[OperationContract]
[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

0

WCF

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
WCF
<
Monthly
>