Thank you very much for the responses. I corrected the above function to include the full (X)path, and I am still unable to retrieve the lastName value. See the code below:
var lastNameNode = employeeInfoWS.selectSingleNode("/dfs:myFields/dfs:dataFields/s0:GetEmployeeInfoResponse/s0:GetEmployeeInfoResult/s0:empDS/s0:Employees/s0:lastName");
XDocument.UI.Alert(lastNameNode.text);
Interestingly, when I updated the above to:
var lastNameNode = employeeInfoWS.selectSingleNode("/dfs:myFields/dfs:dataFields/s0:GetEmployeeInfoResponse/s0:GetEmployeeInfoResult");
XDocument.UI.Alert(lastNameNode.text);
...I got the response (within an alert box) as the following:
AlrinEdward
So what is wrong with the original XPath, and how come I get the above when I shorten the XPath specification? FYI, the request specification for the web service method is as follows:
POST /CMH_InfoPath/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetEmployeeInfo"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetEmployeeInfo xmlns="http://tempuri.org/">
<employeeID>string</employeeID>
</GetEmployeeInfo>
</soap:Body>
</soap:Envelope>
...and the response specification is:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetEmployeeInfoResponse xmlns="http://tempuri.org/">
<GetEmployeeInfoResult>xml</GetEmployeeInfoResult>
</GetEmployeeInfoResponse>
</soap:Body>
</soap:Envelope>
The final piece is the WebMethod (web service) code itself, which is as follows:
[WebMethod]
public XmlNode GetEmployeeInfo(String employeeID)
{
XmlDataDocument xdd = null;
try
{
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
DataSet empDS = new DataSet("empDS");
SqlDataAdapter empDA = new SqlDataAdapter();
empDA.SelectCommand = new SqlCommand("SELECT lastName, firstName FROM Employees WHERE employeeID = '" + employeeID + "'", conn);
empDA.Fill(empDS, "Employees");
xdd = new XmlDataDocument(empDS);
}
catch (Exception ex)
{
}
return xdd.DocumentElement;
}
This is pretty much all the information on my project. I think my mistake may be silly and small, but my understanding may be quite a bit off as to how all this works!