I have .net C# Test Harness consuming a new WebService I wrote. I am getting "The remote server returned an error : (500) Internal Server Error" when it executes
WebResponse webResponse = webRequest.GetResponse();
My Test Harness code to invoke Web Service is as follows :
private void CallUsingSOAP(string InXml, out XmlDocument xmlResponse)
{
string strSoapRequest = "";
xmlResponse = null;
string strABCWebServiceUrl = ConfigurationManager.AppSe
ttings["AB
CTestWebSe
rviceURL"]
;
strSoapRequest = "";
strSoapRequest += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
strSoapRequest += "<soap:Envelope ";
strSoapRequest += "xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance\"
";
strSoapRequest += "xmlns:xsd=\"
http://www.w3.org/2001/XMLSchema\" ";
strSoapRequest += "xmlns:soap=\"
http://schemas.xmlsoap.org/soap/envelope/\" ";
strSoapRequest += "xmlns=\"
http://www.ACORD.org/standards/PC_Surety/ACORD1.10.0/xml/\" ";
strSoapRequest += ">";
strSoapRequest += "<soap:Header>";
strSoapRequest += "<ContractId/> ";
strSoapRequest += "<AppInfo/> ";
strSoapRequest += "</soap:Header>";
strSoapRequest += "<soap:Body>";
strSoapRequest += InXml;
strSoapRequest += "</soap:Body>";
strSoapRequest += "</soap:Envelope>";
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strSoapRequ
est);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest
.Create(st
rABCWebSer
viceUrl);
webRequest.Headers.Add("SO
APAction",
" ABCMethod");
//webRequest.Timeout = Int32.Parse("2000");
webRequest.ContentType = "text/xml; charset=utf-8";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
Stream webStream = webRequest.GetRequestStrea
m();
xmlDoc.Save(webStream);
webStream.Close();
WebResponse webResponse = webRequest.GetResponse();
webStream = webResponse.GetResponseStr
eam();
XmlTextReader xmlReader = new XmlTextReader(webStream);
// xmlResponse = new XmlDocument();
xmlResponse.Load(xmlReader
);
webStream.Close();
}
catch (Exception e )
{
throw new Exception ("" + e.Message);
}
It throws a exception when it executes the
WebResponse webResponse = webRequest.GetResponse();
The strSoapRequest is a well formed XML, I checked it it looks ok.
I am not sure why i am getting this error?
My Web Service code is as follows :
namespace ABCTestWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "
http://tempuri.org/")]
[WebServiceBinding(Conform
sTo = WsiProfiles.BasicProfile1_
1)]
[ToolboxItem(false)]
public class ABCTestWebService : System.Web.Services.WebSer
vice
{
[WebMethod]
public XmlDocumentABCMethod (XmlDocument InputXML)
{
}
}
Start Free Trial