1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.UI;
6using System.Web.UI.WebControls;
7using Wittel.Phone.Locker.Service.Properties;
8using System.Net;
9using System.Text;
10using System.IO;
1112namespace Wittel.Phone.Locker.Service
13{
14 public partial class DoLock : System.Web.UI.Page
15 {
16 public string ServiceUrl
17 {
18 get
19 {
20 string tempUrl = string.Empty;
2122 if (Settings.Default.ccmIsSecure)
23 {
24 tempUrl = string.Format("https://{0}:{1}/axl/", Settings.Default.ccmIp, Settings.Default.ccmSecurePort);25 }
26 else
27 {
28 tempUrl = string.Format("http://{0}:{1}/axl/", Settings.Default.ccmIp, Settings.Default.ccmPort);29 }
3031 return tempUrl;
32 }
33 private set { }
34 }
3536 protected void Page_Load(object sender, EventArgs e)
37 {
38 try
39 {
40 if (!IsPostBack)
41 {
4243 ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
44 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(this.ServiceUrl));
45 request.ProtocolVersion = System.Net.HttpVersion.Version10;
46 request.Credentials = new NetworkCredential(Settings.Default.appUser, Settings.Default.appPwd);
47 request.Timeout = 100000;
48 request.Method = "POST";
49 request.ContentType = "text/xml";
5051 String axlSoapRequest = null;
52 String axlRequestEnvelope = null;
5354 axlSoapRequest = "POST /axl/ HTTP/1.0\r\n";
55 axlSoapRequest += "Host: " + Settings.Default.ccmIp + ":" + (Settings.Default.ccmIsSecure ? Settings.Default.ccmSecurePort : Settings.Default.ccmPort) + "\r\n";
56 axlSoapRequest += "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes((Settings.Default.appUser + ":" + Settings.Default.appPwd))) + "==\r\n";
57 axlSoapRequest += "Accept: text/*\r\n";
58 axlSoapRequest += "Content-type: text/xml\r\n";
59 axlSoapRequest += "SOAPAction: \"CUCM:DB ver=8.0\"\r\n";
60 axlSoapRequest += "Content-length: ";
6162 axlRequestEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> ";63 axlRequestEnvelope += "<SOAP-ENV:Body> ";
64 axlRequestEnvelope += "<axl:getPhone xmlns:axl=\"http://www.cisco.com/AXL/1.0\" xsi:schemaLocation=\"http://www.cisco.com/AXL/1.0 http://gkar.cisco.com/schema/axlsoap.xsd\" sequence=\"123456\"> ";65 axlRequestEnvelope += "<phoneName>SEP...</phoneName> ";
66 axlRequestEnvelope += "</axl:getPhone> ";
67 axlRequestEnvelope += "</SOAP-ENV:Body> ";
68 axlRequestEnvelope += "</SOAP-ENV:Envelope>";
6970 axlSoapRequest += axlRequestEnvelope.Length.ToString();
71 axlSoapRequest += "\r\n\r\n";
7273 Stream requestStream = request.GetRequestStream();
7475 requestStream.Write(System.Text.Encoding.ASCII.GetBytes(axlSoapRequest), 0, axlSoapRequest.Length);
76 requestStream.Close();
7778 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
7980 Stream responseStream = response.GetResponseStream();
81 StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);
8283 Response.ContentType = "text/xml";
84 Response.Charset = "utf-8";
8586 Response.Write(readStream.ReadToEnd());
87 }
88 }
89 catch (Exception ex)
90 {
91 throw ex;
92 }
93 }
94 }
95}