Darcy Schaffer | I'm actually using a C# application to send Web requests directly to the API url. The following is my test code.
//////////////////////// code sample ///////////////////// // build the soap request string soapRequest = BuildRequest(postData);
/***** POST DATA NOW LOOKS LIKE THIS <SOAP-ENV:Envelope> <SOAP-ENV:Body> <axl> <request xsi:type="ISgetGlobal"><ISgetGlobal></ISgetGlobal></request> </axl> </SOAP-ENV:Body> </SOAP-ENV:Envelope> *****/
// convert the request into a byte array UTF8Encoding encoding = new UTF8Encoding(); byte[] postBytes = encoding.GetBytes(soapRequest);
// grab the CME url and user credentials from configuration string ciscoUrl = ConfigurationManager.AppSettings["CiscoExpressServerAddress"]; string ciscoUsername = ConfigurationManager.AppSettings["CiscoLogon"]; string ciscoPassword = ConfigurationManager.AppSettings["CiscoPassword"];
// create the request object WebRequest request = WebRequest.Create(string.Format("http://{0}/ios_xml_app/cme", ciscoUrl));
// set the username and password that is valid for this CME server request.Credentials = new NetworkCredential(ciscoUsername, ciscoPassword);
// setup the request request.Method = "POST"; request.ContentLength = postData.Length; request.ContentType = "text/xml";
// send the request to the CME server Stream dataStream = request.GetRequestStream(); dataStream.Write(postBytes, 0, postBytes.Length); dataStream.Close();
// get the response WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream());
// convert the response into a string to send back to the caller StringBuilder result = new StringBuilder(); string str = reader.ReadLine(); while (str != null) { result.AppendLine(str); str = reader.ReadLine(); }
return result.ToString(); |
| Please sign in to flag this as inappropriate. |