1
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 allow me to receive the return xml, I receive the following message:
403 Server Error - Prohibited: Access denied. You are not allowed to display this river or gina direct using credentials provided.
Context:
I managed the . pfx certificate through the ISS testing website, and linked the certificate to a user, so far ok, I created the certificate. pem because I am not able to use only . pfx via openssl command line, doubts:
1 - How to receive this return with Soap php by sending an xml using certificate . pfx ?
2 - There is another way to do this?