DynamicXmlBuilder class

Developing a Web Service

The DynamicXmlBuilder can be used to generate a web service method that returns an XmlNode. The XmlNode definition is derived from the metadata set up in the DynamicXmlBuilder.

To do this, you will need to create an ASP.NET web service and add a "reference" to the xWeb.dll.

The C# code for a web method could take this form:

[WebMethod(CacheDuration = 0, EnableSession = false, BufferResponse = true, MessageName = "ChaperMembers")]
public System.Xml.XmlNode ChaperMembers(string chapterid, DateTime AsOfDate)
{
/// Instantiate object
Avectra.netForum.xWeb.DynamicXmlBuilder oXml = new Avectra.netForum.xWeb.DynamicXmlBuilder();
 
System.Xml.XmlNode oNode = null;
 
/// set incoming parameters
oXml.Parameters.Add("chapterid", chapterid);
oXml.Parameters.Add("mbr_expire_date", AsOfDate);
 
/// Set IP of calling program for authentication
oXml.ServerIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
 
/// optional - if you want to cache results for response
/// for a distinct set of parameters, you may set this property
/// for the internal number of minutes you want to cache results
oXml.iMinutesToCache = 60;
 
try
{
/// Execute the XmlBuilder to return the XML into "oNode"
oNode = oXml.BuildDynamicXmlNode(this.ToString(), "ChaperMembers");
}
catch(Exception ex)
{
throw new SoapException(ex.Message, SoapException.DetailElementName, ex);
}
 
return oNode;
}
   

To understand more about caching DynamicXmlBuilder results in a web service, as shown in the line above, see DynamicXmlBuilder Cache.

See Also

  • The 2007.01 build of netFORUM will contain a new ExecuteMethod web method that implements this feature directly in xWeb.