简体   繁体   中英

non standard XML-RPC C#

Hello Programmers,

I have to communicate with an API based on RPC calls with the following XML structure:

0x02<root>
   <dispatch>
      <module>MPAPI_RoomInformation</module>
      <function>getRoomData</function>
      <port>0</port>
      <cache_time>15</cache_time>
      <message_id>190</message_id>
   </dispatch>
   <payload status="OK">
      <root>
         <room>150</room>
      </root>
   </payload>
</root>0x03

It doesn't looks like this is following any XML-RPC specifications/standards, so my question is can a library such as http://www.xml-rpc.net/ or https://grpc.io/ be used to communicate with this API? if not do you have any suggestion?

If no libraries are available for this, my understanding is that RPC is basically HTTP requests with, in this case, the body being this custom XML, is that right?

Thanks

my understanding is that RPC is basically HTTP requests with, in this case, the body being this custom XML, is that right?

RPC can be done in many different ways; it can be via HTTP bodies, but that isn't necessarily the case; in your case (looking at the specification), this is a raw socket API that uses start/end sentinels for "framing" (separating different messages), so: you need to get familiar with one of:

  • the raw Socket API
  • the NetworkStream API
  • the "pipelines" API

The last is in many ways the simplest (because it takes care of all the buffer details, including retaining a back-buffer of incomplete data), but it isn't very well documented yet.This 3-and-a-bit series might help, or you might prefer to use the older APIs and deal with those details yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM