< web  portfolio >

Brenda C. Mondragon

< Main Page >


ASP.NET :: XML-RPC


Using XML-RPC in ASP.NET to call a method on a remote server.


This component used the XML-RPC.NET library (http://xml-rpc.net/) to call a method on a remote server which creates an account on that server. There was also the option of using a separate HTTP Handler component which displayed a progress bar as it waited for a response from the remote server.


This sample of the code shows the part which instantiates and runs the remote procedure call:


Account proxyAccount = new Account();
proxyAccount.Timeout = intProxyTimeout;
IAsyncResult asr;
asr = proxyAccount.BeginCreate(firstname, lastname, email, salesrep, pubkey, authentication, null, null);
while (asr.IsCompleted == false)
{
  System.Threading.Thread.Sleep(intSleepTime);
  if (useProgressBar)
  {
    int intProgress = (int)HttpContext.Current.Application["progress_" + strSess];
    if (intProgress < (ProgressBarEnd-dblProgressBarStepBy))
    {
      HttpContext.Current.Application["progress_" + strSess] = (int)Math.Round((double)(intProgress + dblProgressBarStepBy));
    }
  }
}
strResponse = proxyAccount.EndCreate(asr);
...


The Account class:


[XmlRpcUrl("http://remote.server.com/ws/createaccount.php")]
public class Account : XmlRpcClientProtocol
{
  [XmlRpcMethod("remote.account.create")]
  public String Create(string firstname, string lastname, string email, string salesrep, string pubkey, string authentication)
  {
    return (String)Invoke("Create", new object[] {firstname, lastname, email, salesrep, pubkey, authentication});
  }

  public IAsyncResult BeginCreate(string firstname, string lastname, string email, string salesrep, string pubkey, string authentication, AsyncCallback callback, object asyncState)
  {
    return BeginInvoke("Create", new object[] {firstname, lastname, email, salesrep, pubkey, authentication}, callback, asyncState);
  }

  public String EndCreate(IAsyncResult asr)
  {
    return (String)EndInvoke(asr);
  }

}//end of class Account

Categories:



< Main Page >

This portfolio powered by Blosxom

All content Copyright © 1995 - 2024 Brenda C. Mondragon