· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
Docbook Sgml/XML-RPC-HOWTO

You are not allowed to 'fullsearch'


XML-RPC HOWTO

XML-RPC HOWTO

¿ø¿µ½Ä

0.8.0, 2001-04-12

ÀÌ ¹®¼­´Â ´Ù¾çÇÑ ÄÄÇ»Å;ð¾î·Î XML-RPC Ŭ¶óÀ̾ðÆ®¿Í ¼­¹ö¸¦ ¸¸µå´Â ¹æ¹ýÀ» ¼³¸íÇÑ´Ù. Perl, Python, C, C++, Java, PHP µîÀÇ °¢Á¾ ¾ð¾î·Î µÈ ¿¹Á¦ Äڵ带 Á¦°øÇϸç, XML-RPC¸¦ Áö¿øÇÏ´Â ¸ðµç ¿ÀÆÛ·¹ÀÌÆà ½Ã½ºÅÛÀÇ Zope¿Í KDE 2.0 ¼½¼Çµµ Æ÷ÇÔÇÑ´Ù.

고친 과정
고침 0.8.02001-04-12
°øÅë ÀÎÅÍÆäÀ̽º Àå ¼öÁ¤. XML-RPC.Net Á¤º¸ Ãß°¡.
고침 0.7.02001-04-03
C++ proxy classes Àå Ãß°¡.
고침 0.6.02001-02-02
Ruby, K, °øÅë ÀÎÅÍÆäÀ̽º Àå Ãß°¡.
고침 0.5.02001-01-23
ÃÖÃÊ ¹öÁ¯

1. ¹ý·üÀû °øÁö(Legal Notice)

¿ªÀÚÁÖ: ¶óÀ̼¾½º´Â ¿ø¹®À» ±×´ë·Î ½Æ½À´Ï´Ù.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. You may obtain a copy of the GNU Free Documentation License from the Free Software Foundation by visiting their Web site or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

This manual contains short example programs ("the Software"). Permission is hereby granted, free of charge, to any person obtaining a copy of the Software, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following condition:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


2. XML-RPC¶õ ¹«¾ùÀΰ¡?

XML-RPC´Â HTTP¸¦ ÅëÇÑ °£´ÜÇÏ°í À̽ļº ³ôÀº ¿ø°Ý ÇÁ·Î½ÃÁ® È£Ãâ ¹æ¹ýÀÌ´Ù. XML-RPC´Â Perl, Java, Python, C, C++, PHP ¿Í ±× ¿Ü ´Ù¸¥ ¸¹Àº ¾ð¾î·Î »ç¿ëÇÒ ¼ö ÀÖÀ¸¸ç Unix, Windows, ±×¸®°í Macintosh¿¡¼­ ½ÇÇàÇÒ ¼ö ÀÖ´Ù.

´ÙÀ½Àº Perl·Î ¸¸µç °£´ÜÇÑ XML-RPC Ŭ¶óÀ̾ðÆ® ÇÁ·Î±×·¥ÀÌ´Ù. (Ken MacLeodÀÇ Frontier::Client ¸ðµâ »ç¿ë)

use Frontier::Client;
$server = Frontier::Client->new(url => 'http://betty.userland.com/RPC2');
$name = $server->call('examples.getStateName', 41);
print "$name\n";

ÀÌ ÇÁ·Î±×·¥À» ½ÇÇàÇϸé, ¿ø°Ý ¼­¹ö¿¡ ¿¬°áÇÏ¿© ¹Ì±¹ÀÇ ÁÖ¸í(state name)À» ¾ò¾î Ãâ·ÂÇÑ´Ù. (ÀÌ ¿¹Á¦¿¡¼­ 41¹ø ÁÖ´Â South Dakota ÀÏ °ÍÀÌ´Ù.)

´ÙÀ½Àº µ¿ÀÏÇÑ Python ÇÁ·Î±×·¥ÀÌ´Ù. (Fredrik LundhÀÇ xmlrpclib »ç¿ë)

python> import xmlrpclib
python> server = xmlrpclib.Server("http://betty.userland.com/RPC2")
python> server.examples.getStateName(41)
'South Dakota'

ÀÌÁ¦ºÎÅÍ ´Ù¾çÇÑ ÇÁ·Î±×·¡¹Ö ¾ð¾î·Î ¾î¶»°Ô XML-RPC Ŭ¶óÀ̾ðÆ®¿Í ¼­¹ö¸¦ ¸¸µå´ÂÁö¿¡ ´ëÇÏ¿© »ìÆ캼 °ÍÀÌ´Ù.


2.1. ¾î¶»°Ô µ¿ÀÛÇϴ°¡

XML-RPC´Â Dave WinerÀÇ °ø½Ä ¸í¼¼¼­¿¡ »ó¼¼È÷ Á¤ÀǵǾî ÀÖ´Ù. ±Ã±ÝÇÑ »çÇ×ÀÌ ÀÖ´Ù¸é Á÷Á¢ °¡¼­ º¸¶ó. °£´ÜÇÏ°í Àб⠽±°Ô µÇ¾î ÀÖ´Ù.

(¼­¹ö¿Í Ŭ¶óÀ̾ðÆ® °£ÀÇ) Åë½Å »ó¿¡¼­, XML-RPC °ªÀº XML ÄÚµåÈ­µÈ´Ù.:

<methodCall>
  <methodName>sample.sumAndDifference</methodName>
  <params>
    <param><value><int>5</int></value></param>
    <param><value><int>3</int></value></param>
  </params>
</methodCall>

ÀÌ°ÍÀº ÀåȲÇØ º¸ÀÌÁö¸¸ ½±°Ô ¿ä¾àµÈ´Ù. °Ô´Ù°¡ »ý°¢º¸´Ù ºü¸£´Ù. Rick BlairÀÇ ÃøÁ¤¿¡ µû¸£¸é, Hannes WallnoferÀÇ Java ȯ°æ¿¡¼­ ÇÑ ¹øÀÇ XML-RPC È£Ãâ ¿Õº¹¿¡ 0.003ÃÊ°¡ °É·È´Ù.


2.2. Áö¿øµÇ´Â µ¥ÀÌŸÇü

XML-RPC´Â ´ÙÀ½°ú °°Àº µ¥ÀÌŸÇüÀ» Áö¿øÇÑ´Ù:

int

ºÎÈ£ ÀÖ´Â 32ºñÆ® Á¤¼öÇü

string

NULL ¹ÙÀÌÆ®¸¦ Æ÷ÇÔÇÒ ¼ö ÀÖ´Â ¾Æ½ºÅ° ¹®ÀÚ¿­ (XMLÀÇ Æ¯¼º¿¡ ÀÇÇØ ¸î¸îÀÇ XML-RPC ȯ°æ¿¡¼­´Â À¯´ÏÄڵ带 Áö¿øÇÔ)

boolean

Âü ¶Ç´Â °ÅÁþ

double

¹èÁ¤µµ ½Ç¼öÇü (ȯ°æ¿¡ µû¶ó Á¦ÇÑ)

dateTime.iso8601

³¯Â¥¿Í ½Ã°¢. XML-RPC´Â ŸÀÓÁ¸ÀÇ »ç¿ëÀ» ±ÝÇϱ⠶§¹®¿¡ °ÅÀÇ ¾µ¸ð ¾øÀ½

base64

