2013-05-08 41 views
1

我试图通过在本地运行php脚本通过远程服务器连接web服务。我正在阅读整个文件,它不显示任何内容。当我在浏览器中尝试使用此URL时,它会提取数据。我将权限改为755,并启用了allow_url_fopen,php_openssl.dll。任何建议,将不胜感激无法通过远程连接到web服务使用php脚本

我的代码在这里:

$ URL = 'http://mail.abc.com:10139/webservices2.0.asmx?WSDL';

echo file_get_contents($ url);


为想不出连接到主机时,我试着打肥皂在远程服务器上,我得到一个错误。有什么建议么?

代码在这里:

<?php 


      ini_set('soap.wsdl_cache_enabled',0); 
         ini_set('soap.wsdl_cache_ttl',0); 

         $url="http://mail.abc.com:10139/webservices2.0.asmx?WSDL"; 

        $client = new SoapClient (null , array ('location' => "http://mail.abc.com:10139/webservices2.0.asmx?WSDL" , 
              'uri'  => "http://mail.abc.com:10139/webservices2.0/")) ; 
    //echo file_get_contents($url); //Unable to read from url 

     $operator="xxxx"; 
     $operatorPassword="yyyy"; 
     $companyId="abc"; 
     $companyPassword=" "; 
     $languageCode=""; 

     try 
     { 
      $response =$client->__soapCall("logon,array('Operator' => $operator, 'OperatorPassword' => $operatorPassword, 'CompanyId'=> $companyId, 'CompanyPassword' => $companyPassword, 'LanguageCode' => $languageCode)); 
     print_r($response); 
     } 
     catch (SoapFault $result) { 
      echo "<pre>"; 
     print_r($result); 
     echo "</pre>"; 
     } 


    ?> 

回答

1

我得到一个错误,当我尝试访问的页面,你确定它的工作原理?

无论如何,我会推荐这代码一起工作:

function get_data($url) { 

$ch = curl_init(); 
    $timeout = 5; 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); 
    curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
    $data = curl_exec($ch); 
    curl_close($ch); 
    return $data; 
} 

$variablee = get_data('http://example.com'); 
echo $variablee; 
+0

感谢响应。我会尝试一下并回复你。 – Nikisha 2013-05-08 13:23:15

+0

我试过上面的代码,它不接受我在远程服务器上的ERP应用程序的URL,但与其他网站很好地工作。在我的服务器应用程序中是否有任何错误@ Daniel Chernenkov – Nikisha 2013-05-10 14:21:57

+0

@ user2345099您在自己的服务器上运行此代码,因此您需要使用本地地址。它可以是'127.0.0.1'或'localhost' – 2013-05-10 15:29:01

相关问题