Wednesday, January 12, 2005
Web Service Testing

Started playing with the .text web service last night to see how I might be able to move DotText2DasBlog to web services instead of direct connection.  My initial thought was to just replace the DB connection with web services, but it's looking like I might build both in.  I don't see a way to extract comments from the web service as of yet (if anyone know a comment would be great), so since a goal is to also migrate comments, I may choose to support both methodologies.  More on this soon.

Either way, as I started testing I started to think about a better way to test web services.  Knowing there are probably a ton of ways to handle this, I went searching.  I was right.  There are just a ton of apps that have been developed to help test, and work with web services.  Most of them cost $$, though, which is not something I was interested in spending for this. 

My search did end up yielding a few cool things, though.  First, is the .net xml web service repertory (del.icio.us'd).  This is a nice collection of resources for web service development in .net.   They also had a direct link to the .net Web Service Studio.  This was an app that I had seen earlier in the search, that seemed to be removed form gotdotnet.  Even though the sources were removed, though, they had a direct link to the binary which is still there.

This little WSS app is very cool.  It uses wsdl and reflection to build a simple web service test client.  It's a very cool little tool, especially for the price.  Released in 2002 so it might be old news for most, but for me it was new.  Wish the source was still out there. 

 



1/23/2005 3:53:00 PM (Eastern Standard Time, UTC-05:00)
I'm not sure about getting comments.. Darrell Norton is working on a blog mover tool, and he's had similar problems getting comments. I helped him parse out the commentRss, with the following code (a HAAAAAAACK)
<br>
<br>-Brendan
<br>
<br>private void btnGetComments_Click(object sender, System.EventArgs e)
<br>{
<br>System.Xml.XmlTextReader rdr = new XmlTextReader(&quot;<a target="_new" href="http://dotnetjunkies.com/WebLog/darrell.norton/comments/commentRss/42340.aspx&quot;">http://dotnetjunkies.com/WebLog/darrell.norton/comments/commentRss/42340.aspx&quot;</a>);
<br>
<br> ArrayList arrayOfComments = new ArrayList();
<br>
<br> String commentFmt = &quot;{0}: {1}\r\n&quot;;
<br> while(rdr.Read())
<br> {
<br> string tagName = rdr.Name.ToString();
<br> switch(tagName)
<br> {
<br> case &quot;item&quot;:
<br> mwPostComments comment = this.ParseItem(rdr);
<br> arrayOfComments.Add(comment);
<br> break;
<br> default:
<br> // Could parse the whole post here, if we wanted to.
<br> break;
<br> }
<br> }
<br>}
<br>
<br>private mwPostComments ParseItem(XmlTextReader rdr)
<br>{
<br> mwPostComments comment = new mwPostComments();
<br> rdr.Read();
<br> while(rdr.Name != &quot;item&quot;)
<br> {
<br> switch(rdr.Name)
<br> {
<br> case &quot;dc:creator&quot;:
<br> rdr.Read();
<br> comment.Creator = rdr.Value;
<br> rdr.Read();
<br> break;
<br> case &quot;title&quot;:
<br> rdr.Read();
<br> comment.Title = rdr.Value;
<br> rdr.Read();
<br> break;
<br> case &quot;link&quot;:
<br> rdr.Read();
<br> comment.Link = rdr.Value;
<br> rdr.Read();
<br> break;
<br> case &quot;pubDate&quot;:
<br> rdr.Read();
<br> comment.PubDate = rdr.Value;
<br> rdr.Read();
<br> break;
<br> case &quot;guid&quot;:
<br> rdr.Read();
<br> comment.Guid = rdr.Value;
<br> rdr.Read();
<br> break;
<br> case &quot;description&quot;:
<br> rdr.Read();
<br> comment.Description = rdr.Value;
<br> rdr.Read();
<br> break;
<br> }
<br> rdr.Read();
<br> if(rdr.EOF) return comment;
<br> }
<br> return comment;
<br>}
<br>
<br>
<br>
<br>
<br>/// &lt;summary&gt;
<br>/// Made this, cause I didn't know where to put the comments.
<br>/// &lt;/summary&gt;
<br>public class mwPostComments
<br>{
<br> string creator;
<br> string title;
<br> string link;
<br> string pubDate;
<br> string guid;
<br> string description;
<br> public string Creator
<br> {
<br> get { return creator; }
<br> set { creator = value; }
<br> }
<br> public string Title
<br> {
<br> get { return title; }
<br> set { title = value; }
<br> }
<br> public string Link
<br> {
<br> get { return link; }
<br> set { link = value; }
<br> }
<br> public string PubDate
<br> {
<br> get { return pubDate; }
<br> set { pubDate = value; }
<br> }
<br> public string Guid
<br> {
<br> get { return guid; }
<br> set { guid = value; }
<br> }
<br> public string Description
<br> {
<br> get { return description; }
<br> set { description = value; }
<br> }
<br> }
1/23/2005 3:53:00 PM (Eastern Standard Time, UTC-05:00)
Thanks alot Brendan! I will def take a look at this. Glad to know I'm not the only one that was struggling trying to extract comments via the web services.
1/23/2005 3:53:00 PM (Eastern Standard Time, UTC-05:00)
No Problem. Perhaps we should all combine efforts on this stuff. Maybe a GDN workspace or something.
1/23/2005 3:53:00 PM (Eastern Standard Time, UTC-05:00)
I went at this from a diff direction. Used an XmlDocument and XPath. Yeilded
<br>
<br> public dotTextComments GetComments(int entryId)
<br> {
<br> dotTextComments comments = new dotTextComments();
<br>
<br> HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(getCommentUrl(entryId));
<br> HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
<br> XmlDocument xml = new XmlDocument();
<br> xml.LoadXml(new System.IO.StreamReader(httpResponse.GetResponseStream()).ReadToEnd());
<br> XmlNamespaceManager nsm = XmlHelper.GetNamespaces(xml);
<br>
<br> XmlNodeList commentList = xml.SelectNodes(&quot;//item&quot;,nsm);
<br>
<br> foreach (XmlNode n in commentList)
<br> {
<br> dotTextComment c = new dotTextComment();
<br> c.Creator = n.SelectSingleNode(&quot;dc:creator&quot;,nsm).InnerText;
<br> c.Description = n.SelectSingleNode(&quot;description&quot;,nsm).InnerText;
<br> c.Link = n.SelectSingleNode(&quot;link&quot;,nsm).InnerText;
<br> c.PostGuid = n.SelectSingleNode(&quot;guid&quot;,nsm).InnerText;
<br> c.PubDate = DateTime.Parse(n.SelectSingleNode(&quot;pubDate&quot;,nsm).InnerText);
<br> c.Title = n.SelectSingleNode(&quot;title&quot;,nsm).InnerText;
<br> comments.Add(c);
<br> }
<br>
<br> return comments;
<br> }


Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):