Name DataType Subtype Length Credential DotNet System.Net.NetworkCredential.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' MemoryStream DotNet System.IO.MemoryStream.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLRequestDoc DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLResponseDoc DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLProsInstr DotNet System.Xml.XmlProcessingInstruction.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLElement1 DotNet System.Xml.XmlElement.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLElement2 DotNet System.Xml.XmlElement.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLElement3 DotNet System.Xml.XmlElement.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLNode4 DotNet System.Xml.XmlNode.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLNsMgr DotNet System.Xml.XmlNamespaceManager.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' msURL Text oRequest DotNet System.Net.HttpWebRequest.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' oResponse DotNet System.Net.HttpWebResponse.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Ouri DotNet System.Uri.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLRequestDoc := XMLResponseDoc.XmlDocument; XMLProsInstr := XMLRequestDoc.CreateProcessingInstruction('xml','version="1.0" encoding="utf-8"'); XMLRequestDoc.AppendChild(XMLProsInstr); XMLElement1 := XMLRequestDoc.CreateElement('soap','Envelope','http://www.w3.org/2001/XMLSchema'); XMLElement1.SetAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance'); XMLElement1.SetAttribute('xmlns:xsd','http://schemas.xmlsoap.org/soap/envelope/'); XMLElement2 := XMLRequestDoc.CreateElement('soap','Body', 'http://schemas.xmlsoap.org/soap/envelope/'); XMLElement3 := XMLRequestDoc.CreateElement('insertuserbyerpid'); XMLElement3.SetAttribute('xmlns',STRSUBSTNO('http://tempuri.org/')); XMLNode4 := XMLRequestDoc.CreateElement('erpuserid'); XMLNode4.InnerText := ID; XMLElement3.AppendChild(XMLNode4); XMLElement3.AppendChild(XMLNode4); XMLElement2.AppendChild(XMLElement3); XMLElement1.AppendChild(XMLElement2); XMLRequestDoc.AppendChild(XMLElement1); XMLRequestDoc.Save('C:\TEMP\RequestDotNet.xml'); msURL := GetEShopServiceURL; Ouri := Ouri.Uri(msURL); oRequest := oRequest.Create(msURL); oRequest.Method := 'POST'; oRequest.ContentType := 'text/xml; charset=utf-8'; //'XML' oRequest.KeepAlive := TRUE; oRequest.Timeout := 10000; MemoryStream := oRequest.GetRequestStream; XMLRequestDoc.Save(MemoryStream); SLEEP(100); MemoryStream.Flush; MemoryStream.Close; oResponse:=oResponse.HttpWebResponse; //DESMS120314 oRequest := oRequest.GetResponse; MemoryStream := oResponse.GetResponseStream; XMLResponseDoc := XMLResponseDoc.XmlDocument; XMLResponseDoc.Load(MemoryStream); SLEEP(100); MemoryStream.Flush; MemoryStream.Close; XMLNsMgr := XMLNsMgr.XmlNamespaceManager(XMLResponseDoc.NameTable); XMLNsMgr.AddNamespace('urn',STRSUBSTNO('urn:microsoft-dynamics-schemas/codeunit/%1','Insertuserbyerpid')); XMLNode4 := XMLResponseDoc.SelectSingleNode('//urn:return_value',XMLNsMgr); IF UPPERCASE(XMLNode4.InnerText) = 'FALSE' THEN BEGIN XMLNode4 := XMLResponseDoc.SelectSingleNode('//urn:responseMessage',XMLNsMgr); ERROR(XMLNode4.InnerText); END;
Comments
there's probably nothing wrong with your Webrequest call but rather with the SOAP Request document you are sending. It might be an authentication problem though.
Along with the status 500, the web server usually sends you some explanation. You will want to inspect that info. Either use a network monitor to capture the communication or add a wrapper to your Webrequest that allows you to catch and handle Dotnet exceptions.
You might be interested in the following AddOn from the German NAV Developers Blog, if you opt for the latter: Catch Me If You Can – try-catch für .NET in C/AL