Reputation: 11
I have sample SOAP request message like below,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v="http://incometaxindiaefiling.gov.in/ws/ds/common/v_1_0">
<soapenv:Header/>
<soapenv:Body>
<v:DITWSAuthInfoEle>
<v:userID>xxxxxxxxxx</v:userID>
<v:password>xxxxxxxxxx</v:password>
<v:certChain>xxxxxxxxxx</v:certChain>
<v:signature>xxxxxxxxxx</v:signature>
</v:DITWSAuthInfoEle>
</soapenv:Body>
</soapenv:Envelope>
I got the authentication details and xyz.pfx file. By using this file I have got the XML signature representation and added that to the SOAP request. Here my question is how do I acquire certChain (Certificate Chain) and how to add that to the SOAP request. Any one can help me on this?
Upvotes: 1
Views: 2132
Reputation: 8484
Using SoapClient, the server certificate is validated by default and you can send a client certificate like this:
$protected_url = "https://my-server/?wsdl";
$my_cert_file = "/my/path/to/mycert.pem";
$client = new SoapClient($protected_url, array('local_cert', $my_cert_file) );
Or, if your certfificate requires a passphrase:
$client = new SoapClient("https://url.to.service/", array(
'local_cert' => 'client_certificate.pem', 'passphrase' => 'PASSPHRASE',
'cache_wsdl' => WSDL_CACHE_NONE
));
Then, if you want to see the xml, you can use __getLastRequest
Check also this detailed answer on how to use SOAP with certificates on PHP:
Creating a PHP SOAP request with a certificate
Upvotes: 1