Part 3 Creating a wcf service

Share
Embed
  • Published on Nov 18, 2013
  • Link for code samples used in the demo
    csharp-video-tutorials.blogspot.com/2013/11/part-3-creating-wcf-service_18.html
    Link for all dot net and sql server video tutorial playlists
    ru-clip.net/user/kudvenkatplaylists
    This is continuation to Part 2. Please watch Part 2 from WCF video tutorial before proceeding.
    In this video, we will discuss
    1. Creating a WCF service
    2. Hosting the WCF service using a console application
    3. Exposing 2 service endpoints.
    4. Creating a windows and a web Client applications.
    Let's take the scenario that we discussed in Part 2.
    We have 2 clients and we need to implement a service a for them.
    1. The first client is using a Java application to interact with our service, so for interoperability this client wants meesages to be in XML format and the protocl to be HTTP.
    2. The second client uses .NET, so for better performance this client wants messages formmated in binary over TCP protocol.
    In Part 2,
    To meet the requirement of the first client, we implemented a web service and to meet the requirement of the second client we implemented a remoting service.
    In this video, we will create a single WCF service, and configure 2 endpoints to meet the requirements of both the clients.

Comments • 311

  • Saroj Mahanta
    Saroj Mahanta 2 months ago +1

    Please mention here that, the entire exercise need to be done in the Visual studio running as an Administrator. Else, we will get an error, "HTTP could not register URL +:8000/HelloWCF/. Your process does not have access rights to this namespace." .. Those who want to get the solution, please follow the link, www.codeproject.com/Questions/310360/HTTP-could-not-register-URL-http-plus-8000-HelloWC

  • Vipin Prajapati
    Vipin Prajapati 6 months ago

    Sir please make video in hindi

  • roopkumar nanduri
    roopkumar nanduri 6 months ago +1

    Thanks a lot sir excellent presentation in detail 👌👌👌

  • Sourav Roy
    Sourav Roy 7 months ago

    Hi Venkat, I tried with the same example that your are showing here but in browser when I type the base address as localhost:8080/ I am not able to get the wsdl in the browser. I am using Visual Studio 2015. Can you please help how to proceed

  • muhammad asad tahir
    muhammad asad tahir 7 months ago

    Severity Code Description Project File Line Suppression State
    Error "csc.exe" exited with code -532462766. HeloServiceAsad

  • Mohammad Usmani
    Mohammad Usmani 8 months ago

    Venkat,
    I can't run the wsdl what could be wrong?

  • Waseem Sangrasi
    Waseem Sangrasi 8 months ago

    Why we have created Service host project here ? can we add service modal configuration directly to service project ?

  • Harish Kamath
    Harish Kamath 9 months ago

    System.ServiceModel.CommunicationException: 'A TCP error (10013: An attempt was made to access a socket in a way forbidden by its access permissions) occurred while listening on IP Endpoint=0.0.0.0:8080.'
    I am getting this error. How to resolve the above error

  • Aman Aman
    Aman Aman 10 months ago

    For those who are getting security permissions issue. you can resolve this through running following command(run cmd as administrator)
    netsh http add urlacl url=+:8080/ user={domainYouserName}

  • Harshil Soni
    Harshil Soni 11 months ago

    hello how to know the local host as 8080 isnt working

  • nekkoMaster
    nekkoMaster 11 months ago

    25:10 that run as administrator is very important !!! it will stop the damn errors

  • Anbarasu Angappan

    The Server based service based application doesn't work in the Normal Visual Studio, Just close the application, and open the application as Run as Admin , so that service host application works fine.. i also face the problem, and i recover... thanks Cheers

  • Anbarasu Angappan

    Really Good Material For the Starters to learn the Concepts very Clearly in the Step by step Manner.. Thanks Cheers

  • Subramaniam Ananthakrishnan

    Venkat Sir, very nice explanation as always. You are doing a great service to the .net community. :)

  • Abhijit Sahoo
    Abhijit Sahoo Year ago

    superb like

  • MD. Showkat Akbar

    how to find port number. such as localhost:8080) in my project? plz help me.Thanks. An error is additional information: A binding instance has already been associated to listen URI 'localhost:8080/HelloService'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.

  • Anuj Daksh
    Anuj Daksh Year ago

    sir plz dont add more than one ad

  • Veaceslav Chirilov

    For web application you have specified endpoint name in HelloClientService, however in windows forms client application you've specified binding name in HelloClientService, why ?

  • Pradeep P
    Pradeep P Year ago

    Good work Venkat! Very clear, simple and easy to understand!

  • rahul sharma
    rahul sharma Year ago

    Hi sir i am getting this exception why it is there and how to resolve it ..i am using vs2012 "{"The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the HttpsGetUrl property is a relative address, but there is no https base address. Either supply an https base address or set HttpsGetUrl to an absolute address."}"

  • chandrakant Nazirkar

    An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll
    Additional information: Service 'HelloService.HellowService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
    Exception occur while host service
    Please help me on same to fix that issue.
    This is App.config code

  • satwik dondapati
    satwik dondapati Year ago

    hello sir i have tried to host service with the console appliaction and it s getting error in console like System.ServiceModel.AddressAccessDeniedException: 'HTTP could not register URL +:8080/. Your process does not have access rights to this namespace (see go.microsoft.com/fwlink/?LinkId=70353 for details).'
    plese help me

  • Mikheil Shalvashvili

    terrible

  • Jon Reyes
    Jon Reyes Year ago

    Excellent video!

  • Rekha Devi
    Rekha Devi Year ago

    Does it necessary to run WCF service project running while run the Client Project Sir

  • Bashar Haddad
    Bashar Haddad Year ago

    Thank you very much !! very simple, very helpful

  • Saritha Meda
    Saritha Meda Year ago +1

    how can test the web service on tcp port. my service is running. when I type net.tcp//localhost:8090/ in the URL, it says site cant be reached. but http works as expected

  • Ammar The Trainer
    Ammar The Trainer 2 years ago

    I found this video very useful for the novice . Thank you very much Sir

  • Vishnu Bathula
    Vishnu Bathula 2 years ago

    Hi , I got error while run HelloServiceHost Project (Program.cs) as The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the HttpsGetUrl property is a relative address, but there is no https base address. Either supply an https base address or set HttpsGetUrl to an absolute address.. Im new to wcf , So i dont understand exactly whats wrong. But i added to web.config file already as

  • Tahrin Aziz
    Tahrin Aziz 2 years ago

    I am getting this error. How can i solve this?
    Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at System.Net.UnsafeNclNativeMethods.SetFileCompletionNotificationModes(CriticalHandle handle, FileCompletionNotificationModes modes)
    at System.Net.HttpListener.CreateRequestQueueHandle()
    at System.Net.HttpListener.Start()
    at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
    at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
    at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
    at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
    at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    at HelloServiceHost.Program.Main() in c:\Users\ASUS\Documents\Visual Studio 2012\Projects\HelloService\HelloServiceHost\Program.cs:line 15

  • Ganesh M J
    Ganesh M J 2 years ago

    Getting this Message while running the Web App
    The message with To 'localhost/8080/HelloService' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.

  • Keya Kinan
    Keya Kinan 2 years ago

    I was hoping this would connect with a Java client! Any idea where I can find info about that?

  • kannan v
    kannan v 2 years ago

    Dear sir
    this is my error how to solve this error

    Service 'helloservice.helloService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

  • Munish kumar
    Munish kumar 2 years ago

    i am getting this error. please help me out..
    An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
    Additional information: An extension named serviceMetadata already appears in the ServiceBehaviorElement. Extension names must be unique.

  • Hariom Kumar
    Hariom Kumar 2 years ago

    Hello Venkat !!
    Hope you are doing well.
    Very nice video to grow the knowledge base.
    Just my mere suggestion , While adding service reference for tcp protocol , should be exposed with url :--
    net.tcp://localhost:8090
    and configure the endpoint as
    .
    Should suffice.
    Thank you !!

  • awais shabir
    awais shabir 2 years ago

    i am using same code but i am facing below error.
    A binding instance has already been associated to listen URI 'localhost:8080/RemService'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.

    • Marko Razumenić
      Marko Razumenić Year ago

      stackoverflow.com/questions/11506107/wcf-invalidoperationexception-a-binding-instance-has-already-been-associated-to

  • vishal jagani
    vishal jagani 2 years ago

    But in Windows 10 OS issue is arriving at IIS level at the time of creating WCF self host application.
    The issue is :-- HTTP could not register URL +:8000/ServiceModelSamples/Service/. Your process does not have access rights to this namespace (see go.microsoft.com/fwlink/?LinkId=70353 for details). WCF Self Hosting issue.
    The solution for this issue :---
    The issue is that the URL is being blocked from being created by Windows.
    Steps to fix: Run command prompt as an administrator. Add the URL to the ACL
    netsh http add urlacl url= 10.129.159.144:8000/HelloService user=username(In Domain)
    Command Prompt worked as Administrator.

  • Muhammad Waqas Aziz
    Muhammad Waqas Aziz 2 years ago

    Very Very Very nice tutorial, thanks

  • Vishesh Sharma
    Vishesh Sharma 2 years ago

    why did you remove string[] args ?

  • Anuradha Sriramoju
    Anuradha Sriramoju 2 years ago

    Hi sir, Ur Videos are awesome and made me to survive in this field after a long break of 10 years. I used to watch ur videos and learned a lot besides learning from other institutes. Now I am working Professional along with a good Home Maker....
    This credit goes to u.....
    Thank You....
    I have created a wcf service and i am getting an error as -" Specified argument was out of the range of valid values.Parameter name: site
    Description: An unhandled exception occurred during the execution of the current web request."
    will u plz resolve it for me....

  • Roy Levy
    Roy Levy 2 years ago

    if you get this error : HTTP could not register URL +:8000/ServiceModelSamples/Service/. Your process does not have access rights to this namespace (see go.microsoft.com/fwlink/?LinkId=70353 for details)
    for what ever port/path you are using , try running the following command in the CMD as admin
    netsh http add urlacl url=+:8085/ user=DOMAIN\myname

  • jhillyt
    jhillyt 2 years ago

    For those with the baseAddress exception, ensure you are using "mexHttpBinding" for your "mex" endpoint. I had the error because I was using "mexHttpsBinding"; made the correction and running fine now. best of luck. (great tutorials)

  • Zach Smith
    Zach Smith 2 years ago

    Thanks for your videos. They are extremely clear and helpful. I'm coming from a JavaScript background where WCF is completely new to me. Something I wasn't clear on after this video is the variety of ways that you can get clients and services communicating. For example, it seems that using a Channel Factory is preferred to generating proxy classes from WSDL files. stackoverflow.com/questions/1698275/wcf-channelfactory-vs-generating-proxy

  • Drakshop
    Drakshop 2 years ago

    very well explained as usual

  • calvin kwoo
    calvin kwoo 2 years ago

    when we add on the web services, we only use localhost:8080...
    how we add net.tcp://localhost:8090?
    What the different to add localhost:8080... and net.tcp://localhost:8090?

  • manideep kumar
    manideep kumar 2 years ago

    I am new to WCF, it's a Nice tutorial. I have one doubt.I am using visual studio 2013,when we add wcf service template to the service project, some default behaviours and endpoints are forming by default in app.config. But again we are taking app.config in host project and we are writing manually all the behaviours and endpoints.Is there any way to use service app.config in host project with out creating app.config in host project.

  • sadiq m
    sadiq m 2 years ago

    Hi sir, i'm tryin'g to host service it showing error in "using(servicehost host=new servicehost(typeof(not showing service here )))"

  • Arvind kumar
    Arvind kumar 2 years ago

    Hi Venkat ,
    getting A call to SSPI failed, see inner exception. could u please help me on this.

  • Hammad Shah
    Hammad Shah 2 years ago

    How can we host the wcf service over web?

  • shatteredPassion
    shatteredPassion 2 years ago

    thank you for this tutorial!

  • ankita mohapatra
    ankita mohapatra 2 years ago

    Hi,
    while running the program i am getting an unhandled exception pasting below for host.open()
    An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll
    Additional information: Service 'HelloService.HelloService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
    could you please look into it.

  • Valikhan Konurbayev
    Valikhan Konurbayev 2 years ago

    Life saving tutorial. Thank you!

  • Reaven Teh Derg
    Reaven Teh Derg 2 years ago

    Wow really nice tutorial.No bullshits ^^ liked

  • Ahmed Abdulrahman
    Ahmed Abdulrahman 2 years ago +1

    Great explanation.
    Thank you.

  • Vikas Kumar
    Vikas Kumar 2 years ago

    Nice explanation. But, I've a doubt.
    If we've two endpoints for two different clients then both of them should not see other's endpoint. Here, when one client consumes the service then in the web.config of that client, he can see both endpoints. This may be a security breach. Both clients should be independent and they should be seeing two endpoints.
    For example: If you've 100 clients and using the same service with different bindings, then each client will have 100 endpoints in there web.config, according to this video.
    Please let me know, how can we resolve this?

  • Arun
    Arun 2 years ago

    Excellent Explanation!! Thanks

  • Nithish Naidu
    Nithish Naidu 2 years ago

    I am getting site can't be reached when I use base address url to see wsdl

  • Khanyiso Mapuma
    Khanyiso Mapuma 2 years ago

    This tutorial became my redemption. I have to thank you on this one and I am definitely subcribing

  • m nm
    m nm 2 years ago +5

    best WCF tutorial and teacher in the world.

  • TallCoolDrink
    TallCoolDrink 2 years ago

    Thank you, KudVenkat....Your WCF returns a string....So I should be able to create a WCF that will return a list of OBJECTS... such as list of clients and their information. Is this correct? The client app. that consumes this WCF should be informed of the OBJECT it will receive and it is up to them to code for the returning object....Is this correct?

  • bashir ansari
    bashir ansari 3 years ago

    'System.ServiceModel.AddressAccessDeniedException' occurred in System.ServiceModel.dll

    • Nithish Naidu
      Nithish Naidu 2 years ago +1

      open visual studio as administartaor

  • Pravin Kumar
    Pravin Kumar 3 years ago

    good

  • aristotelis alexis
    aristotelis alexis 3 years ago

    Can this service be used between 2 different computers...For example can my friend run the "HelloWindowClient.exe" in his computer while I am running the "HelloServiceHost.exe" in my computer and achieve the same result?

  • Bijay Yadav
    Bijay Yadav 3 years ago

    Great explanation.
    Thank you.

  • Abhinav Kumar
    Abhinav Kumar 3 years ago

    Very well explanation.. Thanks Sir...!

  • akshay vartak
    akshay vartak 3 years ago +1

    Thanks for the videos. Wonderful explanation.

  • Bimal Jena
    Bimal Jena 3 years ago

    you are my master....

  • Kamil
    Kamil 3 years ago

    Hey, Kudvenkat! I tried to modify your code by having a return type of the function be image (the service returns an image and the client displays it in windows forms). However, I get a communicationexception even though reverting back to returning string produces no exceptions at all.
    Could you please help me?

  • priyansh bhaliya
    priyansh bhaliya 3 years ago

    Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https,net.tcp]. i getting this error while running console app

    • wei song
      wei song 2 years ago

      still has this exception.

    • merrua
      merrua 3 years ago +1

      Try httpsGetEnabled="false" in the serviceMetadata in the behavior in the App.config

  • suresh maddela
    suresh maddela 3 years ago

    HELLO Venkat,i hav a doubt by default interface is public so why should you written public before interface class.

  • aneef shaik
    aneef shaik 3 years ago

    Unhandled Exception: System.ArgumentException: Only an absolute Uri can be used as a base address.
    at System.ServiceModel.Description.ConfigLoader.LoadHostConfig(ServiceElement serviceElement, ServiceHostBase host, Action`1 addBaseAddress)
    at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost)
    at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)
    at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
    at System.ServiceModel.ServiceHost.ApplyConfiguration()
    at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
    at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)
    at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
    at FirstServiceHost.Program.Main() in C:\Users\aneef\onedrive\documents\visual studio 2015\Projects\FirstService\FirstServiceHost\Program.cs:line 14
    Press any key to continue . . .
    "while I am running the host i an getting this unhandled Exception" how can resolve it.

    • merrua
      merrua 3 years ago

      Try httpsGetEnabled="false" in the serviceMetadata in the behavior in the App.config

  • Shruti Kittur
    Shruti Kittur 3 years ago

    Hello venkat sir when i am trying to run "localhost:portnumber/ in browser i am getting error "site cannot be reached,Localhost cannotconnect" ..But i am getting message "Host running @datetime" Successfully.Please can u tell me what mistake i have done..

  • Vishal Poddar
    Vishal Poddar 3 years ago +1

    very good explanation..but i have a doubt. while creating windows forms application we are using http address in add service reference address bar, but if we need to use tcp protocol we should be adding tcp address..can u please explain it?

  • Keith Kevin Tabanao
    Keith Kevin Tabanao 3 years ago

    Hello I hope you will have a tutorial of these in vb.net not just C#.Net.. I hope I don't sound too dumb for requesting this. I am still learning and I am using vb.net, when I watched this video what goes in my mind is what could be the vb.net equivalent of that code ^_^

  • RISHABH SHREYAS
    RISHABH SHREYAS 3 years ago

    I have followed your steps Venkat and i am getting an exception. There is no service behaviour named mexBehaviour. Does anyone know why i am getting this ?