Self-hosting WCF ServiceHost / WebServiceHost Concurrency / Formatting Design Options (.NET 3.5)

Thus, I will provide several functions through self-service (in WindowsService) WebServiceHost (not sure how to handle HTTP GET / POST with ServiceHost), one of which can be called a lot of time. This function will also rely on the connection in the appdomain (hosted by WindowsService so that it can stay alive on multiple requests).

I have the following problems and I would be so grateful for any comments / comments / comments:

  • Concurrent access - how WebServiceHost handles many concurrent requests. Are they queued and processed sequentially or are new copies of contracts automatically created?
  • WebServiceHost -> Communication with WindowsService - I need a form of communication between WebServiceHost and WindowsService hosting for things like requesting a new session if it does not exist. Perhaps by implementing a class that extends WebServiceHost with events that subscribe to WindowsService ... (if there is no other way, I can set the event in WindowsService when I execute the request ...)
  • Multiple WebServiceHosts or contracts - Will any real performance increase lead to running multiple instances of WebServiceHost in different threads (one per endpoint)? A better understanding of the first paragraph will probably help here.
  • WSDL - I'm not sure why (maybe you just need to do more reading), but I'm not sure how to get the WebServiceHost database endpoint to respond with a WDSL document describing the available contract. Not required, since all operations will be performed using GET requests, which are unlikely to change, but it would be nice to have ...

About this at the moment;) I read a lot about WCF and would like me to go into it for a long time, but definitely still study.

+4
source share
1 answer

Concurrent access is what you can set with ServiceBehaviorAttribute. There are a number of options - you can create WCF a new instance of the service class for each incoming request, or you can have one instance that processes all requests. In addition, you can tell WCF whether to send you requests one at a time or sequentially.

WebServiceHost -> WindowsService Communication. Two spring approaches: WCF supports a mode called a "well-known instance" where you pass an instance of your service to the ServiceHost constructor instead of passing a type and let WCF create it for you. In this mode, you can preconfigure your service instance with a link to your hosting code (you can use events as an alternative). An alternative if you want to maintain instancing flexibility would be to have a static method in your hosting code that the WCF service could call back.

Multiple WebServiceHosts or Contracts - there really is no advantage to having more than one instance of ServiceHost. see also this SO stream: What are the advantages of several services? Does one ServiceHost support multiple simultaneous connections on one endpoint? .

WSDL Although you can enable WSDL by enabling metadata publishing ( http://msdn.microsoft.com/en-us/library/ms788760.aspx ), WSDL support is for SOAP services, not pure HTTP GET / POST. The WSDL that is automatically generated for your service will most likely not be very useful.

+5
source

Source: https://habr.com/ru/post/1309607/


All Articles