0

我想xml-rpc从我在 android 上的 shell 脚本访问服务器。我用谷歌搜索xml-rpc了客户端,但一无所获。我只想要xml-rpc客户端命令行可执行文件,以便我可以在我的 android 设备上的 shell 脚本中使用它。那么有没有这样的二进制文件?

4

3 回答 3

0

我有同样的问题,试试这个: http: //acme.com/software/xmlrpc/ xmlrpc 是 XML-RPC 协议的命令行接口。

于 2013-09-24T09:56:08.560 回答
0

structArg() 完成:

structMember() {
    local arg=""
    local name= val=
    local type= val=
    local indent=    

    echo -e "    <member>"
    echo -e "    <name></name>"
    echo -e "    <value><></></value>"
    echo -e "    </member>"
}
structArg() {
    local args=""
    local type= val=
    local deep=0

    local cindent="    "
    local nindent=""
    echo -e "<param>\n<value>"
    eval set 
    for arg; do
        shift
        case  in
        struct:B*)
            ((deep > 0)) && echo -e "<member>"
            local name=
            [ -n "" ] && echo -e "<name></name>"
            echo -e "<struct>"
            indent=""
            nindent=""
            ((deep++))
            ;;
        struct:E)
            indent=    
            nindent=
            echo -e "</struct>"
            ((--deep > 0)) && echo -e "</member>"
            ;;
        *)
            structMember ""
            ;;
        esac
    done
    echo -e "</value>\n</param>"
}
于 2013-10-15T08:16:59.387 回答
-1

或者你可以使用 curl: http ://wiki.secondlife.com/wiki/Category:LSL_XML-RPC

我编写了一个 shell 脚本来生成 rpc.xml,它现在工作正常:

xmlrpc-client.sh

#!/bin/bash
# author jiyin@redhat.com

TEMP=`getopt -o vt: --long target   -n 'example.bash' -- "$@"`
if [ $? != 0 ] ; then echo "getopt fail, terminating..." >&2 ; exit 1 ; fi

# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

Usage() {
    echo "usage: $0 -t <rpcServUrl> <method> [arg1 arg2 ...]"
    exit 1
}
simpleArg() {
    local arg="$1"
    local type=${arg%%:*} val=${arg#*:}
        echo -e "${indent}<param><value><$type>$val</$type></value></param>"
}
structArg() {
    local arg="$1"
        : parse wait complete ...
}

while true ; do
    case "$1" in
    -t|--target) servUrl=$2; shift 2;;
    -v) verbose=--verbose; shift;;
    --) shift; break;;
    *) echo "Internal error!"; exit 1;;
    esac
done
[ -z "$servUrl" ] && Usage
[ $# -lt 1 ] && Usage

#<method> <arg1> <arg2> ... <argx>
generateRequestXml() {
    method=$1; shift
    echo '<?xml version="1.0"?>'
    echo "<methodCall>"
    echo "    <methodName>$method</methodName>"
    echo "    <params>"

    indent="    "
    for arg; do
        indent="${indent}    "
        case $arg in
        struct:*) structArg "$arg";;
        *) simpleArg "$arg";;
        esac
    done

    echo "    </params>"
    echo "</methodCall>"
}
rpcxml=rpc$$.xml
generateRequestXml "$@" > $rpcxml
[ "$verbose" = "--verbose" ] && cat "$rpcxml"
curl $verbose --data "@$rpcxml" "$servUrl" 2>/dev/null | xmllint --format -
\rm -f $rpcxml
于 2013-09-24T12:42:41.367 回答