HTTP/1.1 405 Method Not Allowed 允许 authorized.net

Posted

技术标签:

【中文标题】HTTP/1.1 405 Method Not Allowed 允许 authorized.net【英文标题】:HTTP/1.1 405 Method Not Allowed Allow authorized.net 【发布时间】:2014-08-31 16:31:05 【问题描述】:

我正在magento中创建authorized.net的定期订阅。我成功创建了订阅。我添加了一个取消订阅并传递xml的选项,但它不接受。

                $loginname="******";
            $transactionkey="*******";
            $host = "apitest.authorize.net";

                    $content=
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
                    "<ARBCancelSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
                    "<merchantAuthentication>".
                    "<name>" . $loginname . "</name>".
                    "<transactionKey>" . $transactionkey . "</transactionKey>".
                    "</merchantAuthentication>" .
                    "<subscriptionId>" . 2179811  . "</subscriptionId>".
                    "</ARBCancelSubscriptionRequest>";

                    echo $response = send_request_via_curl($host,$path,$content);die;

这是不允许的405方法。请帮助!

【问题讨论】:

我还在调查中。请大家帮忙! 【参考方案1】:

最后我通过修改我的代码来解决它。基本上问题出在标题上

`public function cancelSubscriptionAction()
        
                $xml_str ='<?xml version="1.0" encoding="utf-8"?>
                <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                <soap:Body>
                <ARBCancelSubscription xmlns="https://api.authorize.net/soap/v1/">
                <merchantAuthentication>
                <name>******</name>
                <transactionKey>******</transactionKey>
                </merchantAuthentication>
                <subscriptionId>******</subscriptionId>
                </ARBCancelSubscription>
                </soap:Body>
                </soap:Envelope>';

                $headers = array( 
                'Content-Type: text/xml; charset="utf-8"', 
                'Content-Length: '.strlen($xml_str), 
                'Accept: text/xml', 
                'Cache-Control: no-cache', 
                'Pragma: no-cache', 
                ); 

                $remote_url = 'https://apitest.authorize.net/soap/v1/Service.asmx';
                $process = curl_init($remote_url);
                curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($process, CURLOPT_HEADER, 1);
                curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($process, CURLOPT_TIMEOUT, 30);
                curl_setopt($process, CURLOPT_POST, 1);
                curl_setopt($process, CURLOPT_POSTFIELDS, $xml_str);
                curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
                $return = curl_exec($process);
                $finale = list ($resultCode, $code, $text, $subscriptionId) =parse_return($return);
                print_r($finale );
                curl_close($process);

        `

【讨论】:

以上是关于HTTP/1.1 405 Method Not Allowed 允许 authorized.net的主要内容,如果未能解决你的问题,请参考以下文章

今天遇到 Request failed: method not allowed (405)。 错误,特此在网上翻了翻

vue--axios使用post方法与后台进行异步传值是报错POST http://localhost:8080/api/AddEmployeeApi 405 (METHOD NOT ALLOWED)

跨域405(Method Not Allowed)问题

这是啥 405 Method Not Allowed svn 错误?

jersey中的405错误 method not allowed

代号一:405 Method Not Allowed 错误