When I use port with URL I get error:
Code:
try {
$options = [
'login' => "999999",
'password' => "999999testtest"
];
$request = new SoapClient("https://erpefaturatest.cs.com.tr:8043/efatura/ws/connectorService?wsdl", $options);
print_r($request);
} catch (Exception $exc) {
print_r($exc);
}
Error:
SOAP-ERROR: Parsing WSDL: Couldn't load from
But wihthout port I don't get error:
Code:
try {
$options = [
'login' => "999999",
'password' => "999999testtest"
];
$request = new SoapClient("https://connectortest.efinans.com.tr/connector/ws/connectorService?wsdl", $options);
print_r($request);
} catch (Exception $exc) {
print_r($exc);
}
I don't understand the problem. Any idea?
Related
I get this error on Digital Ocean Ubuntu server after deployment. It works perfectly on Heroku which is our staging server. It is a Laravel project where we use Laravel Passport. How do we solve this?
<?php
namespace App\Http\Traits;
use Illuminate\Support\Facades\Http;
use Laravel\Passport\Client as AuthClient;
use Exception;
trait AuthTrait
{
public function getTokenAndRefreshToken($email, $password)
{
try {
$auth_client = AuthClient::where('password_client', 1)->first();
$url = env('APP_URL') . "/oauth/token";
$response = Http::asForm()->post($url, [
'grant_type' => 'password',
'client_id' => $auth_client->id,
'client_secret' => $auth_client->secret,
'username' => $email,
'password' => $password,
'scope' => '*'
]);
$result = json_decode((string) $response->getBody(), true);
return $result;
} catch (Exception $e) {
throw $e;
}
}
}
How to Retrieve form_params used from a Guzzle BadResponseException (ClientException || ServerException) Object?
I couldn't find it in the documentation.
try {
$reponse = $this->client->post($uri, [
'form_params' => $params,
'headers' => $this->getHeaders()
]);
} catch (RequestException $e){
/// get form_params here without accessing $params
}
The form encoded parameters can be found on Request Body.
try {
$reponse = $this->client->post($uri, [
'form_params' => $params,
'headers' => $this->getHeaders()
]);
} catch (RequestException $e){
echo (string) $e->getRequest()->getBody();
}
I have tried 2 to 3 possibilities of date formats for the "Start_Date" like
30-05-2018
05-30-2018
30/05/2018
but I am getting the response as
The value "30-05-2018" can't be evaluated into type Date.
The below is my function
public function getPriceList($customer_number){
$url = 'Page/CustomerPrices';
try {
$response = new \stdClass();
$response->status = false;
$options = [
'soap_version' => SOAP_1_1,
'connection_timeout' => 120,
'login' => env('MICROSOFT_DYNAMICS_NAV_USERNAME', ''),
'password' => env('MICROSOFT_DYNAMICS_NAV_PASSWORD', ''),
'exceptions' => true,
];
$soapWsdl = env('MICROSOFT_DYNAMICS_NAV_URI', '').$url;
$client = new SoapClient($soapWsdl, $options);
$response->data = $client->ReadMultiple(['filter'=> [],'Start_Date' => "30-05-2018",'Cust_No'=>$customer_number,'Name'=>'Testing','Price_Comments'=>'','setSize'=>'1']);
$response->status = true;
}catch (Exception $e) {
$response->data = $e->getMessage();
}
return $response;
}
I am trying to use the SOAP webservice described by the below WSDL:
http://qaws.ssichilexpress.cl/TarificarCourier?wsdl
I tried:
public function __construct($config) {
$this->config = $config;
$this->client = new SoapClient($this->wsdl, [
'trace' => true,
'exceptions' => true
]);
}
public function tarifar($data) {
try {
$this->client->TarificarCourier([
'reqValorizarCourier' => $data
]);
} catch(SoapFault $fault) {
die($fault->getCode() . ': ' . $fault->getMessage());
}
}
But i get a SoapFault with message "Could not connect to host".
Any ideas ?
EDIT 1:
Also i tried:
public function __construct($config) {
$this->config = $config;
$this->wsdl = null;
$this->client = new SoapClient($this->wsdl, [
'trace' => true,
'exceptions' => true,
'location' => 'http://qaws.ssichilexpress.cl/',
'uri' => 'TarificarCourier'
]);
}
public function tarifar($data) {
try {
$this->client->__soapCall('TarificarCourier', [
'reqValorizarCourier' => $data
]);
} catch(SoapFault $fault) {
die('SFinReq: ' . $fault->getCode() . ': ' . $fault->getMessage());
}
}
But, i get a SoapFault with "Not Found" message.
I'm in a situation where I need to call the same method if any exception is thrown to ensure I'm not duplicating any code. However, it's not working as I thought. Here's the relevant code:
public static function getFolderObject($folder_id)
{
$client = new Client('https://api.box.com/{version}/folders', [
'version' => '2.0',
'request.options' => [
'headers' => [
'Authorization' => 'Bearer ' . self::getAccessToken(),
]
]
]);
$request = $client->get($folder_id);
try {
$response = $request->send();
$result = $response->json();
$files = $result['item_collection']['entries'];
} catch (BadResponseException $e) {
$result = $e->getResponse()->getStatusCode();
if ($result === 401) {
self::regenerateAccessToken();
self::getFolderObject();
}
}
return count($files) ? $files : false;
}
As you can see I'm calling the method from the method method under the if condition self::getFolderObject(); to prevent duplicate code again in under the if statement from beginning of the method. However, if I duplicate the code it works as expected. Is there any solution to achieve what I want?
You have missed to return the value and assign the folder_id:
public static function getFolderObject($folder_id)
{
$client = new Client('https://api.box.com/{version}/folders', [
'version' => '2.0',
'request.options' => [
'headers' => [
'Authorization' => 'Bearer ' . self::getAccessToken(),
]
]
]);
$request = $client->get($folder_id);
try {
$response = $request->send();
$result = $response->json();
$files = $result['item_collection']['entries'];
} catch (BadResponseException $e) {
$result = $e->getResponse()->getStatusCode();
if ($result === 401) {
self::regenerateAccessToken();
return self::getFolderObject($folder_id);
}
}
return count($files) ? $files : false;
}