locked
Logging an Error message RRS feed

  • Question

  • Hello,

    I would like to thow an error if a Webservice request returns no data.  It does not look like there is a verification event handler for a WebService request.  What is the best way to flag an error if the XML returned does not have any data?

    Here is an example of the code I am using...

    this.BeginTransaction("GetDateList");

    wsResults = GetDateListRequest.GetDateList("1234", "127");

    this.EndTransaction("GetDateList");

    reader = new XmlNodeReader(wsResults);

    docNav = new XPathDocument(reader);

    nav = docNav.CreateNavigator();

    strExpression = "ROOT/DATA/row";

    NodeIter = nav.Select(strExpression);

    NodeIter.MoveNext();

    if (NodeIter.Current.Value == "")

    //log error here

     

     

    Tuesday, March 14, 2006 5:02 PM

Answers

All replies

  • One possibility is to create a unit test and pass or fail it there. See the link below for create unit Test for Web Services.

     

    http://msdn2.microsoft.com/en-us/library/ms243399.aspx

     

    Friday, March 17, 2006 10:05 PM
  • Thanks Johnny!

    Your response let me to an answer.  I put this line of code in and it did the trick...

    Assert.IsTrue(NodeIter.Current.Name.Equals("row"), "Web Service GetEvent did not return any data");

    I had to add the following also...

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    Monday, March 20, 2006 6:25 PM