How do I configure Visual Studio to see a net.tcp URL on local IIS? - wcf

I've got a WCF service using the netTcpBinding, and no other binding. It works great when I manually deploy the files to IIS, and my client application can consume the service when I enter the net.tcp://localhost(etc) url. Now I'm trying to get the project to run in Visual Studio, so I can have the service and client in the same solution, and reference the service directly instead of going through IIS, and having to redeploy files manually.
Neither IIS Express nor the Visual Studio Development Server can use net.tcp, so they're out. In the Web tab of my service project, the "Use Local IIS Web Server" or "Use Custom Web Server" looked like good options, but neither of them will accept a URL that doesn't begin with http.
Is there some way of making my WCF service use IIS, and having my client reference the service directly (so that I don't have to deploy files to IIS, and then update service reference, every time I compile)?

Start the service in WcfSvcHost, then try to add a reference to the hosted URL.
Unfortunately, the VS IDE has no technique to start services automatically, except for when you're debugging.
Also, you always need to update service references explicitly. You need to decide which of your changes are ready to be applied to which clients of your service. It would be bad to assume that all clients should be updated as soon as you make a change then compile your service.

You could add a project, which you don't deploy, but only use during development, that self-hosts the service.

Related

Why can't I browse to my WCF service in Windows Server 2012?

On any other operating system, if I browse to my WCF service in the browser, I can see information about that service. In Windows Server 2012, I get no information about the service, and it even acts as if there's nothing there at that address. I can still access the service from a client, but I had to add a server feature just to make it work (.NET Framework 4.5 Features -> WCF Services -> HTTP Activation).
Browsing to the service is normally a quick way to make sure that the service is running, but it's a slight annoying that I no longer have this luxury. Does anyone know how I can get Windows Server 2012 to show information about my service when I browse to it?
Make sure your services' configuration or code modifies the default behavior to enable metadata to be published:
How to: Publish Metadata for a Service Using a Configuration File

Deploying Silverlight Business Application

I have a silverlight business application which access to a web service. I've created WCF service (in RIA part) which access this web service, and then added Web service reference in SL project. Using this way (proxy), I got service address like this: localhost:7777/... When I deployed application to IIS, this port number was not the same (expected, but...).
Since I couldn't configure this port number, I made separate service (not in the same solution) and deployed to IIS. After that, I added service reference to SL project. Similar like before, but now service is not in the same solution, but independently deployed on IIS. This approach doesn't work. In Fiddler all I could see is HTTP 500.
Could someone please tell me how to deploy SL Business Application which has an access to a WCF service which is deployed separately?
Best,
Joksimovic
What you'll want to do is create separate versions of your ServiceReferences.ClientConfig file (which resides in your Silverlight application and contains the service endpoints for the application).
We create a separate ServiceReferences.ClientConfig for each possible deployment location and then base them on the Silverlight project's build configuration. So, when the project is built and it's build configuration is set to "Debug", we have a ServiceReferences.Debug.ClientConfig whose contents are copied into the project's local ServiceReferences.ClientConfig. Ditto for our Test, UAT, and Release builds.
Here is a link which talks about choosing the correct config based on your build configuration: How to use Visual Studio 2010 config transform when running/debugging locally?

can I expose a WCF service from an application runing in visual studio(with F5, run)?

If I run a WCF application which exposes a service in visual studio, is it possible to consume the service from an asp.net application running on another computer? How can I determine the address of the WSDL published by the WCF service in order to add a reference to it in the ASP.NET application?
If your service is an ASP.NET application and you are hosting it with the built-in development server, refer to Kalus's answer. However, if you have IIS installed locally, you can reconfigure your project settings so that the application is hosted by IIS for debugging instead of the built-in development server.
If you are writing a standalone WinForms or Console application, then the responsibility will be on you to select an endpoint and binding, whereas with an ASP.NET application, those parameters will come from IIS or the Dev server (the protocol will always be HTTP/HTTPS, and the port number will be set by IIS or randomly generated by the Dev server). So in a standalone application, you will have to configure which binding (basicHttp, wsHttp, netTcp, etc.) and an appropriate hosting endpoint (http://hostname/MyService or net.tcp://hostname:port/MyService). But yes, if the service is hosted by a standalone application, it will be accessible from other computers.
Refer to this overview here: http://msdn.microsoft.com/en-us/library/ms731758.aspx
According to #Kent Boogart's comment below, the asp.net development server can only be used for local requests. So you will need to configure your web service to run in IIS if you want to call it from another machine.

WCF Service doesnt run on IIS!

I have a WCF service hosted at local IIS. I created a ASP.NET website that consumes this service hosted at IIS.
While running it from Visual Studio WebDev Server, everything works fine, but as soon as i run the same website [after hosting in IIS] from the browser, the website doesnt seem to be communicating with the Service!
The same setup when runs from Visual Studio WebDev Server, doesnt function from IIS!
Any know isues?
Please help!
Thanks
I bet it's the address - when using Add Service Reference it will hardcode "localhost" into your ClientConfig file on the client.
Check this and implement a way to change over to your real (IIS) address at deploy time.
(A way to check you have the right deploy-time address is to pull it up in a browser, try navigating to "http://yoururl.com/MyService.svc" you should get a page that will link to the WSDL, letting you make sure you have the right address.. this is the address your client should look for)
Couple of things to check:
do you have a SVC file? Where is it located?
do you connect to the correct service address? It would be:
http://YourServerName/YourVirtualDirectory/YourServiceFile.svc
This is the address that you get when hosting in IIS - you cannot override that in your web.config, no matter how hard you try.
are the configurations for binding etc. identical on server and client?
have you turned on HttpGetEnabled for the service metadata? Can you navigate to the WSDL address and get the WSDL back??
http://YourServerName/YourVirtualDirectory/YourServiceFile.svc?wsdl
It sounds like you are not resetting the Service reference when you move it to the webserver. What you need to do after you have completed testing is to move your Service to be hosted by IIS, so deploy it to the server. Then you will need to re-reference, or update your reference in our web app before you deploy it.
Typically when testing your service it will run in the dev server at http://localhost:someport/myservice.svc
When you deploy it to IIS it will run on http://myserver.com/PossibleVDIR/myservice.svc
Once you take care of this you should be fine.

how to debug a WCF service once it's out of dev env

I have a WCF service that i've been able to communicate with fine while it's hosted locally.
I have it deployed to a web server in IIS now, and I can get the wsdl file without error by navigating to http://site.com:8000/service/servicename.svc?wsdl
in trying to test this, i've created a console app and was able to successfully add a service reference to this. But when I try to run a Get() method on the service reference, it just hangs with no response.
How can I begin to debug this?
Thanks!
When you have a service that works in dev but not in IIS, it is often due to a problem with the WCF configuration:
Is the configuration in place (since you can add service reference it probably is)
Is the protocol you are using available. The configuration you are using must match what is turned on. For example are you using nettcpip binding without WAS.