Java SGIP survey document (1)

Source: Internet
Author: User

Hi ~ Everyone ~~~

First, SGIP has multiple manufacturers' API implementations. The following code is the code of zte sgip api (ZTE abbreviated as ZTE. In fact, the APIs of other vendors are similar.

 

 

I. preparations:
1. First, you need to obtain the Java apipacket sgip_java.rar of SGIP. (Download? Copy? Connected to you? Whatever ~)
2. Open eclipse and create two new Java projects named sgipclientdemo and sgipserverdemo respectively.
3.decompress sgip_java.rar and copy the sgipclientdemo and sgipserverdemo SRC directories under the release package
Eclipse project.
4. Replace the jar package (COM. ZTE. smgw. API. Jar) in the sgip_java \ release \ API folder
Add the jar package (log4j-1.2.15.jar) under the \ sgip_java \ release \ Lib folder to
In eclipse. (Java build path. If not, you can hit the wall !)
5. Set the two configuration files (log4j. properties and sgipconfig. properties) in the \ sgip_java \ release \ API folder)
Copy them to the src directory of the two eclipse projects respectively. (These two files do not need to be modified normally. At least I have not changed them ~)

PS: The most important preparation work is that you need to go to the China Unicom gateway to apply for the first-off parameters and so on. Let China Unicom open an account for you and so on.
(But thats none of my business right? Cuz im a coder .)

 

Ii. SMS upstream

SMS upstream process: test the mobile phone --> Unicom gateway --> JAVA listener
Principle of SMS upstream:
(Before testing, you need to have China Unicom gateway configure the IP address and port number for listening to upstream messages)
First, test the mobile phone to send a text message to China Unicom's segment, such as 105550200508,
This number is called a special server number. Then, China Unicom gateway will listen to this special server number. Once a text message is sent to this special server number, China Unicom gateway will route it to the configured IP address and port, then, push the short message to your listener server. The listening server must always run a multi-threaded listening service. In this way, you can receive the text message content in the Java program.
Note:
Test Machine IP and port must be configured in advance to connect to the gateway, and must be able to connect to the Internet, if the Internet to the Intranet, you need to use TCP-TRACE tools for IP conversion.

 

The sgipserverdemo project is mainly used for text message upstream.
You need to configure four main parameters:
Info. IP = "111.111.11.11"; // this IP address is the IP address you applied. Use a powerful TCP-TRACE tool if the Internet is switched to Intranet
Info. Port = 10227; // This port number is the port number you applied.
Info. Username = "yang"; // and so on, the account you applied
Info. Password = "yanglala"; // The password you applied
The above four parameters are provided by China Unicom for you. If you don't know, just call them.

After the setting is complete, you can run it. That's easy!
Run as --> I don't need to teach you Java application?

The prompt message for successful run is as follows:
Info [main] com. ZTE. smgw. API. SGIP. server. sgipserver-SGIP server is INIT success!
Info [main] com. ZTE. smgw. Socket. server. socketserver-11.11.11.11: 11111 is begin to listen!
Info [main] com. ZTE. smgw. API. SGIP. server. sgipserver-SGIP server is start success!
 
Congratulations, you can proceed to the next step ~

Pick up your mobile phone and send a test text message to the special server number you applied. For example, send an "I luv u" to 105550200508"
At this moment
Sgipdeliver deliver = (sgipdeliver) msg. OBJ;
Will receive the text message content;
And press him out.
Sgipdeliverbody A = deliver. getbody ();
System. Out. println (new string (A. getmessagecontent ()));

Console: I luv u.
So far, all upstream messages are OK.
(I won't talk about Chinese here, DIY .)

PS:

MSG. messagetype = 1 indicates listening to upstream messages

MSG. messagetype = 2 indicates listening to the downstream SMS Receipt Report, which will be mentioned in the downstream SMS

 

If not, call the technical support of China Unicom. My process is a normal process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.