p0t: XML食わず嫌い

PEAR::XML_RPCはHTTP/1.0なのでバーチャルホスト相手はだめなんですよね SerendipityではHTTP_Requestも併用したもので実装しました パッチ作ってコミットさせてもらいました http://sourceforge.net/mailarchive/forum.php?thread_id=7556980&forum_id=31275

投稿者 ELF : 2006年02月10日 23:33

な、なんだってー! (長くなるのでエントリーで返信)

XML-RPC Specification

Overview

XML-RPC is a Remote Procedure Calling protocol that works over the Internet.

An XML-RPC message is an HTTP-POST request. The body of the request is in XML. A procedure executes on the server and the value it returns is also formatted in XML.

Procedure parameters can be scalars, numbers, strings, dates, etc.; and can also be complex record and list structures.

XML-RPCの仕様には単にHTTP-POST requestとしか書いてないっぽい。ということはServerもClientも1.1対応してた方がいいけど別に必須ってわけじゃないってことかな?

PEARの方を見てみる。

[cvs] View of /pear/XML_RPC/RPC.php

    /**
     * Transmit the RPC request via HTTP 1.0 protocol
     *
     * @param object $msg       the XML_RPC_Message object
     * @param int    $timeout   how many seconds to wait for the request
     *
     * @return object  an XML_RPC_Response object.  0 is returned if any
     *                  problems happen.
     *
     * @see XML_RPC_Message, XML_RPC_Client::XML_RPC_Client(),
     *      XML_RPC_Client::setCredentials()
     */
    function send($msg, $timeout = 0)
    {
        if (!is_a($msg, 'XML_RPC_Message')) {
            $this->errstr = 'send()\'s $msg parameter must be an'
                          . ' XML_RPC_Message object.';
            $this->raiseError($this->errstr, XML_RPC_ERROR_PROGRAMMING);
            return 0;
        }
        $msg->debug = $this->debug;
        return $this-><strong>sendPayloadHTTP10</strong>($msg, $this-&gt;server, $this-&gt;port,
                                        $timeout, $this-&gt;username,
                                        $this->password);
    }

ん、sendPayloadHTTP10()・・・? (XML-RPCで送る中身のことをペイロードっていうらしい)

    /**
     * Transmit the RPC request via HTTP 1.0 protocol
     *
     * Requests should be sent using XML_RPC_Client send() rather than
     * calling this method directly.
     *
     * @param object $msg       the XML_RPC_Message object
     * @param string $server    the server to send the request to
     * @param int    $port      the server port send the request to
     * @param int    $timeout   how many seconds to wait for the request
     *                           before giving up
     * @param string $username  a user name for accessing the RPC server
     * @param string $password  a password for accessing the RPC server
     *
     * @return object  an XML_RPC_Response object.  0 is returned if any
     *                  problems happen.
     *
     * @access protected
     * @see XML_RPC_Client::send()
     */
    function sendPayloadHTTP10($msg, $server, $port, $timeout = 0,
                               $username = '', $password = '')
    {
    (略)

うわっ、ホントだよ。 おれも上鍵さんのパッチをパクろ・・・。

SourceForge.net: php-blog-devs

$req = new HTTP_Request( "http://".$service["host"].$service["path"]);
$req-&gt;setMethod(HTTP_REQUEST_METHOD_POST);
$req-&gt;addHeader( "Content-Type", "text/xml");
$req-&gt;addRawPostData( $message-&gt;payload);
$http_result = $req-&gt;sendRequest();

Comments


Option