Failed to load external entity - php

I am trying to integrate fedex API and getting this error .
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "../wsdl/RateService_v13.wsdl" in test.php on line 12
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '../wsdl/RateService_v13.wsdl' in D:\wamp\www\fedexapi\AddressValidationService_v4_php\php\AddressValidationWebServiceClient\rate_test.php:12 Stack trace: #0 D:\wamp\www\fedexapi\AddressValidationService_v4_php\php\AddressValidationWebServiceClient\rate_test.php(12): SoapClient->SoapClient('../wsdl/RateSer...', Array) #1 {main} thrown in test.php on line 12
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 2.0.0
require_once('../library/fedex-common.php5');
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../wsdl/LocationsService_v3.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
?>
How to solve this ?

Afaik the SoapClient first aprameter need to be an URI, not a local filename on your disk.
The error indicated that it was unable to load the wsdl.
Have a look at the specs and this expample should make it clear.

Relative path works as well.
In my case, I had to fix the wsdl file's relative path.

Related

Fatal Error in Awin API - Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from

I have a very serious issue. I am working witht he API - https://ui.awin.com/awin/affiliate/250615?region=gb and after login into that, i found the api documentation and also php api client zip.
I then downloaded this client zip, updated all my api details and when i run - http://202.131.107.107/searchcycle/ps_client.php , I always get error as below -
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://v6.core.com.productserve.com/ProductServeService.wsdl' : failed to load external entity "http://v6.core.com.productserve.com/ProductServeService.wsdl" in /var/www/html/searchcycle/classes/class.php5Client.php:57 Stack trace: #0 /var/www/html/searchcycle/classes/class.php5Client.php(57): SoapClient->SoapClient('http://v6.core....', Array) #1 /var/www/html/searchcycle/classes/class.php5Client.php(95): Php5Client->__construct(Object(stdClass)) #2 /var/www/html/searchcycle/classes/class.ClientFactory.php(60): Php5Client::getInstance(Object(stdClass)) #3 /var/www/html/searchcycle/ps_client.php(29): ClientFactory::getClient() #4 {main} thrown in /var/www/html/searchcycle/classes/class.php5Client.php on line 57
Can someone please help me in this what is missing from my side.
Add optional SSL parameters.
How to solve:
// options for ssl in php 5.6.5
$opts = array(
'ssl' => array(
'ciphers' => 'RC4-SHA',
'verify_peer' => false,
'verify_peer_name' => false
)
);
// SOAP 1.2 client
$params = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts) // Magic happens here
);
$wsdlUrl = $url . '?WSDL';
$oSoapClient = new SoapClient($wsdlUrl, $params);
Please check this question, you would find something useful.

PHP SOAP Error Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from

I am trying to create a SOAP Client from a WSDL file, but I always get this error bellow.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'https://..../CreateQuote?xsd=createQuote_datamodel.xsd', namespace must not match the enclosing schema 'targetNamespace' in C:\xampp\htdocs\kfz\test.php:23 Stack trace: #0 C:\xampp\htdocs\kfz\test.php(23): SoapClient->SoapClient('https://testws1...', Array) #1 {main} thrown in C:\xampp\htdocs\kfz\test.php on line 23
Here is my code:
$xml = file_get_contents("out.xml");
$soapOptions = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'wsdl_local_copy' => false,
'keep_alive' => true,
);
$soapClient = new SoapClient($wsdlUrl, $soapOptions);
$soapClient->CreateQuote($xml);
Can anyone help me please?
I also tried it with non WSDL mode but it's still not working

aws s3 uploading a directory to a bucket with php sdk

