WCF - service access address aliased - wcf

I am inexperienced in WCF so this question may be real basic...
I have a WCF service hosted in IIS of a server named "Server1". This server is aliased and visible from the open Internet as ServerAlias.mydomain.com.
While developing the consumer application, I add a service reference to the service in Server1 and deploy it. When executing it remotely, the app looks for the service on "Server1.mydomain.com" but it can only be accessed through "ServerAlias.mydomain.com".
Is there a way that I can reference the service in Server1 in design-time, and in run-time the application looks in "ServerAlias"?
Thanks!

When you make the reference, it should create entries in your .config file which indicate the remote endpoint. All you have to do is change the remote endpoint to point to the other server and it should work.

Related

Set Proxy Server for WCF in vb.net

Sorry if this has been raised elsewhere...
I am trying to consume a WCF service in vb.net. The application that is consuming the service sits behind a proxy server, and so needs to connect to the proxy server to get to the service.
In old school web references, this was easy to do with a couple of lines of code to set the proxy server for the web request.
Is there an equivalent way of doing it now? Preferably in such a way that the proxy address can be changed through configuration used in the application rather than amending app.config files.

Azure emulator ports different

When I run my WCF in normal mode it works, but when I run through the Azure Computer Emulator on my local PC, the port numbers are different. For instance, the WCF page opens up in under the address: http://localhost:81/ServiceName1.svc, but the WSDL address says
You can also access the service description as a single file:
http://pc-name1:82/ServiceName1.svc?singleWsdl
When I try to connect using WCF test client, it is not working when I try to fetch the address http://localhost:81/ServiceName1.svc or the address http://pc-name1:82/ServiceName1.svc
Do you know what might be happening? Has anyone noticed this when using the Azure emulator?
Have you gone through the Hosting WCF within Windows Azure exercise? This behaviour is explained. You need an update to the WCF - KB981002- WCF: Hotfix rollup update, which will add a special behavior for your WCF services:
7.About the System.ServiceModel configuration above:
For this example we are exposing a metadata exchange (MEX) endpoint in addition to the service main endpoint. This will expose
the service metadata and thus allow service references to be added to
this service in Visual Studio.
The useRequestHeadersForMetadataAddress behavior is a special behavior that is defined in KB981002- WCF: Hotfix rollup update. It
allows WCF to serve correct metadata behind load balancers. Windows
Azure web roles are load balanced between one or more physical
servers.

WCF DiscoveryClient returns references to localhost from remote machines

I have an app with a self-hosted WCF service.
My WCF service gets published under the URI "net.tcp://localhost:8004/DocumentService". When I run the service on a remote machine and try to discover the service with the new .NET 4 class DiscoveryClient, the found services all have the URI "net.tcp://localhost:8004/DocumentService" too without any information about the actual machine where the service is hosted.
Obviously this is useless if I want to access the service on the remote machine. But I can't find any reference to the actual remote machine (IP address or server name) in the arguments passed to FindProgressChanged.
Is there a way to get the information about the remote machine or do I have to publish my service with the machine name of the remote machine? Or is DiscoveryClient just broken?
I hope this make sense.
I spent a lot of time investigating this problem. Building base addresses in the code was not acceptable for me, as it implies hardcoding transport scheme and port (the latter, of course, can be stored in a separate config section, but then why not just to use the existing section?). I wanted to have an ability to just configure the base address in config as usual. And it turns out that a base address like <add baseAddress="net.tcp://*:8731/"/> will perfectly work. I think the same is true for programmatic configuration.

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 would I create a remote admin console for a WCF Service using telnet/raw?

I have a WCF service currently using a TCP endpoint. Rather than create a separate console client app to administer the server I want the ability to telnet into the server or even just connect using a raw connection using putty and execute ascii commands straight on the server.
Any ideas how I would go about doing this? Not an expert on WCF so would appreciate any help. Thanks
I doubt you could do that - WCF will always have to use its defined endpoints - TCP, HTTP - whatever. I am not aware of any telnet binding or raw connection, as you mention it.
From my perspective, why not create a service contract for admin purposes and just hit that with HTTP and/or TCP from a console app? Seems easier than trying to "bolt on" something that's not really been thought of.
Marc
To administer my WCF apps, I host in IIS, and have a subfolder in the application virtual directory with Admin aspx pages. The folder is protected from unauthorized access using ASP.NET roles.
The Admin folder includes application-independent pages (e.g. managing logging, view log files) and where appropriate application-specific pages.
Since the ASP.NET pages execute within the same AppDomain as the hosted WCF services, the sky's the limit as far as adding functionality for instrumentation and dynamic configuration.
I don't think WCF support custom command processing out of box and it will be quite a bit of hoop jumping to get that to work. I would suggest
Host the WCF service inside a windows service rather than IIS
Create a socket listener inside the windows service listening on the port of your choice
Write some code to process your command when data arrives the socket