ÀÓÀÇÀÇ ±æÀ̸¦ °¡Áö´Â Àú¼öÁØ ÀÌÁø µ¥ÀÌŸ. Åë½Å »ó¿¡¼­´Â Base64·Î ÀÎÄÚµùµÇ¸ç »ó´çÈ÷ À¯¿ëÇÑ µ¥ÀÌŸÇü (¾î¶² ȯ°æ¿¡¼­´Â 0 ¹ÙÀÌÆ®ÀÇ µ¥ÀÌŸ´Â ¼ö½ÅÇÏÁö ¸øÇÏ´Â °æ¿ìµµ ÀÖÀ½)

array

1Â÷¿ø ¹è¿­. ¹è¿­°ªÀº ¾î¶°ÇÑ Çüµµ °¡´ÉÇÔ

struct

key-valueÀÇ ½ÖÀ¸·Î ÀÌ·ç¾îÁø »çÀüÇü. key´Â stringÀ̾î¾ß Çϸç value´Â ¾î¶°ÇÑ Çüµµ °¡´ÉÇÔ


2.3. XML-RPCÀÇ ¿ª»ç

XML-RPC´Â ±× ÀÌÀüÀÇ µÎ ÇÁ·ÎÅäÄݷκÎÅÍ ¿µÇâÀ» ¹Þ¾Ò´Ù. ù°´Â Dave Winer¿¡ ÀÇÇØ µðÀÚÀÎµÇ°í ¿¹Àü¿¡ DaveNet¿¡ ¹ßÇ¥µÈ À͸í RPC ÇÁ·ÎÅäÄÝÀÌ´Ù. (ÀÌ ¶§¹®¿¡ Á¾Á¾ XML-RPC ¼­¹ö´Â /RPC2¿¡ ¼³Ä¡µÈ´Ù.) ¶ÇÇϳª, ´õ¿í ÁÖ¿äÇÏ°Ô´Â SOAP ÇÁ·ÎÅäÄÝÀÇ Ãʾȿ¡¼­ ±× ¿µÇâÀ» ¹Þ¾Ò´Ù.

XML-RPCÀÇ ¿ª»ç¿¡ °üÇÑ ´õ ÀÚ¼¼ÇÑ ¹®¼­·Î´Â Dave Winer°¡ ¾´ ±ÛÀÌ ÀÖ´Ù. ÀÌ ¹®¼­´Â XML-RPC¿Í SOAPÀÇ °ü°è¿¡ ´ëÇؼ­µµ ¼³¸íÇÏ°í ÀÖ´Ù.


3. XML-RPC°ú ´Ù¸¥ ÇÁ·ÎÅäÄÝ

¿ø°Ý ÇÁ·Î½ÃÁ®¸¦ È£ÃâÇÏ´Â ¹æ¹ý¿¡ XML-RPC°¡ À¯ÀÏÇÑ °ÍÀº ¾Æ´Ï´Ù. CORBA, DCOM ±×¸®°í SOAP µîÀÇ ´Ù¸¥ À¯¸íÇÑ ÇÁ·ÎÅäÄݵµ ÀÖ´Ù. À̵é ÇÁ·ÎÅäÄÝÀº Á¦°¢°¢ Àå´ÜÁ¡À» °¡Áö°í ÀÖ´Ù.

ÀÌ ÀåÀÇ ÀÇ°ßÀº ¼øÀüÈ÷ °³ÀÎÀûÀÎ »ý°¢ÀÏ »ÓÀÌ´Ù. ±×³É Âü°í»ï¾Æ ÀоîÁֱ⠹ٶõ´Ù.


3.1. XML-RPC ´ë CORBA

CORBA´Â ºÐ»ê, °´Ã¼ÁöÇâ ¾ÖÇø®ÄÉÀ̼ÇÀÇ ÀÛ¼º¿¡ ¸¹ÀÌ »ç¿ëµÇ´Â ÇÁ·ÎÅäÄÝÀÌ´Ù. CORBA´Â ´ëü·Î ¸ÖƼ-tier ¿£ÅÍÇÁ¶óÀÌÁî ¾ÖÇø®ÄÉÀ̼ǿ¡ ¸¹ÀÌ »ç¿ëµÇ¾îÁ® ¿ÔÀ¸¸ç, ÃÖ±Ù¿¡´Â Gnome ÇÁ·ÎÁ§Æ®¿¡¼­ ¾ÖÇø®ÄÉÀÌ¼Ç °£ÀÇ ³»ºÎÀû Åë½ÅÀ» À§ÇØ »ç¿ëµÇ°í ÀÖ´Ù.

CORBA´Â ¸¹Àº ¾÷ü¿Í ÀÚÀ¯ ¼ÒÇÁÆ®¿þ¾î ÇÁ·ÎÁ§Æ®¿¡ ÀÇÇØ Áö¿øµÇ°í ÀÖ´Ù. CORBA´Â Java, C++ ±×¸®°í ´Ù¸¥ ¿©·¯ ¾ð¾î¿¡¼­ Àß ½ÇÇàµÈ´Ù. ¶ÇÇÑ CORBA´Â »ç¿ëÀÚ·Î ÇÏ¿©±Ý ½±°í °´Ã¼ÁöÇâÀûÀÎ API¸¦ Á¤ÀÇÇÒ ¼ö ÀÖµµ·Ï, ÈǸ¢ÇÑ ÀÎÅÍÆäÀ̽º Á¤ÀÇ ¾ð¾î(interface definition language: IDL)¸¦ Áö¿øÇÑ´Ù.

ÇÏÁö¸¸ CORBA´Â ¾ÆÁÖ º¹ÀâÇÏ´Ù. ¹è¿ì´Â µ¥ ¸¹Àº ½Ã°£ÀÌ µé°í, Àû¿ëÇÏ´Â µ¥¿¡µµ »ó´çÇÑ ³ë·ÂÀÌ ÇÊ¿äÇϸç, Ŭ¶óÀ̾ðÆ® ±¸ÇöÀÌ ²Ï³ª ¾î·Æ´Ù. ±×·¡¼­ CORBA´Â À¥ ¾ÖÇø®ÄÉÀ̼Ǻ¸´Ù´Â ¿£ÅÍÇÁ¶óÀÌÁî ¶Ç´Â µ¥½ºÅ©Å¾ ¾ÖÇø®ÄÉÀ̼ǿ¡ ´õ ÀûÇÕÇÏ´Ù.


3.2. XML-RPC ´ë DCOM

DCOM Àº CORBA¿¡ ´ëÀÀÇÏ´Â MicrosoftÀÇ ÇÁ·ÎÅäÄÝÀÌ´Ù. DCOMÀº »ç¿ëÀÚ°¡ ÀÌ¹Ì COM ÄÄÆ÷³ÍÆ®¸¦ »ç¿ëÇÏ°í ÀÖ°í, Microsoft ¿ÜÀÇ ´Ù¸¥ ½Ã½ºÅÛÀ» °í·ÁÇÏÁö ¾Ê´Â´Ù¸é ¾ÆÁÖ ÈǸ¢ÇÏ´Ù. ±×·¸Áö ¾Ê´Ù¸é ±×´ÙÁö ¾µ¸ð ¾ø´Ù.


3.3. XML-RPC ´ë SOAP

