Expose WCF service hosted in IIS to users - c#

I have a server physically located in the US. The OS is Windows Server 2008 R2 SP1.
I create a WCF service and host it in IIS on the server.
Now, while I'm physically in Germany, I want to write a WCF client to the WCF service. First of all, I need to create a WCF client proxy.
All the tutorials I've seen imply that the WCF service and WCF client are located on the same machine. I.e., the tutorials use "localhost" everywhere. In my case it doesn't work.
I know the IP of my server but I don't know what settings should be done to allow any programmer to use the WCF service. I guess it requires special customization of the endpoint at the WCF service and some settings at the IIS to make the WCF accessible by anybody.
Can you please give a piece of advice in this regard?
Thanks for any suggestions!

Two approaches are available :
Create a service reference using the add reference , enter your service address should be something like : http://IpAdress/service.svc , or if you have your wsdl file on your local disk , just enter your wsdl file location in the add service address bar. This will generate the proxy class.
If you have the service contract(interface) just do it programatically using ChannelFactory , you must know your binding and endpoint address as well.
If have any questions you're welcome

Related

publishing WCF webservice in network

i have a C# WCF project, i have added a websevice inside,
now i wish to publish it, so that another computer on the same network could access the service using the address http:/IPAddress:Port/webservice
how is it done?
thank you very much

C# Calling WCF behind DMZ

I need to call a WCF service that is behind a DMZ:
WEBDMZ .. LANDMZ
------------- ------------
ClientServer => WCF service
As there is a firewall between the two it's not possible for the Client to connect to the WCF service. So I need the WCF service to connect to the client and "listen" to connections or create a tunnel somehow.
I feel it must be a very common problem but I haven't been able to find a proper solution yet. And no it's not possible to open a port. The connection have to be initiated by the WCF.
The client is a server and can easily host any MSMQ or other service.
It seems like this problem can also be referred to as "reverse proxy" or "reverse tunnel".
Solution ideas:
MSMQ hosted by Client (but I'm afraid if it would just simply be polling all the time and creating a network overhead).
A reverse tunnel/proxy?
WCF Duplex?
I'm looking for the simplest solution, preferably in C# and without 3rd party software. Perhaps there is a WCF configuration that allows for reverse calls?
With .Net version 4, you can look at WCF Routing service at here. Or you can build a routing service by yourself following example from Michele Leroux. Here is the link.
EDIT:
You can build a routing service, put it at WEBDMZ server, it will contains list of endpoint wcf service put at DMZ server. At here it will take role as a service server as well as client connect to services at DMZ server. You also can build a discovery service to configure these endpoints automatically.

Two way communication using netTCPBinding

I am new to WCF (Just a day or 2). I am planning to make an application having Client/Server
WCF Service (On Server hosted as windows service):
Will invoke some commands using (Process.Start())
Will send some information from my database
Questions:
What WCF binding should I use? WsDualhttp or netTCP (Please elaborate if you can)
Does WCF works with SqlServer + EF 4.1
Server UI:
This will primarily will be used to
Start ot stop the above service
Change Address (localhost to [My Ip address]) and Port
Show status of service (Running or dead)
Questions:
How can I Change the address and port of my WCF service from this UI (it will be a different project and hence different config file).
Client App:
Used to issue commands to WCF service.
Get to know if the service is running or dead.
Receive status messages for task completion or faults.
Also, can the windows installer be combined to install ServerUI + WCF Service + Windows service?
WCF Service
Here are a couple links on choosing the right binding. Based on the scenario you're describing, I'd go with the netTCP.
C# - WCF - inter-process communication
Choosing the right WCF binding
WCF and SQL Server are independent of each other, so I wouldn't expect any problems using the Windows service to interact with your database.
I'd suggest reading up on how to start a process from a Windows service.
Server UI
I would suggest hosting another WCF service in your Windows service for interacting with your Server UI. You can use the netNamedPipeBinding since this communication channel will always be local, i.e., on the same box. So your Windows service will host two WCF services - one for the external communication with the client and one for the local communication with the configuration UI.
Installer
Yes, the Windows installer can be used, but that might be overkill for what you're describing. Of the Server UI, WCF Service, and Windows service, the only one that absolutely requires installation is the Windows service. The others could theoretically run simply by copying the assemblies to the target system. You might consider having the Windows service install itself via command line. That way you could get away with a self-extracting executable using software like WinZip. This might be less heavyweight than a formal install. If you go this route, have a look at the step-by-step here.
Ha a look at WCF duplex services:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
Why do you want to have a interface to an windows service? And if you have access to IIS7 and WAS, I would recommend to use it instead of self-hosting in windows service.
Here is a good starting point for WCF Configuration Management:
http://msdn.microsoft.com/en-us/library/ff650534.aspx
Yes, you can use windows installer.
Cheers
--Jocke

How to create a WCF client, that will update service reference programmatically?

I don't exactly know, how to ask this question.
I have 3 computers in my local network. On first computer I have installed windows service which hosts WCF Services (binding netTcp). So my address is "net.tcp://localhost:8523/Sms" for example.
Now, I would like to use that service from other two computers. I don't know If I have access to that WCF service - I don't how to check it.
And also I don't know, How to create a WCF client, that will update service reference programmatically?

Debugging Web Service with SOAP Packet

I have a web service that I created in C# and a test harness that was provided by my client. Unfortunately my web service doesn't seem to be parsing the objects created by the test harness. I believe the problem lies with serializing the soap packet.
Using TCPTrace I was able to get the soap packet passed to the web service but only on a remote machine so I can't debug it there. Is there a way of calling my local webservice with the soap packet generated rather than my current test harness where I manually create objects and call the web service through a web reference?
[edit] The machine that I got the soap packet was on a vm so I can't link it to my machine. I suppose I'm looking for a tool that I can paste the soap packet into and it will in turn call my web service
A somewhat manual process would be to use the Poster add-in for Firefox. There is also a java utility called SoapUI that has some discovery based automated templates that you can then modify and run against your service.
By default, .Net will not allow you to connect a packet analyzer like TCPTrace or Fiddler (which I prefer) to localhost or 127.0.0.1 connections (for reasons that I forget now..)
Best way would be to reference your web services via a full IP address or FQDN where possible. That will allow you to trace the calls in the tool of your choice.
Same as palehorse, use soapUI or directly the specific component for that feature: TCPMon.
Just did this the other day with TCPTrace on the local machine. I mapped the remote host in the hosts file to 127.0.0.1. Ran the local web server on 8080, TcpTrace on 80 pointing to 127.0.0.1:8080. Probably your issue is trying to run both at port 80 which won't work.

Categories

Resources