开发者

client server communication using xml

I need to do xml based client server interaction.

As per my knowledge, steps in client server communication through xml may include:

1. client prepares the xml
2. transmittal of the xml
3. server processes the xml

client can send request to the server through 开发者_开发问答xml document. The XML parser at the server will parse the xml file and pass the information to the server.

If so, What will be the output of xml parser to the server?

How to use the xml parser at the server for this purpose?

What will be the response format from server to client( whether can it send response in xml format) to client?

If i am wrong what is the best way to do client server communication through use of xml?

Thank you,


XML is just a container format to pass the data in to the server.

So for instance if you want to pass the username and password of a user to the server you'd sent something like this:

 <credentials>
      <username>john</username>
      <password>password</password>
 </credentials>

The server would receive this and parse it. It would, (perhaps) create a credentials object out of it like this:

 class Credentials
 {
      String username;
      String password;
 };

fill out the values it got from parsing the XML and send it to the business layer.

The businesslayer checks with the database (or any other datastore) to check if the credentials are correct.

It will then inform if it was ok. The server will then send back (probably in XML as well) the result of the logon:

 <result>
      <errorcode>10</errorcode>
      <errortext>The username and password do not match</errortext>
 </result>

And the client will parse the XML and present the user with the result.

Does this explain your question?


XML is a way of describing data, it would probably be better looking at a technology that uses XML to transfer data, for instance WebServices in asp.net use SOAP based XML messages. You should look at these kinds of mechanisms in the technology you work in.

If you are expecting to receive an XML file in a specific format, you need to look at the means of delivery, again this could be WebService based or file transfer?


It depends on the language and function-set that you are using.

The output of the xml parser could be somethings like PHP Arrays.

and usualy the praser function works like:

$output=parse_function($xml_input_string)

yes, the connection could be bidirectional (client can have an instance of parser too)


Use XML serialization and de-serialization on client and server side rather than doing it yourself. Create and object on client (better yet in a common class that can be used both on server and client), populate the object with data and serialize it on client, send it over to server , de-serialize it to object again and use it. You can do the same with the result that the server had to pass back to the client. There are XML libraries in all languages that will help you do that. For client server plumbing you can use numerous frameworks out there. WCF is one on .NET.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