SOAP´Â XML-RPC¿Í ¸Å¿ì À¯»çÇÏ´Ù. SOAP ¿ª½Ã HTTP¿Í XML ¹®¼­¸¦ ÅëÇÑ ÀÏ·ÃÈ­ ÇÁ·Î½ÃÁ® È£ÃâÀ» »ç¿ëÇÑ´Ù. ÇÏÁö¸¸ SOAP´Â ÃÖÃÊÀÇ Ç¥ÁØ ¸í¼¼¿¡¼­ ¼­·Î ´Þ¸® È®ÀåÇØ °¡´Â °ÍÀ» ¸·À» ±æÀÌ ¾ø¾î º¸ÀδÙ.

SOAP´Â ¿ø·¡ UserLand¿Í DevelopMentor, MicrosoftÀÇ Çù·Â¿¡ ÀÇÇØ ¸¸µé¾îÁ³´Ù. ÃÖÃÊÀÇ °ø°³ ¸±¸®Áî´Â XML-RPC¸¦ ±âº»À¸·Î ÇÏ°í ³×ÀÓ½ºÆäÀ̽º¿Í ±ä ¿¤¸®¸ÕÆ® À̸§À» »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇÏ¿´´Ù. ±×·¯³ª ±× ÀÌÈÄ¿¡ SOAP´Â W3C working groupÀ¸·Î ³Ñ°ÜÁ³´Ù.

±×·±µ¥ W3C working groupÀº SOAP¿¡ ¿©·¯ Àâ´ÙÇÑ °ÍÀ» Ãß°¡½ÃÄÑ ¹ö·È´Ù. ÀÌ ±ÛÀ» ¾²°í ÀÖ´Â ÇöÀç SOAP´Â XML Schemas, enumerations, struct¿Í arrayÀÇ È¥ÇÕ, ±×¸®°í »ç¿ëÀÚ Á¤ÀÇ µ¥ÀÌŸÇü µîÀ» Áö¿øÇÑ´Ù. ±×¿Í µ¿½Ã¿¡ Ç÷§Æû¿¡ µû¶ó ¸î°¡Áö ÇüÅÂÀÇ SOAP°¡ ³ªÅ¸³µ´Ù.

XML-RPC°ú À¯»çÇÏÁö¸¸ ´õ ¸¹Àº ±â´ÉÀ» Áö¿øÇÏ´Â ÇÁ·ÎÅäÄÝÀ» ã´Â´Ù¸é SOAP¸¦ »ìÆ캸¶ó. :-)


4. XML-RPCÀÇ °øÅë ÀÎÅÍÆäÀ̽º

¸î¸îÀÇ XML-RPC ¼­¹ö´Â ³»Àå ¸Þ½îµå¸¦ Á¦°øÇÏ°í ÀÖ´Ù. ±×°ÍÀº XML-RPC ÀÚüÀÇ ºÎºÐÀº ¾Æ´Ï°í Á÷Á¢ ¸¸µé¾î Ãß°¡ÇÑ °ÍÀÌ´Ù.


4.1. Introspection: ¼­¹ö API ã±â

Edd Dumbill´Â ´ÙÀ½°ú °°Àº ¸Þ½îµå¸¦ Á¦¾ÈÇß´Ù.:

array system.listMethods ()
string system.methodHelp (string methodName)
array system.methodSignature (string methodName)

¸¸¾à ¼­¹ö°¡ À§ÀÇ ¸Þ½îµå¸¦ Áö¿øÇÑ´Ù¸é »ç¿ëÀÚ´Â ±×°ÍÀ» ÁúÀÇÇÏ°í °á°ú¸¦ Ãâ·ÂÇÒ ¼ö ÀÖ´Ù.

import xmlrpclib
server = xmlrpclib.Server("http://xmlrpc-c.sourceforge.net/api/sample.php")
for method in server.system.listMethods():
    print method
    print server.system.methodHelp(method)
    print

À§ÀÇ ¸Þ½îµåµéÀº ÇöÀç ¼­¹ö»ó(http://xmlrpc-c.sourceforge.net)¿¡¼­ PHP, C ±×¸®°í Microsoft .NETÀÇ ÇüÅ·ΠÁ¦°øµÇ°í ÀÖ´Ù. ÃÖ±Ù¿¡ UserLand Frontier°¡ ºÎºÐÀûÀ¸·Î introspectionÀ» Áö¿øÇϵµ·Ï ¾÷µ¥ÀÌÆ® µÇ¾ú´Ù. Perl, Python°ú JavaÀÇ Introspection Áö¿ø¿¡ ´ëÇؼ­´Â XML-RPC Hacks ÆäÀÌÁö¸¦ Âü°íÇ϶ó. ´Ù¸¥ XML-RPC ¼­¹ö¿¡¼­µµ ¸¶À½´ë·Î introspectionÀ» Áö¿øÇصµ ÁÁ´Ù(±ÇÀåÇÑ´Ù)!

´Ù¾çÇÑ Å¬¶óÀ̾ðÆ® Åø(¹®¼­ »ý¼º±â, ·¡ÆÛ »ý¼º±â µîµî)µµ XML-RPC Hacks ÆäÀÌÁö¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.


4.2. Boxcarring: ´Ù¼öÀÇ ÁúÀǸ¦ µ¿½Ã¿¡ º¸³»±â

¸¸¾à ÀÛÀº ÇÔ¼ö¸¦ È£ÃâÇÏ´Â ·çƾÀ» ¸¹ÀÌ °¡Áö´Â XML-RPC Ŭ¶óÀ̾ðÆ®¸¦ ¸¸µç´Ù¸é, ÀÎÅÍ³Ý backbone latency¸¦ ÀÌ¿ëÇÏ¿© ÁúÀÇ/ÀÀ´äÀÇ ¿Õº¹ ½Ã°£À» ÁÙÀÌ´Â ¹æ¹ýÀ» ãÀ» ¼ö ÀÖ´Ù. ¸î¸îÀÇ ¼­¹ö´Â ´ÙÀ½ÀÇ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ´Ù¼öÀÇ ÁúÀǸ¦ Çϳª·Î ¹­¾î º¸³¾ ¼ö ÀÖµµ·Ï ÇÑ´Ù:

array system.multicall (array calls)

»ó¼¼ÇÑ Á¤º¸´Â system.multicall RFC¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

ÀÌ ¸Þ½îµå´Â ÇöÀç C¿Í UserLand Frontier·Î ÀÛ¼ºµÈ ¼­¹öµéÀÌ Áö¿øÇÏ°í ÀÖ´Ù. Python°ú Perl·Î ÀÛ¼ºµÈ ¼­¹ö´Â XML-RPC Hacks ÆäÀÌÁö¿¡ ÀÖ´Â Äڵ带 »ç¿ëÇÒ ¼ö ÀÖ´Ù.


5. »ùÇÃ API: sumAndDifference

XML-RPC¸¦ ¼³¸íÇϱâ À§ÇØ °¡´ÉÇÑ ÇÑ ¸¹Àº ¾ð¾î·Î ´ÙÀ½ÀÇ API¸¦ ±¸ÇöÇØ º¸¾Ò´Ù.

struct sample.sumAndDifference (int x, int y)

ÀÌ ÇÔ¼ö´Â Àμö·Î µÎ Á¤¼ö¸¦ ¹Þ¾Æ¼­ µÎ ¿ø¼Ò¸¦ °¡Áö´Â XML-RPC <struct>¸¦ µ¹·ÁÁØ´Ù:

sum

µÎ Á¤¼öÀÇ ÇÕ

difference

µÎ Á¤¼öÀÇ Â÷

º°·Î À¯¿ëÇÏÁø ¾ÊÀ¸³ª, ±¦ÂúÀº ¿¹Á¦¶ó ÇÒ ¼ö ÀÖ´Ù. :-)

