?
Solved

Consume webservice using SOAP

Posted on 2008-11-18
3
Medium Priority
?
984 Views
Last Modified: 2013-11-18
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?
0
Comment
Question by:smaranika_sikdar
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 1000 total points
ID: 22983129
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 23195827
The link has related information about the answer for this question.
I think that I should rewarded the points.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question