I am getting an error:
SOAP-ERROR: Parsing WSDL: Couldn't load from
'https://apphom.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl'
: failed to load external entity
"https://apphom.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl
I'm using:
XAMPP for Windows 5.6.15
5.6.15
Windows 8.1
PHP Version 5.6.15
And in my php.ini I enabled the options:
extension=php_openssl.dll
extension=php_curl.dll
extension=php_xmlrpc.dll
But I can not resolve the error, already researched several solutions.
The source code I'm trying to run is here
I solved the problem by rewriting my method
before
public static function getSoapClient()
{
if (!self::$_soapClient) {
$wsdl = Bootstrap::getConfig()->getWsdlAtendeCliente();
self::$_soapClient = new \SoapClient($wsdl, array(
"trace" => Bootstrap::getConfig()->getEnv() != Config::ENV_PRODUCTION,
"exceptions" => Bootstrap::getConfig()->getEnv() != Config::ENV_PRODUCTION,
'encoding' => self::WEB_SERVICE_CHARSET,
'connection_timeout' => 60,
'cache_wsdl' => WSDL_CACHE_MEMORY,
));
}
return self::$_soapClient;
}
after
public static function getSoapClient()
{
if (!self::$_soapClient) {
$wsdl = Bootstrap::getConfig()->getWsdlAtendeCliente();
$opts = array(
'ssl' => array(
'ciphers' =>'RC4-SHA',
'verify_peer' =>false,
'verify_peer_name' =>false
)
);
// SOAP 1.1 client
$params = array (
'encoding' => self::WEB_SERVICE_CHARSET,
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_1,
'trace' => Bootstrap::getConfig()->getEnv() != Config::ENV_PRODUCTION,
'exceptions' => Bootstrap::getConfig()->getEnv() != Config::ENV_PRODUCTION,
"connection_timeout" => 180,
'stream_context' => stream_context_create($opts)
);
self::$_soapClient = new \SoapClient($wsdl, $params);
}
return self::$_soapClient;
}
Related
I'am using Docker container to create a SOAP server inside it. My external PHP script trying to get response from SOAP server, but receive an error
SOAP-ERROR: Parsing WSDL: Couldn't load from... failed to load external entity.
If I'am getting http://domain.loc:8080/api/soap?wsdl from browser, I receive a correct WSDL.
PHP script is
try {
$client = new \SoapClient('http://domain.loc:8080/api/soap?wsdl', [
'uri' => 'http://schemas.xmlsoap.org/soap/envelope/',
'style' => SOAP_RPC,
'use' => SOAP_LITERAL,
'soap_version' => SOAP_1_1,
'cache_wsdl' => WSDL_CACHE_NONE,
'connection_timeout' => 60,
'trace' => true,
'encoding' => 'UTF-8',
'exceptions' => false,
'verifypeer' => false,
'verifyhost' => false,
]);
$params = new \SoapVar('<options>...</options>', XSD_ANYXML);
$result = $client->getSOAPMethod($params);
var_dump($client->__getLastRequest());
var_dump($result);
} catch (\SoapFault $exception) {
echo $exception->getMessage();
}
Can someone explain to me where is a trouble?
My SoapClient constructor works in 7.1 but fails in 7.2 returns an error
[message:protected] => SOAP-ERROR: Parsing WSDL:
Couldn't load from 'https://domain/url.svc?singleWsdl' : failed to load external entity
The WSDL URI appears to be legitimate. I can call it from a browser and get a WSDL document back. Any ideas for what to look at?
$opts = array(
'ssl' => array(
'ciphers' => 'RC4-SHA',
'verify_peer' => false,
'verify_peer_name' => false
)
);
$params = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_1,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts)
);
try {
$this->_client = new SoapClient($wsdl, $params);
The appropriate libraries are enabled in PHP 7.2
[PHP_OPENSSL]
extension=php_openssl.dll
[PHP_SOAP]
extension=php_soap.dll
In my case, the problem was caused because the certificate was not loaded.
[openssl]
openssl.cafile="/path/to/cacert.pem"
Check if the file is exists.
I am trying connect to web service with local cert in php. Soapclient return this error: Warning: SoapClient::SoapClient(): Unable to set local cert chain file ***.p12'; Check that your cafile/capath settings include details of your certificate and its issuer in url on line 226. This cert hasn't cafile... What can i do? My code is this:
$wsdl = 'url';
try {
$soapClient = new SoapClient($wsdl, array(
"trace" => 1,
"exceptions" => false,
"endpoint" => $wsdl,
"soap_version" => SOAP_1_1 ,
"location" => "url",
'stream_context' => stream_context_create(array(
'ssl' => array(
"verify_peer" => false,
'verify_peer_name' => false,
'allow_self_signed' => false,
'ciphers' => 'DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA',
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
"local_cert" => '***.p12',
"passphrase" => ******,
)
))
)
);
echo "<pre>";
print_r($soapClient);
echo "</pre>";
} catch(Exception $e) {
echo "<pre>";
print_r($e);
echo "</pre>";
}
In Java, it is necessary use truststore but i don`t know to do equivalent in php.
Any help would be much appreciated. Thanks in advance.
I have to develop a SOAP Client, and the supplier send me this specifications:
Will be transmited using HTTPS through IP, and will be Packaged as XML documents that adjust to the diferent defnitions of XML scheme.
The Communications is synchronous, the third party should wait for response.
Each request and response will be signed.
I'm using the soapClient class from PHP, and all works fine, except when I try to use my private key to establish communication with the server:
Code: WSDL | Message: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://remoteserver/CustomerManagementService?wsdl' : failed to load external entity "https://remoteserver/CustomerManagementService?wsdl
Then I tried creating a .pem file, it contains my private key concatenated with my certificate, as I've read in: how to send SOAP request with SSL certificate in PHP?
But it still returns an error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://remoteserver:80/CustomerManager/proxy/CustomerManagementService?WSDL%2FGWTCommonResources%2Fwsdl%2FGWTCommonMessages' : failed to load external entity "http://remoteserver:80/CustomerManager/proxy/CustomerManagementService?WSDL%2FGWTCommonResources%2Fwsdl%2FGWTCommonMessages
I wonder if there is some way to get exactly the raw data that is being sent by the soapClient class of PHP. And where I must set the certificate of the supplier.
I've already tried with "$client->__getLastRequest()", but I'm getting a NULL. This is my code:
$client = new anotherSoapClient($service, array(
'local_cert' => $pem,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'soap_version' => SOAP_1_2,
'authentication'=> SOAP_AUTHENTICATION_DIGEST,
'ssl' => array(
'ciphers'=> "SHA1",
'verify_peer' => false,
'allow_self_signed' => true
),
'https' => array(
'curl_verify_ssl_peer' => false,
'curl_verify_ssl_host' => false
),
'cache_wsdl' => WSDL_CACHE_NONE,
'cache_ttl' => 86400,
'trace' => true,
'exceptions' => true,
));
// Test connection
echo BR.'Functions: <pre>';var_dump($client->__getFunctions());echo '</pre>';
$XMLrequest = $client->prepareRequest($email);
$response = $client->__anotherRequest('getCustomerInfo', $XMLrequest);
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
By the way, I'm using PHP 5.4.9 on my local machine and the server have PHP 5.3.10 and anotherSoapClient is a class who extend PHP soapClient class: PHP soapClient send custom XML
For debugging proposals your SOAP request you have to extend the SoapClient class.
class SoapClientDebug extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
// Add code to inspect/dissect/debug/adjust the XML given in $request here
// Uncomment the following line, if you actually want to do the request
// return parent::__doRequest($request, $location, $action, $version, $one_way);
}
}
And next use it in your request:
$client = new SoapClientDebug("x.wsdl");
$response = $client->__soapCall($function);
echo $client->__getLastRequest();
Hope it helps to debug your code!
You probably need to specify following SoalClient options:
$defaultEndpoint = "https://remoteserver/CustomerManagementService";
$uri = "https://remoteserver";
$client = new anotherSoapClient($service, array(
'local_cert' => $pem,
'location' => $defaultEndpoint,
'uri' => $uri,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'soap_version' => SOAP_1_2,
'authentication'=> SOAP_AUTHENTICATION_DIGEST,
'ssl' => array(
'ciphers'=> "SHA1",
'verify_peer' => false,
'allow_self_signed' => true
),
'https' => array(
'curl_verify_ssl_peer' => false,
'curl_verify_ssl_host' => false
),
'cache_wsdl' => WSDL_CACHE_NONE,
'cache_ttl' => 86400,
'trace' => true,
'exceptions' => true,
));
I'm working on consuming a .net web service in php 5.3.6. I'm using SoapClient class to make the connection. It is keep on failing with "SoapClient::__doRequest(): SSL: Connection reset by peer" and "SoapFault Object ( [message:protected] => Error Fetching http headers ".
This is happening only for the Methods/Operations. If i use $response = $objClient->__getFunctions(); and it is working fine and I'm getting the responses with out issue.
$objClient = new SoapClient("http://sample.idws.syndication.kbb.com/3.0/VehicleInformationService.svc?wsdl", array('trace' => 1, 'username' => 'xxxxxxx', 'password' => 'xxxxxxx', 'soap_version' => SOAP_1_2, 'exceptions' => true ));
PHP: php 5.3.6 with ssl soap enabled.
OS: Ubuntu 11.10
i ve been facing a similar issue the past few months.
it turned out afterall that the problem was when i used non-wsdl mode
http://php.net/manual/en/soapclient.soapclient.php
occassionally the remote server wouldn't respond on the request of the location of the wsdl.
initial non-wsdl mode
$soapx = new SoapClient(null,
array(
"trace" => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'location' => 'http://remote_wsdl_url',
'uri' => 'http://necessary_uri',
'use' => SOAP_LITERAL,
'style' => SOAP_DOCUMENT,));
turned to wsdl mode
$soapx = new SoapClient('http://remote_wsdl_url_turned_to_local',
array(
"trace" => true,
'cache_wsdl' => WSDL_CACHE_NONE,));
It seems like there is a problem on the SOAP Server end.
The best online client for debugging SOAP is soapclient
you might give it a try.
I recently came across this due to the same issue. For us the problem was with the SSL protocol being used. We had to force TLS 1.1 and everything started humming along. The key working component for us here is the 'crypto_method'.
$wsdl = 'PATH/TO/WSDL';
$url = 'http://URL_TO_SOAP_SERVICE';
$cert = 'PATH/TO/CLIENT/CERT';
$context = stream_context_create([
'ssl' => [
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false,
'cafile' => '/path/to/cafile.selfsigned'
]
]);
$params = [
'location' => $url,
'local_cert' => $cert,
'trace' => true,
'exceptions' => true,
'verifypeer' => true,
'verifyhost' => true,
'allow_self_signed' => false,
'connection_timeout' => 180,
'keep_alive' => false,
'stream_context' => $context
];
$client = new SoapClient($wsdl, $params);