ÀÌ ÇÔ¼ö(±×¸®°í ´Ù¸¥ ÇÔ¼öµéµµ)´Â http://xmlrpc-c.sourceforge.net/api/sample.php À» ÅëÇØ »ç¿ëÇÒ ¼ö ÀÖ´Ù. (ÀÌ URLÀº À¥ºê¶ó¿ìÀú·Î´Â µ¿ÀÛÇÏÁö ¾Ê´Â´Ù. XML-RPC Ŭ¶óÀ̾ðÆ®°¡ ÇÊ¿äÇÏ´Ù.)


6. Perl·Î XML-RPC »ç¿ëÇϱâ

Ken MacLeod´Â Perl·Î XML-RPC¸¦ ±¸ÇöÇß´Ù. ±×ÀÇ À¥»çÀÌÆ®³ª CPANÀ» ÅëÇØ Frontier::RPC ¸ðµâÀ» ±¸ÇÒ ¼ö ÀÖ´Ù.

Frontier::RPC¸¦ ¼³Ä¡ÇÏ·Á¸é, ÆÐÅ°Áö¸¦ ³»·Á¹Þ°í PerlÀÇ Ç¥ÁØ ¹æ½ÄÀ¸·Î ÄÄÆÄÀÏÇÏ¸é µÈ´Ù:

bash$ gunzip -c Frontier-RPC-0.07b1.tar.gz | tar xvf -
bash$ cd Frontier-RPC-0.07b1
bash$ perl Makefile.PL
bash$ make
bash$ make test
bash$ su -c 'make install'

(ÀÌ °úÁ¤Àº À©µµ¿ìÁ root °èÁ¤ÀÌ ¾Æ´Ñ °æ¿ì¿¡´Â Á¶±Ý ´Ù¸¦ ¼ö ÀÖ´Ù. ÀÚ¼¼ÇÑ °ÍÀº Perl ¹®¼­¸¦ Âü°íÇ϶ó.)


6.1. Perl Ŭ¶óÀ̾ðÆ®

´ÙÀ½ÀÇ ÇÁ·Î±×·¥Àº Perl·Î XML-RPC ¼­¹ö¸¦ È£ÃâÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù:

use Frontier::Client;

# Make an object to represent the XML-RPC server.
$server_url = 'http://xmlrpc-c.sourceforge.net/api/sample.php';
$server = Frontier::Client->new(url => $server_url);

# Call the remote server and get our result.
$result = $server->call('sample.sumAndDifference', 5, 3);
$sum = $result->{'sum'};
$difference = $result->{'difference'};

print "Sum: $sum, Difference: $difference\n";

6.2. µ¶¸³ Perl ¼­¹ö

´ÙÀ½ÀÇ ÇÁ·Î±×·¥Àº Perl·Î XML-RPC ¼­¹ö¸¦ ¸¸µå´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù:

use Frontier::Daemon;

sub sumAndDifference {
    my ($x, $y) = @_;
    return {'sum' => $x + $y, 'difference' => $x - $y};
}

# Call me as http://localhost:8080/RPC2
$methods = {'sample.sumAndDifference' => \&sumAndDifference};
Frontier::Daemon->new(LocalPort => 8080, methods => $methods)
    or die "Couldn't start HTTP server: $!";

6.3. CGI ±â¹ÝÀÇ Perl ¼­¹ö

Frontier::RPC2´Â CGI ±â¹ÝÀÇ ¼­¹ö Áö¿ø ±â´ÉÀ» ³»ÀåÇÏ°í ÀÖÁö´Â ¾Ê´Ù. ÇÏÁö¸¸ ÇÊ¿äÇÑ ´ëºÎºÐ °ÍÀ» ±¸ÇöÇÒ ¼ö ÀÖ´Ù.

´ÙÀ½ÀÇ Äڵ带 À¥¼­¹öÀÇ cgi-bin µð·ºÅ丮¿¡ sumAndDifference.cgi ¶ó´Â À̸§À¸·Î ÀúÀåÇ϶ó. (À¯´Ð½º ½Ã½ºÅÛ¿¡¼­´Â chmod +x sumAndDifference.cgi·Î ½ÇÇà °¡´ÉÇϵµ·Ï ¸¸µé¾î ÁÖ¾î¾ß ÇÑ´Ù.)

#!/usr/bin/perl -w

use strict;
use Frontier::RPC2;

sub sumAndDifference {
    my ($x, $y) = @_;
    return {'sum' => $x + $y, 'difference' => $x - $y};
}

process_cgi_call({'sample.sumAndDifference' => \&sumAndDifference});


#==========================================================================
#  CGI Support
#==========================================================================
#  Simple CGI support for Frontier::RPC2. You can copy this into your CGI
#  scripts verbatim, or you can package it into a library.
#  (Based on xmlrpc_cgi.c by Eric Kidd <http://xmlrpc-c.sourceforge.net/>.)

# Process a CGI call.
sub process_cgi_call ($) {
    my ($methods) = @_;

    # Get our CGI request information.
    my $method = $ENV{'REQUEST_METHOD'};
    my $type = $ENV{'CONTENT_TYPE'};
    my $length = $ENV{'CONTENT_LENGTH'};

    # Perform some sanity checks.
    http_error(405, "Method Not Allowed") unless $method eq "POST";
    http_error(400, "Bad Request") unless $type eq "text/xml";
    http_error(411, "Length Required") unless $length > 0;

    # Fetch our body.
    my $body;
    my $count = read STDIN, $body, $length;
    http_error(400, "Bad Request") unless $count == $length; 

    # Serve our request.
    my $coder = Frontier::RPC2->new;
    send_xml($coder->serve($body, $methods));
}

# Send an HTTP error and exit.
sub http_error ($$) {
    my ($code, $message) = @_;
    print <<"EOD";
Status: $code $message
Content-type: text/html

<title>$code $message</title>
<h1>$code $message</h1>
<p>Unexpected error processing XML-RPC request.</p>
EOD
    exit 0;
}

# Send an XML document (but don't exit).
sub send_xml ($) {
    my ($xml_string) = @_;
    my $length = length($xml_string);
    print <<"EOD";
Status: 200 OK
Content-type: text/xml
Content-length: $length

EOD
    # We want precise control over whitespace here.
    print $xml_string;
}

ÀÌ À¯Æ¿¸®Æ¼ ·çƾÀ» CGI ½ºÅ©¸³Æ®¿¡ Áý¾î³ÖÀ¸¸é µÈ´Ù.


7. PythonÀ¸·Î XML-RPC »ç¿ëÇϱâ

Fredrik Lundh´Â ÈǸ¢ÇÑ XML-RPC library for PythonÀ» Á¦°øÇß´Ù.

¼³Ä¡ÇÏ·Á¸é ÃÖ±Ù ¹öÁ¯À» ³»·Á¹Þ¾Æ¼­ *.py ÆÄÀÏÀ» Python Äڵ尡 ÀÖ´Â µð·ºÅ丮¿¡ µÎ°Å³ª Python µð·ºÅ丮¿¡ ¼³Ä¡ÇÏ¸é µÈ´Ù.

RedHat 6.2 »ç¿ëÀÚ´Â ´ÙÀ½°ú °°ÀÌ ÇÏ¸é µÈ´Ù:

