使用php soapclient的Bugzilla webservices - 错误 - 错误的版本

时间:2012-03-22 21:42:52

标签: php web-services soap soap-client bugzilla

嗨我需要使用bugzilla webservices和php在bugzilla中创建一个bug。我不想使用任何其他库(例如.zend,nusoap等),因为我的老板希望它严格使用php soapclient。在尝试了几天之后,我无法使其发挥作用。我希望你们能帮助我。我第一次使用http://code.google.com/p/bugzillaphp/的类可以做到这一点。但是,当我们升级到新的bugzilla(4.2)并且该类使用xmlrpc请求而不是webservice时。所以它失败了。我正在粘贴代码,肥皂请求和响应。请帮帮我们。

<?php
$user = 'your email address';
$pass = 'your password';
$uri = 'http://your site/xmlrpc.cgi';       
$client = new SoapClient(NULL,
                                       array('location' => $uri,
                                            'uri'     => $uri,
                                            'trace' => 1,
                                            'soap_version' => SOAP_1_2,

                                             'action' => ""
                                            //'exceptions' => 0
));
try
{
 $result = $client->__soapCall("User.login", array(

            'login'          => $user,
            'password'       => $pass,          
            'remember'  => 'true'
            ));
print $result;                  
}
catch (Exception $e)
 {
        print $e->getMessage();
    echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
    echo "Response:\n" . $client->__getLastResponse() . "\n";
    echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "\n";
    echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "\n";
print_r($headers);      
$headers = str_replace("application/soap+xml", "text/xml", $headers);
print_r($headers);  
 }
?>
     xml request and response, xml request headers and response headers:-

REQUEST:
 <?xml version="1.0" encoding="UTF-8"?>
 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="htt
p://devbugz/xmlrpc.cgi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/
soap-encoding"><env:Body><ns1:User.login env:encodingStyle="http://www.w3.org/20
03/05/soap-encoding"><param0 xsi:type="xsd:string">your email</param0><par
am1 xsi:type="xsd:string">your password</param1><param2 xsi:type="xsd:string">true</p
aram2></ns1:User.login></env:Body></env:Envelope>

Response:
<?xml version="1.0" encoding="UTF-8"?><methodResponse><fault><value><struct><mem
ber><name>faultString</name><value><string>Application failed during request des
erialization: 32612: When using XML-RPC, you cannot send data as application/soa
p+xml; charset=utf-8; action="http://devbugz/xmlrpc.cgi#User.login". Only text/x
ml and application/xml are allowed. at F:/applications/ActiveState/Perl/v5.10.0/
site/lib/SOAP/Lite.pm line 2778.
</string></value></member><member><name>faultCode</name><value><string>Client</s
tring></value></member></struct></value></fault></methodResponse>

REQUEST HEADERS:
POST /xmlrpc.cgi HTTP/1.1
Host: devbugz
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.9
Content-Type: application/soap+xml; charset=utf-8; action="http://yoursite/xmlrpc
.cgi#User.login"
Content-Length: 569


RESPONSE HEADERS:
HTTP/1.1 200 OK
Date: Thu, 22 Mar 2012 21:08:56 GMT
Server: Apache/2.2.19 (Win32) mod_auth_sspi/1.0.4 PHP/5.2.6 DAV/2 SVN/1.6.15 mod
_ssl/2.2.19 OpenSSL/0.9.8r
SOAPServer: SOAP::Lite/Perl/0.714
Content-Length: 578
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/xml

2 个答案:

答案 0 :(得分:0)

Bugzilla中已知错误:https://bugzilla.mozilla.org/show_bug.cgi?id=731219

您可以更新Bugzilla,也可以使用上面提供的补丁修补它。

或者您可以使用此答案https://stackoverflow.com/a/1688239/1050577并将您的soap客户端版本更改为SOAP_1_1。

答案 1 :(得分:0)

谢谢“sas”,但我明白了。我的结论是,由于bugzilla webservices是使用xmlrpc服务器(xmlrpc.cgi)(而不是soap服务器)实现的,所以我们不能使用php soapclient来调用这些服务。我在phpxmlrpc.sourceforge.net上使用xmlrpc client for php来实现调用bugzilla webservices的客户端脚本。我很快就会发布这个代码。