Set Proxy Server for WCF in vb.net - 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.

Related

wcf service on windows 2003 server - works as server but not as a consumer/client

It is a very simple wcf service. Since my original wcf service didn't work there I decided to create one test service. Basically I'm using the default method GetData(int).
I hosted this service on windows 2003 server. It works well when I consume it from a different machine. I use a windows forms test application to consume this service. When I run this forms app on the same ws2003 server and attempt to consume the service on the same server it throws the following error:
There was no endpoint listening at http://...
I created another wcf client using asp.net, also silverlight, nothing works.
Basically, it looks like it can't consume any wcf service.
I couldn't figure out what could be the issue.
Basically, the machine had McAfee antivirus installed and was blocking http communication to aspnet_wp.exe.
The full path is c:\windows\microsoft.net\framework\v4.0.30319\aspnet_wp.exe
Everything works fine after unblocking this specific exe.

Relay WCF Service

This is more of an architectural and security question than anything else. I'm trying to determine if a suggested architecture is necessary. Let me explain my configuration.
We have a standard DMZ established that essentially has two firewalls. One that's external facing and the other that connects to the internal LAN. The following describes where each application tier is currently running.
Outside the firewall:
Silverlight Application
In the DMZ:
WCF Service (Business Logic & Data Access Layer)
Inside the LAN:
Database
I'm receiving input that the architecture is not correct. Specifically, it has been suggested that because "a web server is easily hacked" that we should place a relay server inside the DMZ that communicates with another WCF service inside the LAN which will then communicate with the database. The external firewall is currently configured to only allow port 443 (https) to the WCF service. The internal firewall is configured to allow SQL connections from the WCF service in the DMZ.
Ignoring the obvious performance implications, I don't see the security benefit either. I'm going to reserve my judgement of this suggestion to avoid polluting the answers with my bias. Any input is appreciated.
Thanks,
Matt
I do think the remarks made are valid, and in such a case I would probably also try and use as many "defense-in-depth" layers I could possibly come up with.
Plus, the amount of work to achieve this might be less than you're afraid of - if you're on .NET 4 (or can move to it).
You could use the new .NET 4 / WCF 4 routing service to do this quite easily. As an added benefit: you could expose a HTTPS endpoint to the outside world, but on the inside, you could use netTcpBinding (which is a lot faster) to handle internal communications.
Check out how easy it is to set up a .NET 4 routing service:
What's new in WCF4 Routing Service - or: "Look ma: Just one service to talk to!"
Creating Routing Service using WCF 4.0, .NET Framework 4.0 and Visual Studio 2010 RC

Is is possible to 'relay' a WCF service from another server?

I've got a WCF service on a server on one side of a firewall. I need to access the service from many workstations on the other side of the firewall. The network guys insist that all holes through the firewall are one-to-one so at the mo, I'll have to set up every workstation one by one. There could be loads and it'll get tedious and be prone to errors.
Is it possible to set up a WCF server on this side of the firewall that can in some clever way just act as a proxy to the 'real' WCF service on the other side of the firewall? If so, could you point me to some reference material?
There is a new concept of a WCF Relay service being developed for the Windows Azure "cloud" computing space. That would allow you to create your scenario fairly easily - just host some bits of your service out in the cloud.
See these links for more information:
WCF services hosted on Windows Azure
Software in the cloud: the Relay service
.NET ServiceBus: Hands-On with Relays
or search Google for "WCF Relay Service". There are also a number of new bindings specifically for these WCF scenarios.
Hope this helps.
Marc
UPDATE:
WCF v4 - to be released with .NET 4.0 later this year (2009) will include a RoutingService class which can be used in scenarios like this.
See more info about the WCF4 routing service here:
Content based routing in WCF 4
Routing messages in WCF 4.0
A developer's introduction to WCF .NET 4 Beta 1
I have a few suggestions, maybe one would work in your case:
Place the WCF service outside the firewall. If the WCF service needs to talk to the database, open the database port for the IP address of the machine running the WCF service.
Program or use code generation to create a WCF service that is simply a pass through layer
There may be some functionality in your firewall that allows you to publish an end point

WCF - service access address aliased

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.

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