Php SoapClient option stream_context

Möchte ich eine Dritte Partei, die web-service. Der web service muss ich die Verbindung mit HTTPS. Mein problem ist, dass für den Entwicklungsprozess ich habe einen test-api mit einem ungültigen Zertifikat. Ich würde gerne SoapClient nicht zu prüfen, ob der server das Zertifikat. Hier ist die Art und Weise habe ich versucht:

$opts = array(
    'ssl'   => array(
            'verify_peer'          => false
        ),
    'https' => array(
            'curl_verify_ssl_peer'  => false,
            'curl_verify_ssl_host'  => false
     )
);
$streamContext = stream_context_create($opts);
$client = new SoapClient("https://urlToSoapWs",
  array(
      'login'             => 'user',
      'password'          => 'pwd',
      'authentication'    => SOAP_AUTHENTICATION_BASIC,
      'local_cert'        => file_get_contents('C:/somelocation/1.pem'),
      'passphrase'        => 'passphrase',
      'stream_context'    => $streamContext
  ));

Ich habe auch versucht mit CURL und gearbeitet! Aber ich will SoapClient. Sie können den code mit CURL unter:

//create a new cURL resource
$ch = curl_init("https://urlToSoapWs");

//setting the request type to POST: 
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); 
//setting the authorization method to BASIC: 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
//supplying your credentials: 
curl_setopt($ch, CURLOPT_USERPWD, "user:pwd");

$body = "<SOAP-ENV:Envelope>somexmlhere</SOAP-ENV:Envelope>";
//filling the request body with your SOAP message: 
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

//configuring cURL not to verify the server certificate: 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLCERT, "pathToTheCertificatePemFile");
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "pwd");
//curl_setopt($ch, CURLOPT_SSLCERTTYPE, "PEM");

curl_setopt($ch, CURLOPT_SSLKEY, "pathTotheKeyFile");
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "pwd");

//telling cURL to return the HTTP response body as operation result 
//value when calling curl_exec: 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
//calling cURL and saving the SOAP response message in a variable which 
//contains a string like "<SOAP-ENV:Envelope ...>...</SOAP-ENV:Envelope>": 


$result = curl_exec($ch);
//closing cURL: 
curl_close($ch);

Wenn Sie gefunden haben, die Fehler in der code, den ich über den SoapClient poste es bitte.
Danke.

was ist der genaue Fehler, den Sie haben ??
Dies ist die Fehlermeldung von der PHP-error-log: [28-Mar-2012 18:00:54] PHP Warning: SoapClient::SoapClient() [<a href='soapclient.soapclient'>soapclient.soapclient</a>]: SSL-Vorgang ist fehlgeschlagen mit Fehlercode 1. OpenSSL-Fehler Meldungen: Fehler:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in C:\wamp\www\FDGGwsTest\test.php auf der Linie 51
Funktioniert der remote-host benötigen-Verbindung von einer bestimmten IP-Adresse ???
Nein. Sie können es von jedem computer aus.
Hey ich habe das gleiche problem, hast du eine Lösung finden?

InformationsquelleAutor Gergo Boros | 2012-03-28

Schreibe einen Kommentar