As usage of the Eloqua API quickly rises, we continue to receive great feedback from those building on the Eloqua platform. It has recently come to our attention that PHP and the EloquaService WSDL don't play nice together!

 

While the other Eloqua WSDL files work fine, a parsing issue with PHP's native SOAP library causes conflicts with overlapping names.

 

Upon further testing, we were able to make things work by splitting the WSDL document into atomic methods - 1 WSDL doc for each method.

 

So far, the following WSDLs have been generated for EloquaService (attached to this post):

 

  • ListEntityTypes()
  • DynamicEntityService()

 

If you are attempting to use PHP to consume the EloquaService WSDL, and are running into problems:

1. Let us know which web methods you need - and we can generate WSDL documents for them.

2. Be assured that the existing SOAP API (version 1.2) will not change - such that you can rely on local copies of the WSDL documents (generated in step 1).

3. Utilize the SOAP lib extension class : ElqSoapClient

4. Be aware that any changes to our SOAP API (1.2) will require us to provide a new version (1.3) so that we don't alter/break your local WSDL copies.

 

The sample code provided below uses native PHP SOAP libraries, with minor extensions. This basically sets up the SOAP headers for the request (using PHP's SOAP header class).

 

<?php
print "SOAP API Sample - ListEntityTypes()<p>";

 

###
# Extension of SoapClient - Eloqua SOAP API
##
class ElqSoapClient extends SoapClient {

 

public function __construct($wsdl, $username, $password) {

# WSSE Security Namespace
$wsSecurityNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

# SOAP Username and Password variables
$soapVarUser = new SoapVar($username, XSD_STRING, NULL, $wsSecurityNS, NULL, $wsSecurityNS);
$soapVarPass = new SoapVar($password, XSD_STRING, NULL, $wsSecurityNS, NULL, $wsSecurityNS);

# WSSE Authentication SOAP var
$WsAuthentication = new WsAuthentication($soapVarUser, $soapVarPass);
$soapVarWsAuthentication = new SoapVar($WsAuthentication, SOAP_ENC_OBJECT, NULL, $wsSecurityNS, 'UsernameToken', $wsSecurityNS);

# WSSE Authentication Token
$WsToken = new WsToken($soapVarWsAuthentication);

# Authentication Headers
$soapVarWsToken = new SoapVar($WsToken, SOAP_ENC_OBJECT, NULL, $wsSecurityNS, 'UsernameToken', $wsSecurityNS);
$soapVarHeaderVal=new SoapVar($soapVarWsToken, SOAP_ENC_OBJECT, NULL, $wsSecurityNS, 'Security', $wsSecurityNS);
$soapVarWsHeader = new SoapHeader($wsSecurityNS, 'Security', $soapVarHeaderVal, true);

# Create client
parent::__construct($wsdl);
parent::__setSoapHeaders(array($soapVarWsHeader));

}

}

##
# Sample Code - List Entity Types
##

 

# WSDL document - List Entity Service
$wsdl = "/Users/fredericksakr/Sites/listEntityService.xml";

 

# Client Credentials
$username = "Eloqua\Fred.Sakr";
$password = "#######";

 

# Instantiate a new instance of the Soap client
$client = new ElqSoapClient($wsdl, $username, $password);

 

# List web service methods
print_r ($client->__getFunctions());

 

# Invoke SOAP Request : ListEntityTypes()
try
{
$response = $client->ListEntityTypes(array());
}
catch (Exception $e)
{
print ($e->getMessage());
}

 

 

# Print the response
print_r($response);


### Web Service Helper classes

###

# Authentication helper class
##
class WsAuthentication {
private $Username;
private $Password;

 

 

function __construct($username, $password)
{
$this->Username=$username;
$this->Password=$password;
}

 

}

 

###
# Web Service Token helper class
##
class WsToken {
private $UsernameToken;

function __construct ($innerVal)
{
$this->UsernameToken = $innerVal;
}


}
?>