XML -> method call

G

Guest

Q: Does functionality exist within the .NET CF 2 to invoke a method where the
call is specified in XML? I mean where the XML is automatically translated to
the method call. Where is it and how do I use it?

Suppose I have the following class:

public class Adder
{
public bool Add(int a, int b, out int result)
{
result = a + b;
return true;
}
}

Now I would like to invoke the method from XML that looks like this:

<Adder>
<Add>
<a>10</a>
<b>20</b>
</Add>
</Adder>

....and when it's done the XML will change to this:

<Adder>
<Add returnValue="true">
<a>10</a>
<b>20</b>
<result>30</result>
</Add>
</Adder>

So, can I write a few lines of code, supplying XML and XSD and then the
function is called? I assume this is done behind the scenes in SOAP and
remoting somehow, right?

Thanks!

- Kristoffer -
 
K

Kevin Spencer

Hi Kristoffer,

First, your question is a little confusing. You started out talking about
XML, which is a generic markup language, and can be used for a wide variety
of purposes. You posted some "plain vanilla" XML code. Then you mentioned
XSD, which is an XML schema-definition markup standard, and SOAP, which is
used to process remote method calls via SOAP XML and HTTP. Methods are not
serialized as XML in SOAP, but are called remotely by passing method
information and parameter information in a SOAP request to an XML Web
Service, which executes the method locally and returns the result of the
method call via SOAP XML.

So, what exactly are you asking? And what is the context/requirements of
your problem?

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

What You Seek Is What You Get
 
G

Guest

I'll try to be less confusing...

What I'm looking for is a way to "post method calls" to e.g. a socket that
would unfold the request into a real call to a real method on an object on
the server. If XML is used to request methods to be called, then it's not
necessary to have .NET on the client side and it would be easy to debug,
since XML is humanly readable.

I know I can invoke method calls dynamically through the functionality in
the System.Runtime.Reflection namespace. But then I would have to write code
for it. Not much, but still... so I thought that maybe .NET already has a way
to unwrap XML that is formatted in a certain standardized way into a function
call. The vanilla XML was just to give you an idea of what I'm looking for,
i.e. I supply the name of the method and the params and .NET will call it for
me.

I also want it to be possible to have a non .NET client post XML method
calls to the .NET server and have the result posted back to it. Remoting
looks very nice, but I don't know what I would do if the client was non .NET.
So sending XML to a socket sounded simple to me.

Perhaps I'm asking the wrong thing and maybe there's a complete solution out
there that does exactly what I want. If so, please forgive my ignorance and
point me in the right direction.

And it should work on .NET CF 2.

- Kristoffer -
 
K

Kevin Spencer

Hi Kristoffer,
What I'm looking for is a way to "post method calls" to e.g. a socket that
would unfold the request into a real call to a real method on an object on
the server. If XML is used to request methods to be called, then it's not
necessary to have .NET on the client side and it would be easy to debug,
since XML is humanly readable.

SOAP is a WWW standard (for example, see
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/ and
http://www.w3.org/2000/xp/Group/2/06/LC/soap12-part0.html), not a Microsoft
standard. It is sent as an XML document via an HTTP request and response,
again, not Microsoft technology. There is no need for any Microsoft software
on the client to make a SOAP request and get back a SOAP response.

The .Net Platform classes and tools for working with SOAP are just that:
tools. They are not necessary to write a SOAP client. Just read the WWW
documentation, follow the links, and you can go from there.

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

What You Seek Is What You Get
 
S

ssamuel

Kristoffer,

If you like sockets, you can write a service that listens on one then,
responds to an XML request. You'll probably want to do this over HTTP.
There are several framework methods for this in System.Net and
System.Web. This needs not involve SOAP or XSD unless you want it to.
I've seen an implementation just like this. It works, but it hardly
leverages the power of current standards.

If you're willing to use SOAP, you can create a Web Service that'll
take care of serializing and deserializing your objects without
additional work on your part. You can build a SOAP client in any
language, although you should always do thorough integration testing
across environments because not everyone is always fully standards
compliant.

I'd avoid binary remoting. It's convenient and fast, but that's
starting to run into platform-dependent code. It's possible to get Java
or any other language to interoperate with .NET, but that is an
exercise better left to people with existing applications or too much
time on their hands.

Anything you write in the 1.1 framework should work on the 2.0
framework without modification.

How are you writing your clients? What do they do? Are they web-based
in another tier, or GUI apps, or thin clients, or what?


Stephan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top