XMLRPC显示-32601错误(使用PHP) [英] XMLRPC showing -32601 error (using PHP)

查看:284
本文介绍了XMLRPC显示-32601错误(使用PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码...

<?php
include("lib/xmlrpc.inc");

$email='whatever@hotmail.com';

$c=new xmlrpc_client("/register/index.php", "ws.myserver.com", 80);
$f=new xmlrpcmsg('existsEmail', array(new xmlrpcval($email, "base64")));
print "<pre>" . htmlentities($f->serialize( )) . "</pre>";

$r=$c->send($f);
$v=$r->value( );

if (!$r->faultCode( )) {
    print "Email is". $email . " is " .
          $v->scalarval( ) . "<br />";
          print "<hr />I got this value back<br /><pre>" .
          htmlentities($r->serialize( )). "</pre><hr />\n";
} else {
    print "Fault: ";
    print "Code: " . $r->faultCode( ) .
    " Reason '" .$r->faultString( )."'<br />";
}

?>

我需要使用位于 http://ws.myserver.com/register/上的Web服务index.php .

我将电子邮件作为参数传递,然后XMLRPC.inc库将使用base64对其进行编码.

I pass the email as a parameter and then the XMLRPC.inc library will encode it using base64.

我有一个很好的XML请求,如下所示:

I've got a good XML request shown below:

<?xml version="1.0"?>
<methodCall>
<methodName>existsEmail</methodName>
<params>
<param>
<value><base64>dnJvZHJpZ3VlekBpY2NrLm5ldC5jbw==</base64></value>
</param>
</params>
</methodCall>

BUUUT,当我尝试从服务器获取响应时,我遇到了以下错误

BUUUT, when I tried to get a response from the server I've to the following error

Fault: Code: -32601 Reason 'server error. requested method not found'

Fault: Code: -32601 Reason 'server error. requested method not found'

有什么想法吗?我为如何从我的PHP代码调用 existsEmail 方法而疯狂……我确定它在那里,但是我不知道我是否缺少某些东西. >

Any ideas? I'm getting crazy about how to call the existsEmail method from my PHP code...I'm sure it is there but I don't know if I'm missing something..

推荐答案

您将获得这是一个已定义的错误代码:

It is a defined error code:

-32601 ---> server error. requested method not found

服务器未找到您请求的RPC方法.请与您使用的服务的支持联系,以获取所有可用方法的列表.如果可以使用该方法,请与支持人员联系并与他们讨论问题.

The RPC method you requested was not found by the server. Contact the support of the service you consume to get a list of all available methods. If that method should be available, contact the support and discuss the issue with them.

您在评论中问:

有什么方法可以[验证]哪些方法可用?

Is there any way [to] verify which methods are available?

这取决于服务. sourceforge上的XMLRPC建议使用已定义的方法,您可以调用这些方法来列出有关可用功能的信息:

That depends on the service. XMLRPC on sourceforge has a suggestion of defined methods you can call to list information about the functions available:

XML-RPC内省

  • system.listMethods
  • system.methodSignature
  • system.methodHelp
  • system.listMethods
  • system.methodSignature
  • system.methodHelp

您也可以尝试使其与您的服务一起使用. AFAIK这些很常见,我总结了一个简单的示例,您可以在下面找到完整的代码.也请参见代码下方的输出.

You can try if it works with your service, too. AFAIK those are common, I wrapped up a quick example, you find the full code below. See the output below the code as well.

$path = 'http://xmlrpc-c.sourceforge.net/api/sample.php';

printf("\n XMLRPC Service Discovery\n\n for: '%s'\n\n", $path);

$discovery = new Discovery($path);
$methods = $discovery->getMethods();

printf(" Method Summary:\n ===============\n", count($methods));
foreach ($methods as $i => $method)
{
    printf(" %'.-2d %s\n", $i + 1, $method->getName());
}

printf("\n Method Details (%d):\n ===================\n", count($methods));
foreach ($methods as $i => $method)
{
    printf("  %'.-2d %s\n", $i + 1, $method->getName());
    printf("\n       %s\n", $method);
    printf("\n%s\n\n", preg_replace('/^/um', '     ', wordwrap($method->getHelp(), 46)));
}

输出:

 XMLRPC Service Discovery

 for: 'http://xmlrpc-c.sourceforge.net/api/sample.php'

 Method Summary:
 ===============
 1. debug.authInfo
 2. sample.add
 3. sample.sumAndDifference
 4. system.listMethods
 5. system.methodHelp
 6. system.methodSignature

 Method Details (6):
 ===================
  1. debug.authInfo

       <struct> debug.authInfo

     Report any HTTP authentication in use

  2. sample.add

       <int> sample.add (<int>, <int>)

     Add two numbers

  3. sample.sumAndDifference

       <struct> sample.sumAndDifference (<int>, <int>)

     Add and subtract two numbers

  4. system.listMethods

       <array> system.listMethods (<string>)

     This method lists all the methods that the
     XML-RPC server knows how to dispatch

  5. system.methodHelp

       <string> system.methodHelp (<string>)

     Returns help text if defined for the method
     passed, otherwise returns an empty string

  6. system.methodSignature

       <array> system.methodSignature (<string>)

     Returns an array of known signatures (an array
     of arrays) for the method name passed. If no
     signatures are known, returns a none-array
     (test for type != array to detect missing
     signature)

您可以在此处找到源代码: XMLRPC发现服务

You can find the sourcecode here: XMLRPC Discovery Service

这篇关于XMLRPC显示-32601错误(使用PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