How to make a SOAP call with certificates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
guarriman
Forum Commoner
Posts: 44
Joined: Thu Nov 03, 2005 4:11 am

How to make a SOAP call with certificates

Post by guarriman »

Hi.

I'd like to "translate" this cURL call (which works ok) to PHP SOAP:

Code: Select all

 
curl \
  --data @file.xml \
  --header "Content-Type: text/xml; charset=utf-8"  \
  --header "SOAPAction: http://lab.webservice.com/IsValidUser" \
  -v \
  -G \
  --key key.pem \
  --cert verisign.crt \
  https://lab.webservice.com/UsersService.asmx
 
Contents of "file.xml":

Code: Select all

 
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <IsValidUser xmlns="http://lab.webservice.com/">
            <userId>555</userId>
            <lastName>Smith</lastName>
        </IsValidUser>
    </soap:Body>
</soap:Envelope>
 
I don't know how to implement it with:

Code: Select all

 
$wsdl = 'https://lab.webservice.com/UsersService.asmx'; 
$client = new SOAPClient($wsdl); 
 
$params = array(
        'userId' => '555',
        'lastName' => 'Smith'
        );
 
$response = $client->__call(....
 
Any suggestion?
guarriman
Forum Commoner
Posts: 44
Joined: Thu Nov 03, 2005 4:11 am

Re: How to make a SOAP call with certificates

Post by guarriman »

I tried with:

Code: Select all

 
$wsdl = 'https://lab.domain.com/UserService.asmx';
$local_cert = 'key-cert.pem';
$passphrase = 'foofoo';
 
$client = new SoapClient($wsdl, array('trace'=>true, 'exceptions'=>true, 'local_cert' => $local_cert, 'passphrase' => $passphrase));
 
but I get this error message:

Code: Select all

 
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://lab.domain.com/UserService.asmx' in /home/code/soap4.php on line 7
 
Post Reply