Consume webservice using SOAP

I have tried calling web service using SOAP. I tried the following code. But did not work. Its giving the error.
Code:
protected void btnTestSoap_Click(object sender, EventArgs e)
{
string strSoapEnvelope = "";
strSoapEnvelope =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>";strSoapEnvelope += "<soap:Envelope ";
strSoapEnvelope +=
"xmlns:xsi = \"http://www.w3.org/2001/XMLSchema-instance\" ";strSoapEnvelope += "xmlns:xsd= \"http://www.w3.org/2001/XMLSchema\" ";
strSoapEnvelope +=
"xmlns:soap= \"http://schemas.xmlsoap.org/soap/envelope/\">";strSoapEnvelope += "<soap:Body>";
strSoapEnvelope +=
"<AddTwoNumbers xmlns=\"http://localhost/wwwroot/addnumbers/Service1\">";strSoapEnvelope += "<a>10</a>";
strSoapEnvelope +=
"<b>12</b>";strSoapEnvelope += "</AddTwoNumbers >";
strSoapEnvelope +=
"</soap:Body>";strSoapEnvelope += "</soap:Envelope>";
objXMLHttp =
new MSXML2.ServerXMLHTTP40();objXMLHttp.open("POST", "http://localhost:1600/MyWebService/WebService.asmx",false,"","");
objXMLHttp.setRequestHeader(
"Content-Type", "text/xml; charset=utf-8");objXMLHttp.setRequestHeader("SOAPAction", "http://localhost:1600/MyWebService/WebService/WebAdd");
objXMLHttp.send(strSoapEnvelope.ToString());
objXMLHttp.waitForResponse(500);
string outXML = objXMLHttp.responseText.ToString();
Label1.Text = outXML.ToString();
 }
 Error :
soap:ClientSystem.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost:1600/MyWebService/WebService/WebAdd. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
 Is there any solution to get rid of?
smaranika_sikdarAsked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
Consume WebService Using SOAP
http://www.codeproject.com/KB/webservices/Consume_WebService.aspx


Create and Consume Web Services at Server and Client
http://www.asp101.com/articles/colin/webservices/default.asp
0
 
DhaestCommented:
The link has related information about the answer for this question.
I think that I should rewarded the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.