Search code examples
phpxmlsoapwsdl

How to pass WSDL functions in this PHP program using SOAP


I understand that I need to pass the parameters of the function as the index of an array. I also understand that the values of the parameter are the corresponding values of that index of the array. But I cannot get my function to work. I pass the variable into the function in the WSDL but I am not getting anything.

Here is my PHP code:

try{
    $soap_client = new SoapClient("https://foo.example.com:8443/current/bar?wsdl");
    $log_in = array(
        "iwsUsername"    => "username", 
        "iwsSecretKey"   => "secretKey",
        "caller"         => "JohnDoe", 
        "callerPassword" => "password"
    );
    //passing values into the function parameters above
    $request = $soap_client->authenticatedPing($log_in);
    echo $request->authenticatedPing;
} catch(SoapFault $exception){
    echo '?????';
}

These are obviously fake values for security purposes but you get the idea.

Here is the WSDL for this function:

 <wsdl:operation name="authenticatedPing">
   <soap12:operation soapAction="" style="rpc"/>
   <wsdl:input name="authenticatedPing">
     <soap12:body namespace="http://www.example.com" use="literal"/>
   </wsdl:input>
   <wsdl:output name="authenticatedPingResponse">
     <soap12:body namespace="http://www.example.com" use="literal"/>
   </wsdl:output>

What am I doing wrong?


Solution

  • The non-WSDL form worked. Thank you for your comments

    $client = new SoapClient(
        null,
        array(
            'location' => "https://************.com:*******/*****-=/iws",
            'soap_version' => SOAP_1_2,
            'uri' =>'http://www.*******.com',
            'style' => SOAP_RPC,
            'use' => SOAP_LITERAL
        )
    );