0

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

Fabian
  • 177
  • 1
  • 14
  • Has no one an idea? I still don't get what my mistake is. I can send a request with SoapUI, but still don't have any idea how I have to configure this in php. I'm searching google all day long and tried everything I could find. Thanks for every responds – Fabian Aug 10 '17 at 17:44
  • I also added my SoapUI code. I hope that helps. – Fabian Aug 11 '17 at 15:53
  • The line `$authParams = array('AuthenticationParameters' => $aParams);` should maybe become `$authParams = array('aParm' => $aParams);` Also can you provide result of `$soap->__getFunctions()` and `$soap->__getTypes()` - these will provide a complete picture of the API and what the request should look like. – Kris Peeling Aug 14 '17 at 20:24
  • @KrisPeeling Both are "null" – Fabian Aug 15 '17 at 09:44
  • ok getFunctions() isn't going to work because the soapclient can't parse the wsdl. Are you sure the web service is soap version 1.2? Did you try changing it to SOAP_1_1 to see if the wsdl will parse? Are you 100% sure the WSDL is abstract? – Kris Peeling Aug 15 '17 at 14:47
  • Yes i tried that already. I guess i can't use the wdsl because it's an abstract wdsl. – Fabian Aug 15 '17 at 14:56
  • @KrisPeeling I'm pretty sure its abstract. This is a part of the WSDL: ` – Fabian Aug 16 '17 at 07:09
  • It looks like there is an error in the php implementation of soap and wsdl, if the wsdl-file is abstract. – Fabian Sep 21 '17 at 07:31

0 Answers0