2017-12-15 18 views
0

내 일상적인 작품 잘 HTTPS에 요청을 보낼 수 없습니다 만, 최근에는 HTTPS로 업그레이드하는 데 필요한 더 이상 노력하고 있습니다. 나는 무슨 일이 일어나고 있는지 전혀 모르며 웹상에서 많은 다른 코드를 시도했다.는 soapclient 및 http 프로토콜에 따라

오류 메시지가 catch되지 않은 SOAPFault의 예외입니다 : [HTTP] 호스트에 연결할 수 없습니다 [...] 내가 PHP를 v.5.6를 사용하고 있지만,이 솔루션은 5.3도 작동하는 경우 것이 바람직 할 것이다

. 37. 여기

, 당신의 서버가 openssl 라이브러리가있는 경우

<?php 
error_reporting(E_ERROR | E_PARSE); 
ini_set('display_errors', 1); 
ini_set('soap.wsdl_cache_enabled',0); 
ini_set('soap.wsdl_cache_ttl',0); 
ini_set('default_socket_timeout', 1000); 


$url_wsdl ="https://exampleservice.cls?WSDL=1&CacheUserName=myusername&CachePassword=mypassword&CacheNoRedirect=1"; 


print 'Starting routine'; 
//logging in 
$curl = curl_init($url_wsdl); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_HEADER, 1); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($curl, CURLOPT_SSLVERSION, 3); 


// get cookies 
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result, $matches); 
$cookies = array(); 
foreach($matches[1] as $item) { 
    parse_str($item, $cookie); 
    $cookies = array_merge($cookies, $cookie); 
} 
curl_close($curl); 
print 'Curl....ok. Cookies ok<br>'; 


$options = array(
    'trace'    => 1 
    , 'cache_wsdl'  => WSDL_CACHE_NONE 
    , 'user_agent'  => 'PHP WS' 
    , 'ssl_method' => SOAP_SSL_METHOD_SSLv3 

); 

$soapClient = new SoapClient($url_wsdl,$options ); 
print 'SoapClient....ok<br>'; 

//sending cookies to soapclient 
foreach ($cookies as $name => $value) { 
    print '------> sending cookies: '. $value . '<br>'; 
    $soapClient->__setCookie($name, $value); 
} 
print 'SetCookies....ok<br>'; 


$data = array('TesteInterface' => array('Request' => array('Mensagem' => 'teste'))); 
$response = $soapClient->__soapCall("TesteInterface",$data); 
print 'SoapCall....ok<br>'; 

print 'Response:<br>'; 
print_r($response); 


?> 

답변

0

:

그 후에 당신은 당신의 WSDL $options을 향상시킬 수 있습니다. 그것은 https 주소가 없음을 가리 켰습니다. 이제는 작동합니다.

0

먼저 체크를 도와 주셔서 감사합니다 내 코드입니다, 다음은 OpenSSL의 PHP 확장에 대한 확인이 활성화된다. 내가 수동으로 엔드 포인트를 설정하여 그것을 알아 냈어요

$options = [ 
      'trace' => 1, 
      'exceptions' => true, 
      'cache_wsdl' => WSDL_CACHE_NONE, 
      'soap_version' => SOAP_1_2, 
      'encoding' => 'UTF-8', 
      'connection_timeout' => 60, //or other 
      'keep_alive' => false, 
      'ssl_method' => SOAP_SSL_METHOD_TLS, //or other 
      'stream_context' => stream_context_create([ 
       'ssl' => [ 
        'verify_peer' => false, 
        'verify_peer_name' => false, 
        'allow_self_signed' => true, 
       ], 
      ]), 
     ]; 
+0

openssl이 phpinfo()에서 활성화되었습니다. 옵션 섹션을 코드로 개선했지만 여전히 작동하지 않습니다. – danielarend

+0

서버의 openssl은 어떻습니까? 어떤 버전이 있습니까? – Edwin

+0

openssl v 1.0.2k-fips – danielarend