i try to call a SOAP function with PHP. But I always get back "Authentication parameter(s) missing." and "looks like we got no XML document". So I guess I'm doing something wrong with the parameters.
This ist what i'm doing:
PHP:
<?php
$options = array(
'location'=>'xxx',
'uri'=>'xxx',
'style'=>SOAP_RPC,
'use'=>SOAP_ENCODED,
'soap_version'=>SOAP_1_2,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout'=>60,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=>true
);
//AuthenticationParameters
$aParams = array(
'accountName' => 'xxx',
'username' => 'xxx',
'userName' => 'xxx',
'apiKey' => 'xxx'
);
$authParams = array('AuthenticationParameters' => $aParams);
try {
$soap = new MySoapClient(null, $options);
$data = $soap->createSession($authParams);
}
catch(Exception $e) {
die($e->getMessage());
}
var_dump($data);
die;
class MySoapClient extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
// parse $response, extract the multipart messages and so on
//this part removes stuff
$start=strpos($response,'<?xml');
$end=strrpos($response,'>');
$response_string=substr($response,$start,$end-$start+1);
return($response_string);
}
}
?>
This ist a part of the XML wsdl:definitions:
<wsdl:message name="createSession">
<wsdl:part element="tns:createSession" name="parameters">
</wsdl:part>
</wsdl:message>
...
...
...
<xs:element name="createSession" type="createSession" />
<xs:complexType name="createSession">
<xs:sequence>
<xs:element minOccurs="0" name="aParm"
type="ns0:AuthenticationParameters" />
<xs:element minOccurs="0" name="gParm"
type="ns0:GeneralParameters" />
</xs:sequence>
</xs:complexType>
...
...
...
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="unqualified"
targetNamespace="http://xxx/parameters">
<import namespace="http://www.w3.org/2001/XMLSchema-instance" />
<xs:complexType name="AuthenticationParameters">
<xs:complexContent>
<xs:extension base="tns:ParameterBase">
<xs:sequence>
<xs:element default="" minOccurs="0" name="accountName"
nillable="true" type="xs:string" />
<xs:element default="" minOccurs="0" name="sessionToken"
nillable="true" type="xs:string" />
<xs:element default="" minOccurs="0" name="userName"
nillable="true" type="xs:string" />
<xs:element default="" minOccurs="0" name="password"
nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="apiKey" nillable="true"
type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
I don't get how I have to send the parameters to the function.
I also tried to add the WSDL to the SoapClient but it looks like its an abstract WDSL(SOAP-ERROR: Parsing WSDL: Could not find any usable binding services in WSD):
$wsdl = 'https://xxxxxxxxxx?WSDL';
$soap = new SoapClient($wsdl, $options);
SOAP-ERROR: Parsing WSDL: Could not find any usable binding services in WSDL.
This is how it looks in SoapUI:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="xxxxxxx">
<soap:Header/>
<soap:Body>
<ser:showObject>
<!--Optional:-->
<aParm>
<accountName>xxx</accountName>
<!--Optional:-->
<sessionToken/>
<!--Optional:-->
<userName>xxx</userName>
<!--Optional:-->
<password>xxxx</password>
</aParm>
<!--Optional:-->
<gParm>
</gParm>
<!--Optional:-->
</ser:showObject>
</soap:Body>
</soap:Envelope>
I hope someone can help me.
Thanks,
best regards