Hello I got this program and this error.
Unable to complete web request. Web Exception error: Error en el servidor
remoto: (405) Método no permitido
Its supposed to send xml messages to a biztalk assembly and then it should
drop them on a folder. but I got that error.
Questions.
1. The VirtualFolder HTTPReceiver must be integrated or anonymous
authentication in IIS Manager.
2. Should I Imporsonate on the web.config.
3. Should I give any more permissions?
private void btnsubmit_Click(object sender, System.EventArgs e)
{
string requestLocation =
"http://192.168.1.132:90/HTTPReceiver/BTSHTTPReceive.dll";
Status.Text = "";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.PreserveWhitespace = true;
XmlNode tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element,
"Activity", "http://que.activity");
xmlDocument.AppendChild(tempXmlNode);
tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Attribute, "type", "");
tempXmlNode.Value = TypeList.SelectedItem.Text;
xmlDocument.DocumentElement.Attributes.Append( (XmlAttribute)tempXmlNode);
tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Location", "");
tempXmlNode.InnerText = Location.Text;
xmlDocument.DocumentElement.AppendChild(tempXmlNod e);
tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Timestamp", "");
DateTime now = DateTime.Now;
tempXmlNode.InnerText = now.ToString("s");
xmlDocument.DocumentElement.AppendChild(tempXmlNod e);
tempXmlNode = xmlDocument.CreateNode(XmlNodeType.Element, "Notes", "");
tempXmlNode.InnerText = Notes.Text;
xmlDocument.DocumentElement.AppendChild(tempXmlNod e);
try
{
HttpWebRequest request = (HttpWebRequest)
HttpWebRequest.Create(requestLocation);
request.Method = "POST";
// request.PreAuthenticate=true;
//
request.Credentials = new NetworkCredential("btservices", "vaz.711", "se");
// CredentialCache.DefaultCredentials;
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] requestData = encoding.GetBytes(xmlDocument.OuterXml);
request.ContentType="application/x-www-form-urlencoded";
request.ContentLength = xmlDocument.OuterXml.Length;
Status.Text += "Submitting activity message";
Stream requestStream = request.GetRequestStream();
requestStream.Write(requestData,0,requestData.Leng th);
requestStream.Flush();
requestStream.Close();
HttpWebResponse response;
response= (HttpWebResponse) request.GetResponse();
StreamReader responseData = new StreamReader( response.GetResponseStream());
Status.Text = System.Web.HttpUtility.HtmlEncode( responseData.ReadToEnd()) +
"<br>";
}
catch (WebException wex)
{
Status.Text = "Unable to complete web request. Web Exception error: " +
wex.Message;
}
}