Webservice returning PHP error

Asked

Viewed 89 times

0

Hello to all my friends(as), you are well?

I have a very annoying little problem, I can’t find the problem.

I’m consuming a webservice.: Link to the Webservice

It is about the prefecture of MOGI-MIRIM/SP for issuance of NFS-e

Below is the code (XML Structure) according to the layout.

$rps = '
<GerarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd">
<Rps>
<InfDeclaracaoPrestacaoServico Id="1">
        <Rps>
            <IdentificacaoRps>
                <Numero>1</Numero>
                <Serie>12345</Serie>
                <Tipo>1</Tipo>
            </IdentificacaoRps>
            <DataEmissao>'.date('Y-m-d').'</DataEmissao>
            <Status>1</Status>
        </Rps>
        <Competencia>'.date('Y-m-d').'</Competencia>
        <Servico>
            <Valores>
                <ValorServicos>XXX</ValorServicos>
                <ValorDeducoes>0.00</ValorDeducoes>
                <ValorPis>0.00</ValorPis>
                <ValorCofins>0.00</ValorCofins>
                <ValorInss>0.00</ValorInss>
                <ValorIr>0.00</ValorIr>
                <ValorCsll>0.00</ValorCsll>
                <OutrasRetencoes>0.00</OutrasRetencoes>
                <ValorIss>XXXX</ValorIss>
                <Aliquota>XXXX</Aliquota>
                <DescontoIncondicionado>0.00</DescontoIncondicionado>
                <DescontoCondicionado>0.00</DescontoCondicionado>
            </Valores>
            <IssRetido>XX</IssRetido>
            <ItemListaServico>XXX</ItemListaServico>
            <CodigoTributacaoMunicipio>XXXXX</CodigoTributacaoMunicipio>
            <Discriminacao>XXXX</Discriminacao>
            <CodigoMunicipio>XX</CodigoMunicipio>
            <ExigibilidadeISS>X</ExigibilidadeISS>
            <MunicipioIncidencia>XX</MunicipioIncidencia>
        </Servico>
        <Prestador>
            <CpfCnpj>
                <Cnpj>XXXX</Cnpj>
            </CpfCnpj>
            <InscricaoMunicipal>XXX</InscricaoMunicipal>
        </Prestador>
        <Tomador>
            <IdentificacaoTomador>
                <CpfCnpj>
                    <Cpf>XXXX</Cpf>
                </CpfCnpj>
            </IdentificacaoTomador>
            <RazaoSocial>XXXXXXX</RazaoSocial>
            <Endereco>
                <Endereco>XXX</Endereco>
                <Numero>XXX</Numero>
                <Complemento></Complemento>
                <Bairro>XXX></Bairro>
                <CodigoMunicipio>XXXX</CodigoMunicipio>
                <Uf>XXXX</Uf>
                <Cep>XXXXX</Cep>
            </Endereco>
            <Contato>
                <Email>XXXXX</Email>
            </Contato>
        </Tomador>
        <OptanteSimplesNacional>XX</OptanteSimplesNacional>
        <IncentivoFiscal>XX</IncentivoFiscal>
    </InfDeclaracaoPrestacaoServico>
    </Rps>
</GerarNfseEnvio>';

I did not pass values to XML with the intention of Webservice returning some error missing information or something like that.

The functions of SOAP I am going through as follows (I believe the problem may be around here)

    try {
    
    
    $wsdl = 'http://abrasfmogimirim.sigbancos.com.br/servico.asmx?wsdl';
    $cliente = new SoapClient($wsdl,array('encoding'=>'ISO-8859-1'));
    
    $conexao = '<tem:nfseCabecMsg><![CDATA[<cabecalho xmlns="http://www.abrasf.org.br/nfse.xsd" versao="2.03"><versaoDados>2.03</versaoDados></cabecalho>]]></tem:nfseCabecMsg>';
                   
        
        
     $xml_nfse = '
    
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
    <tem:GerarNfse>
    '.$conexao.'
    <tem:nfseDadosMsg>
    <![CDATA[
    '.$rps.']]>
    </tem:nfseDadosMsg>
     </tem:GerarNfse>
     </soap:Body>
     </soap:Envelope>';

    $funcao = 'GerarNfse'; 
        
            
    
    $resultado = $cliente->__soapCall($funcao,array('input' => $xml_nfse));
        
    $xmlProtocolado = $resultado->outputXML;
        
    //gravar XML da NFSe com erro
    file_put_contents("NFSE/xml/nfse_com_erro_mogi.xml",utf8_encode($xml_nfse));
    
        
    
        
    
            
    } catch(Exception $erro) {
    echo $erro->getMessage();
}

The return I get from Webservice is this:

System.Web.Services.Protocols.Soapexception: Server was Unable to process request. ---> System.Nullreferenceexception: Object Reference not set to an instance of an Object. at ServicoMobile.servico.GerarNfse(String nfseCabecMsg, String nfseDadosMsg) in C:\Users\atila.junqueira\Source\Repos\ABRASF\ServicoMobile\servico.asmx.cs:line 1927 --- End of inner exception stack trace ---

But taking the same XML code and playing in Soapui 5.6.0

The return is different.O (So I think the problem is in the SOAP call in PHP)

Return of the Soapui

 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <GerarNfseResponse xmlns="http://tempuri.org/">
         <GerarNfseResult><![CDATA[<?xml version="1.0" encoding="utf-16"?><GerarNfseResposta xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.abrasf.org.br/nfse.xsd"><ListaMensagemRetorno><MensagemRetorno><Codigo>E174</Codigo><Mensagem>RPS não assinado.</Mensagem><Correcao>Assine o RPS</Correcao></MensagemRetorno></ListaMensagemRetorno></GerarNfseResposta>]]></GerarNfseResult>
      </GerarNfseResponse>
   </soap:Body>
</soap:Envelope>

I honestly do not know how to proceed, I hope you can help me my friends(as)

Thank you from the start !

Great day to you all ! ;)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.