使用SOAP连接到web服务PHP


Connecting to web service using SOAP & PHP

我正在尝试使用PHP的soap客户端连接到web服务,我可以成功地使用Visual Studio,按下F5并在本地运行页面,这是一种治疗。

一旦我上传完全相同的文件到我的apache web主机,我不断得到错误:"未能加载外部实体"。

这是我的代码与凭据和url取出…

任何想法?

<?php
header("Access-Control-Allow-Origin: http://example.com");
header("Access-Control-Request-Method: GET,POST");
ini_set('display_errors', true);
ini_set("soap.wsdl_cache_enabled", "0");
error_reporting(E_ALL);

try
{
$soapclient = new SoapClient('http://example.com');
$params = array ('SystemID' => 'testID','Username' => 'test', 'Password' => 'test');
$response = $soapclient->GetEngineerList($params);
print_r($response);
}
catch(SoapFault $e)
{
    print_r($e);
}

字符串不会被读取两次,并在单引号中解析

$soapclient = new SoapClient('$url');

$soapclient = new SoapClient($url);

也……你有$url = ";任何地方?

更新1

请尝试使用基本授权访问您的wsdl:

$login = 'bert';
$password = 'berts password';
$client = new SoapClient(
  'http://' . urlencode($login) . ':' . urlencode($password) . '@www.server.com/path/to/wsdl',
  array(
    'login' => $login,
    'password' => $password
  )
);