Jeffha77
Jeffha77

Reputation: 169

php SoapClient Request with authentication

I'm trying to make a simple request. It works in SoapUI now trying to transfer to php.

SoapUI generated envelope(this works):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:HPD_IncidentInterface_WS">
   <soapenv:Header>
      <urn:AuthenticationInfo>
         <urn:userName>USERNAME</urn:userName>
         <urn:password>PASSWORD</urn:password>
         <!--Optional:-->
         <urn:authentication>?</urn:authentication>
         <!--Optional:-->
         <urn:locale>?</urn:locale>
         <!--Optional:-->
         <urn:timeZone>?</urn:timeZone>
      </urn:AuthenticationInfo>
   </soapenv:Header>
   <soapenv:Body>
      <urn:HelpDesk_QueryList_Service>
         <urn:Qualification></urn:Qualification>
         <urn:startRecord></urn:startRecord>
         <urn:maxLimit>10</urn:maxLimit>
      </urn:HelpDesk_QueryList_Service>
   </soapenv:Body>
</soapenv:Envelope>

The php:( I can run $fcs = $client->__getFunctions(); and get the functions but the $result function wont run. Getting no error messages)

$client = new SoapClient($url,array("userName" => $username, "password" => $password));
$result = $client->HelpDesk_QueryList_Service(array('Qualification' => '', 'startRecord' => '','maxLimit' => '10'));

Upvotes: 1

Views: 779

Answers (1)

Jeffha77
Jeffha77

Reputation: 169

Did alot more search and testing and got the write code for the connection.

$client = new SoapClient($url);
$headerbody = array('userName' => $username, 
                    'password' => $password,
                    'authentication'=>'',
                    'locale'=>'',
                    'timeZone'=>'');     
$header = new SOAPHeader($ns, 'AuthenticationInfo', $headerbody);        
$client->__setSoapHeaders($header)

Upvotes: 1

Related Questions