Good afternoon, I have the following code trying to access the ISS webservice of the city of Curitiba:
<?php
$xml_data = '<?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>
<ConsultarNfse xmlns="http://www.e-governeapps2.com.br/">
<ConsultarNfseEnvio>
<Prestador>
<Cnpj>1312313123123</Cnpj>
<InscricaoMunicipal>13123123</InscricaoMunicipal>
</Prestador>
</ConsultarNfseEnvio>
</ConsultarNfse>
</soap:Body>
</soap:Envelope>';
$url = "https://isscuritiba.curitiba.pr.gov.br/Iss.NfseWebService/nfsews.asmx?WSDL";
$headers = array(
"POST /nfse_ws/nfsews.asmx HTTP/1.1",
"Host: pilotoisscuritiba.curitiba.pr.gov.br",
"Content-Type: text/xml; charset=utf-8",
"SOAPAction: \"http://www.e-governeapps2.com.br/ConsultarNfse\"",
"Content-length: " . strlen($xml_data)
);
$xml = $xml_data;
$ch = curl_init();
$soapUser = "usuário_iss";
$soapPassword = "senha_iss";
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . '\Pref_ISS_Cert.pem');
curl_setopt($ch, CURLOPT_USERPWD, $soapUser . ":" . $soapPassword);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSH_PRIVATE_KEYFILE, getcwd() . '\Pref_ISS_Cert.pfx');
curl_setopt($ch, CURLOPT_SSLCERT, getcwd() . '\Pref_ISS_Cert.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "easy2017");
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$ch_result = curl_exec($ch);
print_r($ch_result);
curl_close($ch);
?>
This code does not allow me to login site, I can send the xml, but it does not give me permission to receive the return XML, I get the following message:
Server Error 403 - Forbidden: access is denied. You do not have permission to view this directory or page using the credentials provided.
Context:
I generated the .pfx certificate from the test ISS website, and I linked the certificate to a user, until then, okay, I created the .pem certificate because I am not able to use only .pfx via the openSSL command line, / p>
1 - How to get this return with soap php by sending an xml using .pfx certificate?
2 - Is there another way to do this?