TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Santhanaraman M
NA
1
1k
SUB:SOAP Request
Jan 31 2015 2:46 AM
Hello Sir/Madam,
I am working on SOAP requests, getting error again & again
"
The remote server returned an error: (500) Internal Server Error
" at
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
SOAP URL is configured in public IP.
Below is my code.
void testing()
{
string webURL = "http://IP address/momapitest/ServiceClients/OperationClient.svc";
string xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\" xmlns:ns=\"http://schemas.datacontract.org/2004/07/\"> <soapenv:Header/><soapenv:Body><tem:CurrentStockInquiry><!--Optional:--><tem:AuthenticationHeader><!--Optional:--><ns:AuthenticationKey>E836261630434E4DBA74FBB04A55CD8DCFE8792C4CED47718C5046B63F5DC851</ns:AuthenticationKey><!--Optional:--><ns:Password>49191748</ns:Password><!--Optional:--><ns:UserCompanyID>184</ns:UserCompanyID><!--Optional:--><ns:UserCustomerID>10875995</ns:UserCustomerID></tem:AuthenticationHeader></tem:CurrentStockInquiry></soapenv:Body></soapenv:Envelope>";
string url = webURL;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(xml);
req.Method = "POST";
req.ContentType = "text/xml; charset=\"utf-8\"";
Stream requestStream = null;
try
{
req.ContentLength = requestBytes.Length;
requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
}
catch (WebException ex)
{
}
finally
{
if (requestStream != null)
{
requestStream.Close();
}
}
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();
sr.Close();
res.Close();
XmlDocument xmlDocBooks = new XmlDocument();
XmlDocument doc = new XmlDocument();
doc.InnerXml = backstr;
}
Reply
Answers (
1
)
Reading File
ASP.net Return html response