简体   繁体   中英

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?

the following are just some comments - not an answer - to differentiate the conclusions you draw in your question so for (so this is not totally helpful just pointing out some weak spots, I know that we don't have SOAP well covered on this one on Stackoverflow, but we have it covered at least somehow)

I understand that I need to pass the parameters of the function as the index of an array.

No, this is actually not the case. Next to arrays you can also parse objects and even meta-objects. The array notation is only there for short-cutting some of these and it follows somewhat obscure rules that are not really clearly documented .

To give you an example: Please provide reference for your array statement. Provide a link where it is documented when, how and why the array has to be created the way you did.

I also understand that the values of the parameter are the corresponding values of that index of the array.

Again, even this statement is not overly wrong, you didn't outline why in this case and following which rules.

I pass the variable into the function in the WSDL but I am not getting anything.

You get something . Find out more exactly what. What is the exception message for example.

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
    )
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM