HI All, I'm trying to update users Pin number with a .Net C# webpage.
I have pasted the code and error below. I ended up using soap although I noticed there is a risservice.wsdl that should have methods to update pins. Any help would be greatly appreciated.
code
----------------------
using System;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Net.Mail;
using System.Net.Mime;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;
using System.Text;
using System.Runtime.InteropServices;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("https://ip:8443/axl/"));
request.ProtocolVersion = System.Net.HttpVersion.Version10;
request.Credentials = new NetworkCredential("user", "pass");
request.Timeout = 100000;
request.Method = "POST";
request.ContentType = "text/xml";
String axlSoapRequest = null;
String axlRequestEnvelope = null;
axlSoapRequest = "POST /axl/ HTTP/1.0\r\n";
axlSoapRequest += "Host: host:8443 \r\n"; axlSoapRequest += "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(("user" + ":" + "pass"))) + "==\r\n";
axlSoapRequest += "Accept: text/*\r\n";
axlSoapRequest += "Content-type: text/xml\r\n";
axlSoapRequest += "SOAPAction: \"CUCM

B ver=8.0\"\r\n";
axlSoapRequest += "Content-length: ";
axlRequestEnvelope = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://www.cisco.com/AXL/API/8.5\"> ";
axlRequestEnvelope += "<soapenv:Header/>";
axlRequestEnvelope += "<soapenv:Body>";
axlRequestEnvelope += "<ns:updateUser sequence=\"?\">";
axlRequestEnvelope += "<userid>user</userid>";
axlRequestEnvelope += "<password>user pass</password>";
axlRequestEnvelope += "<pin>new pin</pin>";
axlRequestEnvelope += "</ns:updateUser>";
axlRequestEnvelope += "</soapenv:Body> ";
axlRequestEnvelope += "</soapenv:Envelope>";
axlSoapRequest += axlRequestEnvelope.ToString();
axlSoapRequest += "\r\n\r\n";
Stream requestStream = request.GetRequestStream();
requestStream.Write(System.Text.Encoding.ASCII.GetBytes(axlSoapRequest), 0, axlSoapRequest.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);
Label1.Text = readStream.ReadToEnd();
Response.ContentType = "text/xml";
Response.Charset = "utf-8";
Response.Write(readStream.ReadToEnd());
}
catch (Exception ex)
{
}
}
}
this is the error that is printed to the page
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
- <SOAP-ENV:Body>
- <SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Content is not allowed in prolog.</faultstring>
- <detail>
- <axl:Error xmlns:axl="http://www.cisco.com/AXL/API/1.0">
<axl:code>5001</axl:code>
<axl:message>Content is not allowed in prolog.</axl:message>
<request />
</axl:Error>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>