Hello All Gurus!

I have developed a web service using DotNet Framework 3.5, having one webmethod that have a string parameter and returns parameter value after concatenating it with some string. When I tried to call it from the SOAP request, it only returns the concatenated string while parameter value is missing in it. It means that parameter value is not passing to it. Code is written below.


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

// [System.Web.Script.Services.ScriptService]

public class Service1 : System.Web.Services.WebService


public String HellowSahib(String name)


return ("Hello " + name + " after");




protected MSXML2.XMLHTTPClass objXMLHttp;
string strSoapEnvelope= "";

protected void Page_Load(object sender, EventArgs e)

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 += "<HellowSahib xmlns=\"http://tempuri.org\">";

strSoapEnvelope += "<name>Shakeel</name>";
strSoapEnvelope += "</HellowSahib >";

strSoapEnvelope += "</soap:Body>";
strSoapEnvelope += "</soap:Envelope>";

objXMLHttp = new MSXML2.XMLHTTPClass();
objXMLHttp.open("POST", "http://localhost/Asmx/Service1.asmx", false, "", "");

objXMLHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

objXMLHttp.setRequestHeader("SOAPAction", http://tempuri.org/HellowSahib);

string outXML = objXMLHttp.responseText.ToString();
lblReponse.Text = outXML.ToString();


When I execute this code, it returns "Hello after" instead of "Hello Shakeel after". Please let me know what is missing in it.


Please use code tags when posting any type of code
[code=syntax] # Code goes here

syntax can be replaced with any code that is supported by DaniWeb like: python, php, etc.

This article has been dead for over six months. Start a new discussion instead.