To create an enterprise SMS platform (below)

xiaoxiao2021-03-06  43

I saw the previous article, everyone must think that I am brag, not a small program that sends a short message, I also dare to call the enterprise SMS platform, huh, don't worry, yesterday's content is better than the first step in the Long March, only The first step will go out to have a thousands of steps after the future, so the first step is to go hard. If you don't say much, you will start today. Yesterday our goal is clear, it is to do a small program that can send a short message, and today's demand is more complex, I often say the specific problem specific analysis, but this time I can't make this again, because the demand is a variety of diversification In order not to make this article to become a long story, I try to simplify the problem, so our DEMO is just a platform that builds a short message. Since it is a platform, there is a service provider and service user. The relationship between the two is clearly a relationship called and called. Since it is a platform, then we certainly hope that it can be used in most environments, such as providing sending services for users on the Internet, you can only provide sending services for users in the LAN, you can only provide sending services for this unit ( Narciting ... @ # $ # ^%). Since it is a platform, we certainly hope that this service can be easily referenced by other clients, such as Windows applications or web applications. OK, facing the above three basic requirements for SMS platforms, we can see that this will be a distributed project. Fortunately, .net has provided full preparation for our distributed development, we only need to take the weapon in your hand to win. These tools are Remoting and Web Service. Like yesterday, if you don't know much about these technologies, you can consult online information, but you don't need to learn deeply (temporarily uncomfortable), because they are very unpredictable, I don't want to eat a fat man. We can learn and familiarize them through some instances. (Figure 1: Simple use of a short message) can be seen by the above cases, the service caller is sent by "sending short messages" to achieve transmission, saying the service interface, we will immediately think of Web Service, Yes, it is such a stuff, use it as a service interface. Is it too simple to guess it? Don't be too early to be too early, the server is not practical in the form of web services. The consequences of doing this are: You need to reopen the serial port of your phone at each request, then you can send it, first this will cause the call to time when the time is delayed, and then we do not guarantee each connection. Can succeed that if you are unsuccessful, you will cause loss of information, which is obviously not allowed. The direct cause of the above situation is that Web Service is the same as all web applications, and cannot keep the object state, and can only respond to the request. Therefore, while establishing a web service, we also need to create an object to keep the SMS service status and monitor connection and send conditions. This object is generally a Windows application, but in my Demo it is a Windows service, because I hope it will be loaded. In this case, our server side runs two applications, a web service interface, a execution SMS sending service, and the two work together to complete the sending short message. In order to enable them to interact with each other, we have two options, one is to use Web Service technology, one is Remoting technology.

For the technical details of Remoting, you can view this. Because the two servers are in the same server, I have selected Remoting for performance. The process is already very clear, the server: server boot -> automatically load SMS service -> Initialization SMS platform; client: caller call service -> service interface Receive information -> Trigger "SMS Event" -> Send short messages. After you know these, we can do it. I will do it. I will not be described in the specific process. You can refer to Demo at the bottom of this article. It should be noted that this demo is simply achieved some basic functions, and there is no considering security, concurrency, stability, and abnormal processing, because these technical details are not within the scope of this article, I will be targeted in the future. Some content is more discussion. The following is the functionality and points of this platform of each module: RemoteServer: It is equivalent to the business logic layer, all SMS operations are here. The port number and other parameter information of the phone are stored in the READCONFIG.CS file. WindowsServer: Look at the name is a Windows service program, which is the host of RemoteServer, and it is very simple inside, just registered a channel. When receiving the callback request for the first time, it constructs a service object. And keep its state until the service is interrupted. This program needs to be registered when using it. The registration method is: installutil windowsserver.exe uninstall method is: installutil / u windowsserver.exewindowstest: A Windows calling the SMS service should be program, through it, you can turn the serial port, send a short message, etc. SMSWebService: Services interface, can be referenced by Windows applications and web applications. WebTest: A web application, only one page that sends a short message, references the above Web service inside it. Source code download:

Demo in this article (download close)

转载请注明原文地址:https://www.9cbs.com/read-113845.html

New Post(0)