Я пытаюсь собрать на своей работе программное обеспечение c#, которое получает информацию от устройств с tr-069 (CWMP). Может кто-нибудь сказать мне, как go дальше построить это? Может также кто-нибудь сказать мне, как получить сообщение soap от CPE
Я уже сделал это. Первая функция только для soap
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
namespace SoapToClassData
{
class Program
{
static void Main(string[] args)
{
Execute();
}
public static void Execute()
{
HttpWebRequest request = CreateWebRequest();
XmlDocument soapEnvelopeXml = new XmlDocument();
// soap
soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/""
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"">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand=""1"">279384</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:Inform>
<DeviceId>
<Manufacturer>DrayTek Corp.</Manufacturer>
<OUI>00507F</OUI>
<ProductClass>EG8040H5</ProductClass>
<SerialNumber>001DAA18E148</SerialNumber>
</DeviceId>
<Event SOAP-ENC:arrayType=""cwmp: EventStruct[04]"">
<EventStruct>
<EventCode>0 BOOTSTRAP</EventCode>
<CommandKey></CommandKey>
</EventStruct>
<EventStruct>
<EventCode>1 BOOT</EventCode>
<CommandKey></CommandKey>
</EventStruct>
<EventStruct>
<EventCode>2 PERIODIC</EventCode>
<CommandKey></CommandKey>
</EventStruct>
<EventStruct>
<EventCode>4 VALUE CHANGE</EventCode>
<CommandKey></CommandKey>
</EventStruct>
</Event>
<MaxEnvelopes>1</MaxEnvelopes>
<CurrentTime>2020-02-17T14:30:33+00:00</CurrentTime>
<RetryCount>0</RetryCount>
<ParameterList SOAP-ENC:arrayType=""cwmp:ParameterValueStruct[9]"">
<ParameterValueStruct>
<Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
<Value xsi:type=""xsd:string""/>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
<Value xsi:type=""xsd:string"">http://ip:8069/cwm/CRN.html</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceSummary</Name>
<Value xsi:type=""xsd:string"">InternetGatewayDevice:1.4[](Baseline:1, EthernetLAN:1, WiFiLAN:2, Time:1, IPPing:1, DeviceAssociation:1)</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SerialNumber</Name>
<Value xsi:type=""xsd:string"">001DAA18E148</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
<Value xsi:type=""xsd:string"">1.0</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
<Value xsi:type=""xsd:string"">e</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
<Value xsi:type=""xsd:string"">3.9.1.1</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
<Value xsi:type=""xsd:string""/>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name>
<Value xsi:type=""xsd:string"">213.125.61.108</Value>
</ParameterValueStruct>
</ParameterList>
</cwmp:Inform>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>CWMP fault</faultstring>
<detail>
<cwmp:fault>
<FaultCode>9005</FaultCode>
<FaultString>Invalid parameter Name</FaultString>
</cwmp:fault>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>");
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string soapResult = rd.ReadToEnd();
// I get here the soap that i've typed here above
Console.WriteLine(soapResult);
}
}
}
Здесь я устанавливаю соединение с AC и отправляю soap
// connection with the acs
public static HttpWebRequest CreateWebRequest()
{
string action = "https://acsnoc.hompes.nl:443/ACSServer/services/ACSServlet";
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"https://acsnoc.hompes.nl:443/ACSServer/services/ACSServlet");
webRequest.Credentials = new NetworkCredential("username", "password");
webRequest.Headers.Add("SOAPAction", action);
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
}
}
}