-3
我正在做一個HttpWebRequest,在那裏我將一個Xml文檔發送到一個Web服務並將請求的結果從單元測試中返回。在return語句之後,Xml文檔被取消。爲什麼?XmlDocument在返回語句後變爲空
public class BaseTest
{
public XmlDocument _xmlDoc;
public string CallWebService()
{
XmlDocument _xmlDoc = "./xmlfile.xml";
/*Prepare HttpHeaders and make webservice call*/
string result = reader.ReadToEnd().ToString();
return result;//<-----_xmlDoc becomes null at this point.
}
}
[TestMethod]
public void TestWebService()
{
string result = CallWebService();
Assert.IsTrue(result.Contains("SUCCESS"));
}
信息太少。我認爲這個錯誤是在別的地方 – Matt
代碼中有幾個錯誤 – sjkm
轉身,深呼吸,想想快樂五分鐘,回頭看看你的問題。你看到我們的問題? –