简体   繁体   中英

Hosting WCF web service from a Remote Server

I have an WCF Webservice project, built in my local machine, which when hosted using test client and triggered, returns values from remote database in JSON format.

For example, if you key in the URL with localhost then you get results back in the below format:

{"Id":3,"Value1":"67.5687","Value2":"126.7125"}

I want to host this project on a remote server with a public URL, which should return the above results back from any network. I have 3 question regarding this:

** What modifications should I do to my current WCF project to host it on remote server.

** Given the various types of hosting like :

1) windows process activation services (WAS)
2) IIS
3) Self hosting
4) Hosting in a Windows service,

which type of hosting is best suited for hosting on remote server.

** What changes should I make in my App.Config file (including the change in my endpoint address from localhost to IP address) to make the service work.

Thanks.

1) You shouldn't need to make any changes to your project just because you want to host the code on another machine. I find this an odd question.

2) Given your choice of JSON as data format and a browser as test client, I'm guessing you want to make it available over HTTP using simple GET requests. In the Microsoft stack, IIS is the web server, and the natural choice for this scenario.

3) It is quite impossible to answer. I don't know what's in your app.config today. I don't know if you're going to authenticate, and if so how. And I don't want to know! That said, it seems to me if everything is supposed to behave as it does on your dev box, the bindings are already ok. I don't remember if a WCF service needs to know about the endpoint it is itself at (hard to see why it would need to know this, really); I would have thought it more natural to do such configuration on the host, eg IIS. The client of course should use a different endpoint pointing to wherever you host the service. (You can put many endpoints in app.config and let the user choose one, btw.)

I think most of us sin against the following advice now and then, but it is the best advice I can give: Read a book. Learn as much as possible about the thing you're using, in this case WCF. You'll get the time back later, and your software will be less bad!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM