Solved

Mapping xml messages to c# Functions

Posted on 2007-03-29
1
248 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

16 Experts available now in Live!

Get 1:1 Help Now