Search code examples
phpsoapwsdlsoap-client

SOAP Request Over PHP


I tried to create a request for SOAP wsdl, the request & response of the request is:

SOAP request:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sub="http://subscriberprovisioning.ws.nvsmx.domain.com/">
<soap:Header/><soap:Body>
<sub:wsGetSubscriberProfileByID><subscriberID>123456789</subscriberID><alternateID></alternateID><parameter1></parameter1><parameter2></parameter2>
</sub:wsGetSubscriberProfileByID></soap:Body></soap:Envelope>

Response

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:wsGetSubscriberProfileByIDResponse xmlns:ns2="http://subscriberprovisioning.ws.nvsmx.domain.com/">
<return><responseCode>200</responseCode><responseMessage>SUCCESS</responseMessage><subscriberProfile>
<entry><key>SUBSCRIBER_IDENTITY</key><value>123456789</value></entry>
</subscriberProfile></return></ns2:wsGetSubscriberProfileByIDResponse></soap:Body></soap:Envelope>

I am using php to create the request the code look like this:

request.php

<?php

$client = new SoapClient("http://ipnumber:1988/services/Subscriber?wsdl"); 





$param = array('subscriberId' => '123456789');
$response = $client->wsGetSubscriberProfileByID    ($param);

var_dump($response);

within above code the the 'subscriberId' => '123456789' doesn't pass to the wsdl and I got the missing parameter response. I tested also using SOAP UI, and it working. Any suggestion for my php code.

Thanks


Solution

  • Finally it got working within this code:

    try{
    $soapclient = new SoapClient('http://ipnumber:1988//services/Subscriber?wsdl');
    $param=array('subscriberID'=>'123456789');
    $response =$soapclient->wsGetSubscriberProfileByID($param);
    var_dump($response);
    echo '<br><br><br>';
    $array = json_decode(json_encode($response), true);
    print_r($array);
     echo '<br><br><br>';
          echo '<br><br><br>';
        foreach($array as $item) {
            echo '<pre>'; var_dump($item);
        }  
    }catch(Exception $e){
        echo $e->getMessage();
    }