Solved

Mapping xml messages to c# Functions

Posted on 2007-03-29
1
251 Views
Last Modified: 2013-11-07
Hi All,

I need an approach on calling function that request comes to me with xml message. Ok here is the fully story.

I have an client.aspx in my site and makes xmlhttp calls to serv.aspx. This client.aspx page pass the info about which function it call. Like..

<?xml....?>
<root>
    <msg label="getSubCategories">
         <param lable="categoryId">13</param>
    </msg>
</root>

And I got it in serv aspx and parse it to an object that holds the information of call message.

And now I need a approached that how to invoke requested method.

First thing that comes to my mind is like this.

/*************************************/
switch(msg.label)
{
   case "getSubCategories":
      myapi.getSubCategories(int.parse(msg.parameters[0]))
      break;
   case "getCountries":
      myapi.getCountries()
      break;
   .
   .
   .
}
/*************************************/

This maybe very easy to implement but the list may be to long and every change to api needs change of the inner part of the switch

So I ask what can be done for the issue. Is the above is suitable, or regular web xml service use a best way. Or what can be else?

thanks as now.

note: I use my own api for xml calls and easily made change on message body, and use c# (asp.net 2.0 on w2003 IIS 6.0), by the way I do not want to implement standard soap message rules and set web service project that comes with .net it sells. You can be ask why beacause the job I decide t&#305;o to is more like an remote call system, because I want it to specially to my system..:)



0
Comment
Question by:karanba
1 Comment
 
LVL 3

Accepted Solution

by:
Nico earned 500 total points
ID: 18814729
You can use Reflection for this I suppose. I think the following CodeProject article can be helpful to you: http://www.codeproject.com/csharp/runtime_method_invoke.asp


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now