This is the php file named upload.php in ec2 server
require 'vendor/autoload.php';
use Aws\S3\S3Client;
$client = S3Client::factory(array(
'key' => 'aws-secret-key',
'secret' => 'aws-very-secret-pass',
));
$dir = '/home/user/movies/history';
$bucket = 'my-unique-bucket';
$keyPrefix = '';
$options = array(
'params' => array('ACL' => 'public-read'),
'concurrency' => 20,
'debug' => true
);
$client->uploadDirectory($dir, $bucket, $keyPrefix, $options);
When I execute the upload.php file in terminal returns fatal error like this,
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(/home/kaya/Resimler/transferet/): failed to open dir: No such file or directory' in /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php:47
Stack trace:
#0 /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php(47): RecursiveDirectoryIterator->__construct('/home/user/movie...', 12800)
#1 /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/S3Client.php(557): Aws\S3\Sync\UploadSyncBuilder->uploadFromDirectory('/home/user/movie...')
#2 /var/www/html/upload_dir.php(21): Aws\S3\S3Client->uploadDirectory('/home/user/movie...', 'my-unique-bucket', '', Array)
#3 {main}
thrown in /var/www/html/vendor/aws/aws-sdk-php/src/Aws/S3/Sync/UploadSyncBuilder.php on line 47
Normally I can upload files clearly with php sdk except uploadfolder function. I couldnt find where is false. My php sdk version is 2.7.
I figured it out. It works on local server like xampp or something, doesnt work on remote server.

soap parsing unexpected in complextype

I can parse the .WSDL file and call the functions using soapUI, but not
using PHP5. It has also been shown to work with JAVA/AXIS and .NET.
I need the WSDL caching functionality of the PHP5 SOAP procedures
otherwise I might stick with soapUI.
Reproduce code:
$optional = array
(
'trace' => 1,
'exceptions' => true,
'soap_version' => SOAP_1_1,
'encoding' => 'ISO-8859-1'
);
$wsdl = 'https://www-a.audanet.de/b2b/services/AXAttachmentService?wsdl';
$client = new SoapClientAuth($wsdl, $optional);
Expected result:
A useable instance of a SoapClient object.
Actual result:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected 'attribute' in complexType in ../class/SoapClientAuth.php:62
Stack trace:
0 ../class/SoapClientAuth.php(62): SoapClient->SoapClient('https://www-a.a...', Array)
1 ../class/Ws.php(30): SoapClientAuth->SoapClientAuth('https://www-a.a...', Array)
2 ../zalacz.php(468): Ws->podlaczenieWS()
3 {main}
thrown in ../class/SoapClientAuth.php on line 62

How to change the namespace sent with a SOAP request?

Related to this question: How to request an answer from a SOAP XML API?
I have this PHP script sending the request with the required fields:
$client = new SoapClient('https://live.domainbox.net/?WSDL');
$params = array(
'AuthenticationParameters' => array(
'Reseller' => 'resellername',
'Username' => 'myusername',
'Password' => 'mypassword'
),
'CommandParameters' => array(
'DomainName' => 'mydomain.com',
'LaunchPhase' => 'GA'
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
I get the following error message:
Fatal error: Uncaught SoapFault exception: [soap:VersionMismatch]
Possible SOAP version mismatch: Envelope namespace
http://schemas.xmlsoap.org/soap/envelope/ was unexpected.
Expecting http://www.w3.org/2003/05/soap-envelope. in
/home/nosa/public_html/dev/check-domain-availability.php:20 Stack
trace: #0
/home/nosa/public_html/dev/check-domain-availability.php(20):
SoapClient->__call('CheckDomainAvai...', Array) #1
/home/nosa/public_html/dev/check-domain-availability.php(20):
SoapClient->CheckDomainAvailability(Array) #2 {main} thrown in
/home/nosa/public_html/dev/check-domain-availability.php on line 20
I removed and recompiled apache to include the latest SOAP version available using WHM/cPanel.
My question is:
How do I send the correct envelope namespace?
When building your soap_client object, you can pass an option's array, by default, the version will be 1.1 as per php documentation.
The error you have seems to point out that the service might be SOAP 1.2 so you need to set it to 1.2...
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2));
Try that out!

Categories