SOAP-ERROR:解析WSDL:无法加载

时间:2013-06-27 08:38:37

标签: php symfony soap wsdl

我是salesforce api的肥皂服务新手。我在我的symfony2.2项目中创建服务,但是当我尝试运行它时,请告诉我:

SOAP-ERROR: Parsing WSDL: Couldn't load from '/var/www/XXX/src/xxxxx/XXBundle/ServicesResources/wsdl/soap/enterprise.wsdl' : failed to load external entity "/var/www/xxx/src/xxxxx/XXBundle/ServicesResources/wsdl/soap/enterprise.wsdl"

我不知道为什么。

我的服务.php

use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use xxxxx\XXBundle\Entity\User;
use xxxxx\XXBundle\Entity\SoapClient;

class SalesforceService
{

/**
 * @param string $salesforce_wsdl
 */
public $salesforce_wsdl;
/**
 * @param string $salesforce_user
 */
public $salesforce_username;
/**
 * @param string $salesforce_password
 */
public $salesforce_password;
/**
 * @param string $salesforce_token
 */
public $salesforce_token;
/**
 * @var \Doctrine\ORM\EntityManager
 */
protected $em;

public function __construct($salesforce_wsdl, $salesforce_username, $salesforce_password, $salesforce_token, EntityManager $em )
{
   $this->salesforce_wsdl = $salesforce_wsdl;
   $this->salesforce_username = $salesforce_username;
   $this->salesforce_password = $salesforce_password;
   $this->salesforce_token = $salesforce_token;
   $this->em = $em;
}

/**
 * create lead 
 */
public function createLead($user)
{
        $client = new SoapClient(__DIR__ . 'Resources/wsdl/soap/enterprise.wsdl');

        $sflogin = $client->login(array('username'=>$this->salesforce_username,
                               'password'=>$this->salesforce_password));

        $result = $sflogin->return;

        //In xml file Lead exit
        $describe = $client->describeSObjects(array('Lead'));//die;

        //Create New Lead
        $leadFirstName = $user->getFirstname();
        $leadLastName = $user->getLastname();
        $leadCompany = $user->getCompany();
        $leadEmail = $user->getEmail();

        //Creating the Lead Object
        $lead = new stdClass;
        $lead->type = 'Lead';
        $lead->fields = array(
          'FirstName' => $leadFirstName,
          'LastName' => $leadLastName,
          'Company' => $leadCompany,
          'Email' => $leadEmail
        );

        //Submitting the Lead to Salesforce
        $result = $client->create(array($lead), 'Lead');

}

我的SoapClient.php

namespace xxxxx\XXBundle\Entity;


/**
 * SOAP client used for the Salesforce API client
 *
 */
class SoapClient extends \SoapClient
{
/**
 * SOAP types derived from WSDL
 *
 * @var array
 */
protected $types;

/**
 * Retrieve SOAP types from the WSDL and parse them
 *
 * @return array    Array of types and their properties
 */
public function getSoapTypes()
{
    if (null === $this->types) {

        $soapTypes = $this->__getTypes();
        foreach ($soapTypes as $soapType) {
            $lines = explode("\n", $soapType);
            if (!preg_match('/struct (.*) {/', $lines[0], $matches)) {
                continue;
            }
            $typeName = $matches[1];

            foreach (array_slice($lines, 1) as $line) {
                if ($line == '}') {
                    continue;
                }
                preg_match('/\s* (.*) (.*);/', $line, $matches);
                $properties[$matches[2]] = $matches[1];
            }
            $this->types[$typeName] = $properties;
        }
    }

    return $this->types;
}

/**
 * Get a SOAP type’s elements
 *
 * @param string $type Object name
 * @return array       Elements for the type
 */

/**
 * Get SOAP elements for a complexType
 *
 * @param string $complexType Name of SOAP complexType
 *
 * @return array  Names of elements and their types
 */
public function getSoapElements($complexType)
{
    $types = $this->getSoapTypes();
    if (isset($types[$complexType])) {
        return $types[$complexType];
    }
}

/**
 * Get a SOAP type’s element
 *
 * @param string $complexType Name of SOAP complexType
 * @param string $element     Name of element belonging to SOAP complexType
 *
 * @return string
 */
public function getSoapElementType($complexType, $element)
{
    $elements = $this->getSoapElements($complexType);
    if ($elements && isset($elements[$element])) {
        return $elements[$element];
    }
}
}

任何人都知道我在做什么部分或我的代码中的错误是什么?

0 个答案:

没有答案