bash$ mkdir xmlrpclib-0.9.8
bash$ cd xmlrpclib-0.9.8
bash$ unzip ../xmlrpc-0.9.8-990621.zip
bash$ python
python> import xmlrpclib
python> import xmlrpcserver
python> Control-D
bash$ su -c 'cp *.py *.pyc /usr/lib/python1.5/'

µÎ *.py ÆÄÀÏÀ» ÄÄÆÄÀÏÇϱâ À§ÇØ importÇÏ´Â ¹æ¹ýÀ» »ç¿ëÇß´Ù. ´Ù¸¥ Ç÷§ÆûÀÇ »ç¿ëÀÚ´Â Python ¹®¼­¸¦ Âü°íÇ϶ó.

´Ù¸¥ ¿¹Á¦¸¦ º¸±â À§Çؼ­´Â O'Reilly NetworkÀÇ XML-RPC: It Works Both Ways ¹®¼­¸¦ º¸¶ó.


7.1. Python Ŭ¶óÀ̾ðÆ®

´ÙÀ½ÀÇ ÇÁ·Î±×·¥Àº PythonÀ¸·Î XML-RPC ¼­¹ö¸¦ È£ÃâÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù:

import xmlrpclib

# Create an object to represent our server.
server_url = 'http://xmlrpc-c.sourceforge.net/api/sample.php';
server = xmlrpclib.Server(server_url);

# Call the server and get our result.
result = server.sample.sumAndDifference(5, 3)
print "Sum:", result['sum']
print "Difference:", result['difference']

8. C/C++·Î XML-RPC »ç¿ëÇϱâ

C/C++À» À§ÇÑ XML-RPC´Â xmlrpc-c À¥»çÀÌÆ® ¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù.

°ü·Ã ÆÄÀϵéÀº RPM ÇüÅ·Π±¸ÇÒ ¼öµµ ÀÖ°í, ¼Ò½º¸¦ ³»·Á¹Þ¾Æ ÄÄÆÄÀÏÇÒ ¼öµµ ÀÖ´Ù.


8.1. C Ŭ¶óÀ̾ðÆ®

´ÙÀ½ÀÇ Äڵ带 getSumAndDifference.cÀÇ À̸§À¸·Î ÀúÀåÇ϶ó:

#include <stdio.h>
#include <xmlrpc.h>
#include <xmlrpc_client.h>

#define NAME       "XML-RPC getSumAndDifference C Client"
#define VERSION    "0.1"
#define SERVER_URL "http://xmlrpc-c.sourceforge.net/api/sample.php"

void die_if_fault_occurred (xmlrpc_env *env)
{
    /* Check our error-handling environment for an XML-RPC fault. */
    if (env->fault_occurred) {
        fprintf(stderr, "XML-RPC Fault: %s (%d)\n",
                env->fault_string, env->fault_code);
        exit(1);
    }
}

int main (int argc, char** argv)
{
    xmlrpc_env env;
    xmlrpc_value *result;
    xmlrpc_int32 sum, difference;
    
    /* Start up our XML-RPC client library. */
    xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION);
    xmlrpc_env_init(&env);

    /* Call our XML-RPC server. */
    result = xmlrpc_client_call(&env, SERVER_URL,
                                "sample.sumAndDifference", "(ii)",
                                (xmlrpc_int32) 5,
                                (xmlrpc_int32) 3);
    die_if_fault_occurred(&env);
    
    /* Parse our result value. */
    xmlrpc_parse_value(&env, result, "{s:i,s:i,*}",
                       "sum", &sum,
                       "difference", &difference);
    die_if_fault_occurred(&env);

    /* Print out our sum and difference. */
    printf("Sum: %d, Difference: %d\n", (int) sum, (int) difference);
    
    /* Dispose of our result value. */
    xmlrpc_DECREF(result);

    /* Shutdown our XML-RPC client library. */
    xmlrpc_env_clean(&env);
    xmlrpc_client_cleanup();

    return 0;
}

ÄÄÆÄÀÏÀº ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

bash$ CLIENT_CFLAGS=`xmlrpc-c-config libwww-client --cflags`
bash$ CLIENT_LIBS=`xmlrpc-c-config libwww-client --libs`
bash$ gcc $CLIENT_CFLAGS -o getSumAndDifference getSumAndDifference.c $CLIENT_LIBS

°¢ÀÚÀÇ ½Ã½ºÅÛ¿¡ ¸Âµµ·Ï À§ÀÇ gcc¸¦ ¹Ù²ãÁÖ¸é µÈ´Ù.


8.2. C++ Ŭ¶óÀ̾ðÆ®

´ÙÀ½ÀÇ Äڵ带 getSumAndDifference2.ccÀÇ À̸§À¸·Î ÀúÀåÇ϶ó:

#include <iostream.h>
#include <XmlRpcCpp.h>

#define NAME       "XML-RPC getSumAndDifference C++ Client"
#define VERSION    "0.1"
#define SERVER_URL "http://xmlrpc-c.sourceforge.net/api/sample.php"

static void get_sum_and_difference () {

    // Build our parameter array.
    XmlRpcValue param_array = XmlRpcValue::makeArray();
    param_array.arrayAppendItem(XmlRpcValue::makeInt(5));
    param_array.arrayAppendItem(XmlRpcValue::makeInt(3));

    // Create an object to resprent the server, and make our call.
    XmlRpcClient server (SERVER_URL);
    XmlRpcValue result = server.call("sample.sumAndDifference", param_array);

    // Extract the sum and difference from our struct.
    XmlRpcValue::int32 sum = result.structGetValue("sum").getInt();
    XmlRpcValue::int32 diff = result.structGetValue("difference").getInt();
        
    cout << "Sum: " << sum << ", Difference: " << diff << endl;
}

int main (int argc, char **argv) {

    // Start up our client library.
    XmlRpcClient::Initialize(NAME, VERSION);

    // Call our client routine, and watch out for faults.
    try {
        get_sum_and_difference();
    } catch (XmlRpcFault& fault) {
        cerr << argv[0] << ": XML-RPC fault #" << fault.getFaultCode()
             << ": " << fault.getFaultString() << endl;
        XmlRpcClient::Terminate();
        exit(1);
    }

    // Shut down our client library.
    XmlRpcClient::Terminate();
    return 0;
}

ÄÄÆÄÀÏÀº ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

bash$ CLIENT_CFLAGS=`xmlrpc-c-config c++ libwww-client --cflags`
bash$ CLIENT_LIBS=`xmlrpc-c-config c++ libwww-client --libs`
bash$ c++ $CLIENT_CFLAGS -o getSumAndDifference2 getSumAndDifference2.cc $CLIENT_LIBS

±¸½Ä C++ ÄÄÆÄÀÏ·¯·Î´Â Á¦´ë·Î ÄÄÆÄÀÏÀÌ µÇÁö ¾ÊÀ» ¼öµµ ÀÖ´Ù.


8.3. Proxy Class¸¦ »ç¿ëÇÏ´Â C++ Ŭ¶óÀ̾ðÆ®

¸¸¾à XML-RPC ¼­¹ö°¡ Introspection API¸¦ Áö¿øÇÑ´Ù¸é ÀÚµ¿À¸·Î C++ proxy class¸¦ ¸¸µé ¼ö ÀÖ´Ù. Proxy class¸¦ ¸¸µé±â À§Çؼ­´Â ´ÙÀ½ÀÇ ¸í·ÉÀ» ÀÔ·ÂÇÏ°í ±× °á°ú¸¦ ÆÄÀÏ·Î ÀúÀåÇ϶ó:

