Tôi có một ứng dụng mà người dùng gửi biểu mẫu thực hiện trao đổi SOAP để lấy một số dữ liệu từ API Web. Nếu có quá nhiều yêu cầu trong một thời gian nhất định, máy chủ Throttle sẽ từ chối truy cập. Tôi đã thực hiện chế độ xem lỗi tùy chỉnh cho điều này được gọi là throttle.blade.php
được lưu dưới resources\views\pages
. Trong routes.php
Tôi đã đặt tên cho tuyến đường như:Chuyển hướng đến tuyến đường không hoạt động trong Laravel 5
Route::get('throttle', '[email protected]');
trong PagesController.php
Tôi đã thêm chức năng có liên quan như:
public function throttleError() {
return view('pages.throttle');
}
Đây là lớp SoapWrapper
Tôi đã tạo ra để thực hiện việc trao đổi SOAP:
<?php namespace App\Models;
use SoapClient;
use Illuminate\Http\RedirectResponse;
use Redirect;
class SoapWrapper {
public function soapExchange() {
try {
// set WSDL for authentication
$auth_url = "http://search.webofknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl";
// set WSDL for search
$search_url = "http://search.webofknowledge.com/esti/wokmws/ws/WokSearch?wsdl";
// create SOAP Client for authentication
$auth_client = @new SoapClient($auth_url);
// create SOAP Client for search
$search_client = @new SoapClient($search_url);
// run 'authenticate' method and store as variable
$auth_response = $auth_client->authenticate();
// add SID (SessionID) returned from authenticate() to cookie of search client
$search_client->__setCookie('SID', $auth_response->return);
} catch (\SoapFault $e) {
// if it fails due to throttle error, route to relevant view
return Redirect::route('throttle');
}
}
}
Mọi thứ hoạt động như vậy cho đến khi tôi đạt đến số lượng yêu cầu tối đa được máy chủ Throttle cho phép, tại thời điểm đó nó sẽ hiển thị m y chế độ xem tùy chỉnh nhưng hiển thị lỗi:
InvalidArgumentException in UrlGenerator.php line 273:
Route [throttle] not defined.
Tôi không thể hiểu tại sao người ta nói rằng Tuyến đường không được xác định.