简体   繁体   中英

hosting WCF Application in IIS

I am creating a WCF project. The project contains two applications: one is console based, containing few classes to support database operations like 'Insert', 'Update', 'Encryption' etc. and another one is WCF service application which contains the operation contracts. Now, the WCF service application will be using the console application for database operations. I want to know the process of hosting this project in IIS. I have the steps in my mind, please guide me whether I am right or wrong:

Step I - At first, I will build the console application and add the reference in WCF application.

Step II - After finishing with the WCF tasks, I will host only the WCF Application in IIS.

Is this process correct? Please guide me the right and efficient way.

Thanks.

you should split your console application. both the console application and the WCF application should use a DLL with all the logic in it.

once you will split your solution your WCF wont have any problems to interact with the console application.

I am assuming you are looking to host the project as console application for the purpose of developing the consumers. If so, then you may not have to create another application, you can run the wcf project using visual studio itself which can run it as an IIS Express service. You can also easily debug the app in case you need to fix issues.

Once you are done, you can move this to IIS and host it with any of your preferred bindings like basicHttpBinding or netTcpBindings. You have to make sure to enable the protocols in your IIS --> Your site --> Advanced Settings --> Enabled Protocols. If you need http binding or net.tcp, enter the values like http, net.tcp as per your config requirements.

Always add a logging framework like log4net early in the project as it would help us in debugging rare issues by enabling logging.

First thing, referring the console application is not the right way in other words bad code. For testing or development purpose they used console application.

My suggestion is, add new class library project and move all the class files from console app to this class library project. Refer this library project to your WCF service and start building the app.

Now you can right click the WCF project and click the publish.

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