bash$ xml-rpc-api2cpp \
> http://xmlrpc-c.sourceforge.net/api/sample.php sample SampleProxy

À§ÀÇ ¸í·ÉÀº SampleProxy¶ó´Â À̸§ÀÇ proxy class¸¦ ¸¸µç´Ù. SampleProxy´Â sample·Î ½ÃÀÛÇÏ´Â ¸ðµç ¸Þ½îµåÀÇ ·¡ÆÛ(wrapper)¸¦ °¡Áö°í ÀÖ´Ù. ¹°·Ð ¿øÇÑ´Ù¸é ¼öÁ¤ÇÒ ¼ö ÀÖ´Ù.


8.4. CGI ±â¹ÝÀÇ ¼­¹ö

´ÙÀ½ÀÇ Äڵ带 sumAndDifference.cÀÇ À̸§À¸·Î ÀúÀåÇ϶ó:

#include <xmlrpc.h>
#include <xmlrpc_cgi.h>

xmlrpc_value *
sumAndDifference (xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
{
    xmlrpc_int32 x, y;

    /* Parse our argument array. */
    xmlrpc_parse_value(env, param_array, "(ii)", &x, &y);
    if (env->fault_occurred)
        return NULL;

    /* Return our result. */
    return xmlrpc_build_value(env, "{s:i,s:i}",
                              "sum", x + y,
                              "difference", x - y);
}

int main (int argc, char **argv)
{
    /* Set up our CGI library. */
    xmlrpc_cgi_init(XMLRPC_CGI_NO_FLAGS);

    /* Install our only method (with a method signature and a help string). */
    xmlrpc_cgi_add_method_w_doc("sample.sumAndDifference",
                                &sumAndDifference, NULL,
                                "S:ii", "Add and subtract two integers.");

    /* Call the appropriate method. */
    xmlrpc_cgi_process_call();

    /* Clean up our CGI library. */
    xmlrpc_cgi_cleanup();
}

ÄÄÆÄÀÏÀº ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

bash$ CGI_CFLAGS=`xmlrpc-c-config cgi-server --cflags`
bash$ CGI_LIBS=`xmlrpc-c-config cgi-server --libs`
bash$ gcc $CGI_CFLAGS -o sumAndDifference.cgi sumAndDifference.c $CGI_LIBS

ÄÄÆÄÀÏÀÌ µÇ¾úÀ¸¸é sumAndDifference.cgi ÆÄÀÏÀ» À¥¼­¹öÀÇ cgi-bin µð·ºÅ丮¿¡ º¹»çÇÏ¸é µÈ´Ù.


9. Java·Î XML-RPC »ç¿ëÇϱâ

Hannes Wallnöfer´Â ÈǸ¢ÇÑ Java¿ë XML-RPC ¶óÀ̺귯¸®¸¦ Á¦°øÇß´Ù.

¼³Ä¡Çϱâ À§Çؼ­´Â ÆÄÀÏÀ» ¹ÞÀº ÈÄ ¾ÐÃàÀ» Ç®°í *.jar ÆÄÀÏÀ» CLASSPATH¿¡ Ãß°¡ÇØ¾ß ÇÑ´Ù. À¯´Ð½º ½Ã½ºÅÛ¿¡¼­´Â ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

bash$ unzip xmlrpc-java.zip
bash$ cd xmlrpc-java/lib
bash$ CLASSPATH=`pwd`/openxml-1.2.jar:`pwd`/xmlrpc.jar:$CLASSPATH

9.1. Java Ŭ¶óÀ̾ðÆ®

´ÙÀ½ÀÇ ÇÁ·Î±×·¥À» JavaClient.javaÀÇ À̸§À¸·Î ÀúÀåÇ϶ó.

import java.util.Vector;
import java.util.Hashtable;
//import helma.xmlrpc.*;
import org.apache.xmlrpc.*;  // helma.xmlrpc.* -> org.apache.xmlrpc.* ·Î º¯°æ, 2004.1.26, thkim86@ÇϳªÆ÷½º.com

public class JavaClient {

    // The location of our server.
    // ¾Æ·¡ÀÇ ¼­¹öÇÁ·Î±×·¥À» ·ÎÄÃÈ£½ºÆ®¿¡¼­ ±âµ¿ÇÏ´Â °æ¿ì¿¡ Å×½ºÆ®Çϱâ À§Çؼ­ url º¯°æ
    // º¯°æÀÚ : thkim86@ÇϳªÆ÷½º.com, 2004.1.26
    private final static String server_url =
        "http://localhost:8080";
        //"http://xmlrpc-c.sourceforge.net/api/sample.php";


    public static void main (String [] args) {
        try {

            // Create an object to represent our server.
            XmlRpcClient server = new XmlRpcClient(server_url);

            // Build our parameter list.
            Vector params = new Vector();
            params.addElement(new Integer(5));
            params.addElement(new Integer(3));

            // Call the server, and get our result.
            Hashtable result =
                (Hashtable) server.execute("sample.sumAndDifference", params);
            int sum = ((Integer) result.get("sum")).intValue();
            int difference = ((Integer) result.get("difference")).intValue();

            // Print out our result.
            System.out.println("Sum: " + Integer.toString(sum) +
                               ", Difference: " +
                               Integer.toString(difference));

        } catch (XmlRpcException exception) {
            System.err.println("JavaClient: XML-RPC Fault #" +
                               Integer.toString(exception.code) + ": " +
                               exception.toString());
        } catch (Exception exception) {
            System.err.println("JavaClient: " + exception.toString());
        }
    }
}

9.2. µ¶¸³ Java ¼­¹ö

´ÙÀ½ÀÇ ÇÁ·Î±×·¥À» JavaServer.javaÀÇ À̸§À¸·Î ÀúÀåÇ϶ó.

import java.util.Hashtable;
//import helma.xmlrpc.*;
import org.apache.xmlrpc.*;  // helma.xmlrpc.* -> org.apache.xmlrpc.* ·Î º¯°æ, 2004.1.26, thkim86@ÇϳªÆ÷½º.com

public class JavaServer {

    public JavaServer () {
        // Our handler is a regular Java object. It can have a
        // constructor and member variables in the ordinary fashion.
        // Public methods will be exposed to XML-RPC clients.
    }

    public Hashtable sumAndDifference (int x, int y) {
        Hashtable result = new Hashtable();
        result.put("sum", new Integer(x + y));
        result.put("difference", new Integer(x - y));
        return result;
    }

    public static void main (String [] args) {
        try {
            
            // Invoke me as <http://localhost:8080/RPC2>.
            WebServer server = new WebServer(8080);

            // ¿ø·¡ ¼Ò½º¿¡´Â ¾øÁö¸¸ ¹Ýµå½Ã Ãß°¡µÇ¾î¾ß ÇÏ´Â ºÎºÐ
            // º¯°æÀÚ : thkim86@ÇϳªÆ÷½º.com, 2004.1.26
            server.start();

            server.addHandler("sample", new JavaServer());

        } catch (Exception exception) {
            System.err.println("JavaServer: " + exception.toString());
        }
    }
}

10. PHP·Î XML-RPC »ç¿ëÇϱâ

Edd Dumbill´Â PHP¿ë XML-RPC ¸ðµâÀ» ¸¸µé¾ú´Ù. ¸ðµâÀº UsefulInc XML-RPC website¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù.

ÆÄÀÏÀ» ³»·Á¹Þ¾Æ ¾ÐÃàÀ» Ǭ ´ÙÀ½, xmlrpc.inc¿Í xmlrpcs.inc ÀÇ µÎ ÆÄÀÏÀ» PHP ½ºÅ©¸³Æ®¿Í °°Àº µð·ºÅ丮¿¡ º¹»çÇÏ¸é µÈ´Ù.


10.1. PHP Ŭ¶óÀ̾ðÆ®

´ÙÀ½ÀÇ ½ºÅ©¸³Æ®´Â À¥ÆäÀÌÁö¿¡ XML-RPC È£Ãâ ·çƾÀ» Ãß°¡ÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.

<html>
<head>
<title>XML-RPC PHP Demo</title>
</head>
<body>
<h1>XML-RPC PHP Demo</h1>

<?php
include 'xmlrpc.inc';

// Make an object to represent our server.
$server = new xmlrpc_client('/api/sample.php',
                            'xmlrpc-c.sourceforge.net', 80);

// Send a message to the server.
$message = new xmlrpcmsg('sample.sumAndDifference',
                         array(new xmlrpcval(5, 'int'),
                               new xmlrpcval(3, 'int')));
$result = $server->send($message);

// Process the response.
if (!$result) {
    print "<p>Could not connect to HTTP server.</p>";
} elseif ($result->faultCode()) {
    print "<p>XML-RPC Fault #" . $result->faultCode() . ": " .
        $result->faultString();
} else {
    $struct = $result->value();
    $sumval = $struct->structmem('sum');
    $sum = $sumval->scalarval();
    $differenceval = $struct->structmem('difference');
    $difference = $differenceval->scalarval();
    print "<p>Sum: " . htmlentities($sum) .
        ", Difference: " . htmlentities($difference) . "</p>";
}
?>

</body></html>

À¥¼­¹ö¿¡¼­ PHP ½ºÅ©¸³Æ®°¡ ½ÇÇàµÇÁö ¾Ê´Â´Ù¸é PHP À¥»çÀÌÆ®¸¦ ÂüÁ¶Ç϶ó.


10.2. PHP ¼­¹ö

´ÙÀ½ÀÇ ½ºÅ©¸³Æ®´Â PHP¸¦ ÀÌ¿ëÇÏ¿© XML-RPC ¼­¹ö¿¡ Àû¿ëÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.

<?php
include 'xmlrpc.inc';
include 'xmlrpcs.inc';

function sumAndDifference ($params) {

    // Parse our parameters.
    $xval = $params->getParam(0);
    $x = $xval->scalarval();
    $yval = $params->getParam(1);
    $y = $yval->scalarval();

    // Build our response.
    $struct = array('sum' => new xmlrpcval($x + $y, 'int'),
                    'difference' => new xmlrpcval($x - $y, 'int'));
    return new xmlrpcresp(new xmlrpcval($struct, 'struct'));
}

// Declare our signature and provide some documentation.
// (The PHP server supports remote introspection. Nifty!)
$sumAndDifference_sig = array(array('struct', 'int', 'int'));
$sumAndDifference_doc = 'Add and subtract two numbers';

new xmlrpc_server(array('sample.sumAndDifference' =>
                        array('function' => 'sumAndDifference',
                              'signature' => $sumAndDifference_sig,
                              'docstring' => $sumAndDifference_doc)));
?>

À§ÀÇ ½ºÅ©¸³Æ®¸¦ À¥¼­¹ö¿¡¼­ http://localhost/path/sumAndDifference.php¿Í °°Àº ¹æ½ÄÀ¸·Î ½ÇÇà½Ãų ¼ö ÀÖ´Ù.


11. Using XML-RPC with Microsoft .NET

Charles CookÀÌ ÇöÀç ÀÌ HOWTO¿¡ ´ëÇÑ »õ·Î¿î ÀåÀ» ¾²°í ÀÖ´Ù. ÇöÀç ¿Â¶óÀÎ ÃʾÈÀ» º¼ ¼ö ÀÖ´Ù. ¸¸¾à ÀÌ ÆäÀÌÁö°¡ ¾ø¾îÁ³´Ù¸é ¸®´ª½º ¹®¼­ ÇÁ·ÎÁ§Æ®¿¡¼­ XML-RPC HOWTO(ÀÌ ¹®¼­)ÀÇ ÃֽŹöÁ¯À» »ìÆ캸¶ó.


12. Ruby·Î XML-RPC »ç¿ëÇϱâ

(ÀÌ ÀåÀÇ ´ëºÎºÐÀº Michael NeumannÀÌ ½è´Ù.)

Ruby´Â °´Ã¼ÁöÇâÀûÀÎ ½ºÅ©¸³Æ® ¾ð¾î´Ù. ÀÌ¹Ì ÀϺ»¿¡¼­´Â ÇÁ·Î±×·¡¹ÖÀÇ ÁÖ·ù¸¦ ÀÌ·ç°í ÀÖÀ¸¸ç, ±× ¿ÜÀÇ °÷À¸·Îµµ È®´ëµÇ¾î °¡°í ÀÖ´Ù.

Ruby·Î XML-RPC¸¦ »ç¿ëÇϱâ À§Çؼ­´Â ¸ÕÀú Yoshida MasatoÀÇ xmlparser ¸ðµâ(James ClarkÀÇ expat Æļ­ÀÇ ·çºñ¿ë ·¡ÆÛ)À» ¸ÕÀú ¼³Ä¡ÇØ¾ß ÇÑ´Ù. ÀÌ ¸ðµâÀº Ruby Application Archive¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

xmlrpc4r ¸ðµâÀ» ´ÙÀ½°ú °°ÀÌ ¼³Ä¡Ç϶ó:

bash$ tar -xvzf xmlrpc4r-1_2.tar.gz
bash$ cd xmlrpc4r-1_2
bash$ su root -c "ruby install.rb"

12.1. Ruby Ŭ¶óÀ̾ðÆ®

´ÙÀ½Àº °£´ÜÇÑ Ruby Ŭ¶óÀ̾ðÆ®ÀÌ´Ù:

require "xmlrpc/client"

# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new( "xmlrpc-c.sourceforge.net", "/api/sample.php")

# Call the remote server and get our result
result = server.call("sample.sumAndDifference", 5, 3)

sum = result["sum"]
difference = result["difference"]

puts "Sum: #{sum}, Difference: #{difference}"

12.2. Ruby ¼­¹ö

´ÙÀ½Àº °£´ÜÇÑ Ruby ¼­¹öÀÌ´Ù:

require "xmlrpc/server"

s = XMLRPC::CGIServer.new

s.add_hanlder("sample.sumAndDifference") do |a,b|
  { "sum" => a + b, "difference" => a - b }
end

s.serve

À§ÀÇ ÄÚµå´Â ´ÙÀ½°ú °°ÀÌ ÀÛ¼ºÇÒ ¼öµµ ÀÖ´Ù:

require "xmlrpc/server"

s = XMLRPC::CGIServer.new

class MyHandler
  def sumAndDifference(a, b)
    { "sum" => a + b, "difference" => a - b }
  end
end

s.add_handler("sample", MyHandler.new)
s.serve

CGI ±â¹ÝÀÇ ¼­¹ö ´ë½Å µ¶¸³ ¼­¹ö·Î ½ÇÇàÇÏ·Á¸é µÎ¹ø° ÁÙÀ» ´ÙÀ½°ú °°ÀÌ ¹Ù²Ù¸é µÈ´Ù:

s = XMLRPC::Server.new(8080)

13. °£ÀÌ ¾ð¾î·Î XML-RPC »ç¿ëÇϱâ

´ÙÀ½°ú °°Àº ºñ¹ü¿ë °£ÀÌ ¾ð¾î ȯ°æ¿¡¼­µµ XML-RPC¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.


13.1. K·Î XML-RPC »ç¿ëÇϱâ

(ÀÌ ÀåÀÇ ´ëºÎºÐÀº Christian Langreiter°¡ ½è´Ù.)

K´Â À繫(finance)¿Í µ¥ÀÌŸº£À̽º °³¹ß¿ë ¾ð¾îÀÌ´Ù. K¿ë XML-RPC ¸ðµâÀº Kx À¥»çÀÌÆ®¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù. ¾ÐÃàÀ» Ç®°í .k ÇÁ·Î±×·¥ÀÌ ÀÖ´Â µð·ºÅ丮¿¡ ÆÄÀÏÀ» µÎ¸é µÈ´Ù.

´ÙÀ½Àº °£´ÜÇÑ Å¬¶óÀ̾ðÆ®ÀÌ´Ù:

\l kxr
server:("localhost";"/cgi-bin/sumAndDifference.cgi");
.kxr.c[server;"sumAndDifference";2 3]

¶ÇÇÑ ¼­¹ö´Â ´ÙÀ½°ú °°´Ù:

\l kxrsc
.kxr.sm: ,("sumAndDifference";{.((`sum;+/x);(`difference;-/x))})

´Ù¸¥ ¿¹Á¦´Â ¹èÆ÷µÇ´Â ÆÄÀÏ ¼Ó¿¡ µé¾îÀÖ´Ù.


14. XML-RPC ¸ðµâÀ» ³»ÀåÇÑ ¾ÖÇø®ÄÉÀ̼Ç

¸î¸îÀÇ À¯¸íÇÑ ¸®´ª½º ¾ÖÇø®ÄÉÀ̼ÇÀº XML-RPC ¸ðµâÀ» ÀÚüÀûÀ¸·Î Áö¿øÇÏ°í ÀÖ´Ù. ÀÌ ÇÁ·Î±×·¥µéÀº ´Ù¸¥ °÷¿¡¼­ ÀÌ¹Ì ¸¹ÀÌ ¾ð±ÞµÇ¾úÀ¸¹Ç·Î, ¿©±â¼­´Â ¸µÅ©¸¸ °É¾îµÎ°íÀÚ ÇÑ´Ù.


14.1. Zope

ZopeÀÇ XML-RPC »ç¿ë¹ý¿¡ ´ëÇÑ ¹®¼­´Â ´ÙÀ½°ú °°Àº °÷¿¡¼­ ãÀ» ¼ö ÀÖ´Ù:


14.2. KDE 2.0

KDE 2.0Àº Kurt GanrothÀÇ kxmlrpc daemonÀ» Æ÷ÇÔÇÑ´Ù. ÀÌ°ÍÀº KDE ¾ÖÇø®ÄÉÀ̼ÇÀÌ XML-RPC¸¦ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇØ ÁÖ´Â ½ºÅ©¸³Æ®ÀÌ´Ù.

PythonÀ¸·Î ¸¸µç °£´ÜÇÑ »ùÇà ÇÁ·Î±×·¥µµ ÀÖ´Ù. ÀÌ ÇÁ·Î±×·¥Àº kxmlrpc¿¡ ¿¬°áÇÏ¿© KDE ÁÖ¼Ò·ÏÀ» Á¶ÀÛÇÏ°í, KDE trader¸¦ ÁúÀÇÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.

¸¸¾à ´Ù¸¥ ¹®¼­³ª Äڵ尡 ÀÖ´Ù¸é 15.3절À» º¸¶ó. KDE ½ºÅ©¸³Æ®¿¡ ´ëÇÑ ´õ ¸¹Àº Á¤º¸°¡ ÇÊ¿äÇÏ´Ù.


15. ÀÌ ¹®¼­¿¡ ´ëÇÏ¿©

ÀÌ ¹®¼­´Â ¸®´ª½º ¹®¼­ ÇÁ·ÎÁ§Æ®ÀÇ ÀϺκÐÀÌ´Ù. Dave Winer¿Í ¸¹Àº XML-RPC ¶óÀ̺귯¸®ÀÇ °ü¸®Àڵ鿡°Ô °¨»ç¸¦ Ç¥ÇÑ´Ù.


15.1. ÀÌ ¹®¼­ÀÇ »õ ¹öÁ¯

ÀÌ ¹®¼­ÀÇ ÃֽŠ¹öÁ¯Àº ¸®´ª½º ¹®¼­ ÇÁ·ÎÁ§Æ® À¥»çÀÌÆ®¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù.

´ÙÀ½°ú °°Àº ´Ù¸¥ Çü½ÄÀÇ ¹®¼­µµ Áö¿øÇÑ´Ù: PDF, gzipped HTML and ASCII text.


15.2. XML-RPC HOWTO ¹®¼­ÀÇ °øÇåÀÚ

Ruby¿¡ ´ëÇÑ ÀåÀº Michael Neumann(neumann AT s-direktnet DOT de)ÀÌ µµ¿òÀ» ÁÖ¾ú´Ù. K¿¡ ´ëÇÑ ÀåÀº Christian Langreiter(c DOT langreiter AT synerge DOT at)°¡ µµ¿òÀ» ÁÖ¾ú´Ù.

À§ÀÇ °øÇåÀÚµéÀº ±×µéÀÇ ÀÛ¼ºÇÑ ÀåÀÇ Ã¹¸Ó¸®¿¡ À̸§ÀÌ ºÙ´Â´Ù.


15.3. ¹®¼­ º¸³»±â

¸¸¾à ´Ù¸¥ ¾ð¾î³ª ȯ°æ¿¡¼­ ¸¸µç Ŭ¶óÀ̾ðÆ®³ª ¼­¹ö ¿¹Á¦°¡ ÀÖ´Ù¸é ±× ¼³¸í¼­¸¦ º¸³»´Þ¶ó. »õ·Î µî·ÏÇÏ·Á¸é ´ÙÀ½°ú °°Àº Á¤º¸°¡ ÇÊ¿äÇÏ´Ù:

  • XML-RPC ¸ðµâÀÌ »ç¿ëµÈ URL

  • ¼³Ä¡ ¹æ¹ý

  • ¿ÏÀüÇÏ°Ô ½ÇÇàµÇ´Â ÇÁ·Î±×·¥

  • (ÄÄÆÄÀÏÇØ¾ß ÇÏ´Â °ÍÀ̶ó¸é) ÄÄÆÄÀÏ ¹æ¹ý

xmlrpc-c-devel ¸ÞÀϸµ¸®½ºÆ®, ȤÀº Á÷Á¢ Eric Kidd¿¡°Ô ¿¹Á¦¸¦ ¸ÞÀÏ·Î º¸³»´Þ¶ó.

Thank you for your help!


ID
Password
Join
You plan things that you do not even attempt because of your extreme caution.


sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2008-06-11 09:43:29
Processing time 0.0020 sec