Development of simple SMS interface for Web services
--order by Yang
It's been a while. See a bit about WCF technology, also learned a little, rookie level. Helpless nowhere to use WCF, inadvertently see SMS Verification code, you want to use WCF to create an SMS interface! Speaking of SMS interface, engage in development are certainly not unfamiliar, but generally in large-scale Internet site use of SMS interface I want to be mobile or Unicom Telecom has done the SMS interface, helpless environment constraints, want to call their interface must have a very complex application process, and not everyone can apply to. It is impossible to learn as an individual. Helpless can only another way, think of oneself have an Android mobile phone, so play up its idea. The next step is to think of the ADB tool for granted. Then the ADB is all called the Android Debug Bridge, is to play the role of the Debug bridge. We can use the ADB command to send instructions to our Android phone to send a message to a mobile phone number, or even make a phone call, this is a very simple thing, so since the creation of SMS interface of the basic physical equipment and environment have.
The next step is design services. The idea is that, to send a text message, we first need to know the recipient's mobile phone number and SMS message. As a test, I also added a call function (this was not in accordance with the design specification). To this end we need users of the service to provide us with these basic information, so we define them as data contracts, including mobile phone numbers, information content. Since we have added the ability to call, in order to do it in one operation, I have also defined an enumeration type to represent the client's request category, whether it is texting or calling! The data contract is as follows:
Because the cell phone number and the type of operation are necessary, we use isrequired=true.
Next is the service contract:
Then we will implement the service contract interface:
On the ADB command I do not introduce too much, Baidu on a lot! is the implementation of the interface!
We use process-managed mode to publish the service:
Related configuration:
Run the console program and let the service take effect:
OK Service Deployment Successful! Let's use the client test again:
Still using the console program
The first is to use svcutil to get the metadata:
Add in
The client code is as follows:
Then we run the program!
1. Send SMS:
Then call the phone test:
Done!
It's just a simple SMS interface! In fact, in the production environment these functions are far from meeting the requirements, such as we need to track audit, need to have user modules, need to have billing module, etc., which also involves many technical details of WCF, message contract encryption and so on!
Development of simple SMS interface for Web services