Development based on the TR-069 Protocol (i)

Source: Internet
Author: User
Tags soap xmlns

TR 069 is a protocol proposed by DSL Fourm, that is, the CWMP protocol, mainly for the management of user terminal equipment.
Its functions are mainly composed of two pieces of ACS (Auto Config Server) and CPE (Customer pression equalment). Its specific functions, please refer to the TR-069 protocol, the network is also introduced, there is no more to say.
Recently, the company received a project to monitor and manage the performance of the telecommunications AP (Access point) device. I am also a developer of the project team, mainly responsible for building ACS.
According to the description of the agreement CPE will call the Acs,acs periodically and can also call the CPE. When ACS calls the CPE, it's actually
After sending a connectionrequest to the CPE, the CPE will send a inform to the ACS after the process of authorization and authentication.
It contains the EventCode, according to Enventcode we can already know is the CPE active call, or after the ACS call, the CPE to establish the connection. TR-069 specifies that the inform Event code that responds to ACS's call is 6 Connection Request.
I was also the first time to develop communications, something that had not been touched before. First of all, the next agreement, here I have a feeling, is to the next version of the TR-069 agreement, their own to slowly understand, do not understand the word to check, although the whole English, but also the most authoritative, but also the original flavor.
May see the agreement will feel very, many pronouns do not understand. Soap,rpc. Soap and PRC feel a bit like webservice, but I don't have the WebService experience, but I think in the TR-069 protocol, ACS specifies which methods of the CPE to invoke, and the required parameters, through the SOAP protocol. The specified method is then executed via RPC on the CPE side, returning the result after the method executes. The resulting results are then returned to the CPE through the SOAP protocol.
If a system has a function of querying the cell phone number of the attribution, then the B system also to achieve this function, then the two systems can communicate the way of data interaction. The b system specifies the function (method) and parameters (mobile number) to be executed through the SOAP protocol and then sends it to the a system. A system accepts the XML contained in the SOAP protocol, begins parsing, then calls its own method, then encapsulates the executed result into an XML-formatted data and sends it to the B system, and the result of the execution is obtained after the B system resolves. In short, the most important thing is communication.


Both ACS and CPE support the HTTP protocol, and all ACS only needs to have an HTTP container. So it was natural that we thought of the servlet to achieve it. I do not know what the format of XML, but the company urged the tight, all hurriedly started. Since I do not know how to achieve, but the CPE will call the timing, all the first thing it called after the reception to see, what is.

The CPE currently tested is the H3C AP.
First, create the Acsservlet and prepare to receive the message.
The code is as follows:

Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.InputStreamReader;
Import Java.io.OutputStream;
Import Java.util.HashMap;

Import javax.servlet.ServletException;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;
Import Javax.servlet.http.HttpServletResponse;
Import javax.servlet.http.HttpSession;

Import Com.seahigh.tyt.acs.util.AcsUtil;


/**
* ACS Serverimp
*
* @author Wang Cenley
* @Create Time 2009-1-4 pm 04:34:42 (c) Copy right Seahigh 2009
*/
public class Acsservlet extends HttpServlet {

Private static final long serialversionuid = 1L;

public void doget (HttpServletRequest request, httpservletresponse response)
Throws Servletexception {

}

public void DoPost (HttpServletRequest request, httpservletresponse response)
Throws Servletexception, IOException {
Session remembers the method that was executed

InputStream in = Request.getinputstream ();
String IP = request.getremoteaddr ();
InputStreamReader ir = new InputStreamReader (Request.getinputstream ());
BufferedReader input = new BufferedReader (IR);
String Line;
String xml = "";
while (line = Input.readline ()) = null) {
if (Line.trim (). Length () <= 0)
Continue
XML + = line;
}
In.close ();
Input.close ();
System.out.println (ip+ "Post:" +xml);

}
}


The servlet is then configured in Web. xml

<soap:envelope xmlns:xsd= "Http://www.w3.org/2001/XMLSchema"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xmlns:cwmp= "urn:dslforum-org:cwmp-1-0"
xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/" >
<soap:Header>
<cwmp:id soap:mustunderstand= "1" >1</cwmp:ID>
</soap:Header>
<soap:Body>
<cwmp:Inform>
<DeviceId>
<Manufacturer>H3C</Manufacturer>
<OUI>000FE2</OUI>
<ProductClass>Gateway</ProductClass>
<SerialNumber>210235A32MC085003208</SerialNumber>
</DeviceId>
<event soapenc:arraytype= "Cwmp:eventstruct[1" >
<EventStruct>
<eventcode>0 bootstrap</eventcode>
<CommandKey></CommandKey>
</EventStruct>
</Event>
<MaxEnvelopes>1</MaxEnvelopes>
<CurrentTime>2000-05-10T09:55:50</CurrentTime>
<RetryCount>0</RetryCount>
<parameterlist soapenc:arraytype= "Cwmp:parametervaluestruct[8" >
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceSummary</Name>
<value soap:type= "Soap:string" >internetgatewaydevice:1.0[] (baseline:1) </Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
<value soap:type= "Soap:string" >1.0</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
<value soap:type= "Soap:string" >Ver.A</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
<value soap:type= "Soap:string" >V100R001B47D011SP01</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
<value soap:type= "Soap:string" >ProvisioningCode</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
<value soap:type= "soap:string" &GT;HTTP://192.168.1.200:7547/CPE </Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
<value soap:type= "Soap:string" ></Value>
</ParameterValueStruct>
<ParameterValueStruct>
<name>internetgatewaydevice.wandevice.1.wanconnectiondevice.1.wanpppconnection.1.externalipaddress</ Name>
<value soap:type= "Soap:string" >192.168.1.200</Value>
</ParameterValueStruct>
</ParameterList>
</cwmp:Inform>

</soap:Body>
</soap:Envelope>

For more information, see: http://www.tr069bbs.com

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.