How to call local WCF service from webpage? - wcf

I'm developing a webpage that is supposed to consume WCF webserice that is located on client's computer. First, user installs some software that hosts WCF service on his computer, then he'll view my webpage which is supposed to call the WCF service. Do you have any idea how to do it without having to use AtiveX and IE?

Add your wcf service as service reference to your web project. You have to specify the url of your wcf service. A clientproxyclass will be generated for you. In your webpages or whathever you can create a instance of this proxyclass and just code what you want.

Related

Calling a net.tcp wcf service from Silverlight - in an external facing web site?

I have an external (public) website developed in Silverlight. The Silverlight app currently calls http based wcf services hosted in IIS.
I am now having to call a wcf service with net.tcp binding hosted in a different app server. I have the net.tcp wcf service hosted in a windows service on port range 4502-4530 and with an interface to expose clientaccesspolicy.xml file as part of the service. I am able to invoke this service from my Silverlight app in the web server. I want the SL app to make direct call to net.tcp, rather than routing the call to it from another http based service.
Question is will this work without any issues when exposed over internet.
Client browser --> IIS webserver with Silverlight website --> App Server with wcf service on net.tcp.
I am assuming in this case, from XAP SL would try to make direct call to the app server service using net.tcp ?
The communication between the web server and app server could be opened up for ports 4502-4535. But I am wondering what about the client. Does this setup require the ports to be available even in the clients machine (with browser)?
Any insight is much helpful.
Thanks.
Take a look at http://support.microsoft.com/kb/2425652; there is sample code included as well! If you setup clientaccesspolicy.xml correctly; it should work as long as clients can access your TCP server.
If your clients are behind some firewall which is blocking your server's ports; they may face connectivity issues!

Calling WCF service method from browser?

Since i am new to WCF and Having configured a WCF service endpoint in IIS at Virtual Directory Api ( url goes like
http://localhost/api/taskapi.svc)
i was looking for ways to make request through web browser something like
http://localhost/api/taskapi.svc/GetCompleted
would respond with returnd data .I know this requires the binding of web service with the webHttpBinding but i don't know how to do it any help would be great ?
Use WCFSVGHoST application to test WCF applications. Application enables you to key-in parameters value and execute method of your interest.
Link for the same:
http://msdn.microsoft.com/en-us/library/bb552363.aspx

Consuming WCF Restful Service hosted by IIS

I have successfully deployed my WCF restful web service to IIS 7. I have verified that my service is working when I call it from a browser in IE via a something like "https://myserver/mservice.svc/postuser/JohnSmith" . The method is a POST and I have verified that my IIS configuration allows for POSTS.
My issue is as follows. We are using a 3rd party Software as a Service application that allows for external web service calls. It allows you to configure the URL "https://myserver/mservice.svc/postuser/" and then you can choose a parameter. When I call the web service from the external application, a 404 error is registered in IIS.
I think there must be some difference between the way I call my webservice "https://myserver/mservice.svc/postuser/JohnSmith" and the way the SAAS application is calling my external web service. The web service is attempting to pass the username, but I cannot detect how it is constructing this.
Do I need to write a web enabled front end for my web service that is hosted in IIS that can handle XML? I'm assuming this is how the SAAS application is trying to pass the username onto my web service.
Thank you all in advance for your ideas and help.

Questions about adding a WCF service to a Windows service assembly

I have found some basic information about hosting a WCF service in a Windows service, but not much. All of my experience thus far with WCF has been in Web projects. I have a few simple questions.
I have a project which creates a windows service application. I have done a right click -> add WCF Service. This creates Service1.cs and IService1.cs.
I'm wondering why no SVC file is created in this scenario? When I add services to Web projects i get an SVC file which I can navigate to and use to consume the service.
Adding the service adds some configurations to the app.config under the services element. I'm seeing a default base address of
http://localhost:8732/Design_Time_Addresses/WindowsServiceName.services/WCFServiceName/
What does this mean? It's sort of an odd looking address. Am I supposed to change it to whatever I want?
Navigating to this address in a browser results in an unable to connect message. Does the windows service itself have to be running to talk to the WCF service?
How do I go about consuming this service from another application without an svc file?
I'm taking a guess on this first one, but I'm thinking the .svc file when hosting in IIS is to tell IIS, "Hey I have a WCF service here, please handle accordingly".
The base address is as it should be and yes you can change it if I'm not mistaken.
You can't hit the WCF service unless the Windows service is running, which is one of the dangers of hosting in a Windows service, because if the service dies somehow your WCF service is offline until you get the Windows service running again.
You consume the service the same way you do any other WCF service, just using that base address to get at it.

How to communicate between two applications?

I have created a library which reads the app.config file and gets the type of WCF service in which it is called.
Now, I have a separate console application, I want that this library informs the console application about the type it found in the WCF service so that the console application can host it.
It is useful because then I will just add my library in any WCF service and call its method and it will then inform my console application and it will host it.
Please give me an idea on this problem.
I have to agree with Marc, but this is perhaps related to your question regarding ServiceHost, but what is the purpose of your console application?
Is it acting as a host or as client (consumer of the services). If its a host I would simply add the appropraite configuration in the app.config?
HTH
Phil'