1

Estou com um problema com "SOAP" confesso que sou bem leigo, já dei uma olhada na internet e não consegui identificar onde esta o problema, será que alguém conseguiria dar uma força?

Assim esta o SOAP

<?
try {
    $wsdl = 'https://limeira.iibr.com.br/api/soap/homologacao_notafiscal.php?wsdl';
    $cliente = new SoapClient($wsdl);
    
    $funcao = 'GerarNfse'; 
    
    
    $argumento = array($funcao => array(
    'Rps' => '96',
    'Integridade' => '247ea05be6cf0a7348cdd239d91c90de93b2a6d220d004e1222fc0c35b8cdc5711aa2a080004ebc260cb4d084e255c51757b1c4d56625f532803a41135c2e886' 
    ));
    echo ['InformacoesNfse'],['NumeroRps'],['SerieRps'],['Prestador'],['NumeroNfse'],['SerieNfse'],['CodigoVerificacao'],['LinkNfse'];
    $resultado = $cliente->__soapCall($funcao,$argumento);// array($funcao => $array_objeto),$cabecalho);
    //echo ['GerarNfseResposta'],['InformacoesNfse'];
} catch(Exception $erro) {
    echo $erro->getMessage();
}

Arquivo de envio

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');

    require "soap_envio_nfse.php";
    
    
        $token       = 'TLXX4JN38KXTRNSEAJYYEA==';//S1ZhMzNqOXRjT1RnakFTWHlvT0xtNENCQS9SNWwxUjRnQnRrbzlEOCs1dz0=';
        $tag         = '
        <GerarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd">
                <Rps>
                    <InfDeclaracaoPrestacaoServico Id="1">
                      <Rps>
                        <IdentificacaoRps>
                          <Numero>96</Numero>
                          <Serie>85236</Serie>
                          <Tipo>1</Tipo>
                        </IdentificacaoRps>
                        <DataEmissao>2019-07-04</DataEmissao>
                        <Status>1</Status>
                      </Rps>
                      <Competencia>2019-07-04</Competencia>
                      <Servico>
                        <Valores>
                          <ValorServicos>2358.77</ValorServicos>
                          <ValorDeducoes>0</ValorDeducoes>
                          <ValorPis>0</ValorPis>
                          <ValorCofins>0</ValorCofins>
                          <ValorInss>0</ValorInss>
                          <ValorIr>0</ValorIr>
                          <ValorCsll>0</ValorCsll>
                          <OutrasRetencoes>0</OutrasRetencoes>
                          <Aliquota>0</Aliquota>
                          <DescontoIncondicionado>0</DescontoIncondicionado>
                          <DescontoCondicionado>0</DescontoCondicionado>
                        </Valores>
                        <IssRetido>1</IssRetido>
                        <ResponsavelRetencao>1</ResponsavelRetencao>
                        <ItemListaServico>07.02</ItemListaServico>
                        <CodigoTributacaoMunicipio>233030500</CodigoTributacaoMunicipio>
                        <Discriminacao>TESTANDO RPS DISCRIMINAÇÃO</Discriminacao>
                        <CodigoMunicipio>3526902</CodigoMunicipio>
                      </Servico>
                      <Prestador>
                        <CpfCnpj>
                          <Cnpj>88888888888888</Cnpj>
                        </CpfCnpj>
                        <InscricaoMunicipal>123456</InscricaoMunicipal>
                      </Prestador>
                      <TomadorServico>
                        <IdentificacaoTomador>
                          <CpfCnpj>
                            <Cnpj>55555555555555</Cnpj>
                          </CpfCnpj>
                        </IdentificacaoTomador>
                        <RazaoSocial>Dorotheo</RazaoSocial>
                        <Endereco>
                          <Endereco>Rua Japão</Endereco>
                          <Numero>2</Numero>
                          <Complemento>TESTE RPS</Complemento>
                          <Bairro>Jaragua</Bairro>
                          <CodigoMunicipio>3550704</CodigoMunicipio>
                          <Uf>SP</Uf>
                          <Cep>11600318</Cep>
                        </Endereco>
                        <Contato>
                          <Telefone>12345678901</Telefone>
                          <Email>[email protected]</Email>
                        </Contato>
                        <AtualizaTomador>2</AtualizaTomador>
                        <TomadorExterior>2</TomadorExterior>
                      </TomadorServico>
                      <InformacoesComplementares>TESTANDO RPS</InformacoesComplementares>
                    </InfDeclaracaoPrestacaoServico>
                </Rps>
                <Integridade>247ea05be6cf0a7348cdd239d91c90de93b2a6d220d004e1222fc0c35b8cdc5711aa2a080004ebc260cb4d084e255c51757b1c4d56625f532803a41135c2e886</Integridade>
            </GerarNfseEnvio>';
    
        $tag = preg_replace('/[^\x20-\x7E]+/','',$tag);
        $tag = preg_replace('/[ ]+/','',$tag);
    
    
        $integridade = hash('sha512',$tag.$token);
    
        
    
            
    
        $xml=$integridade->GerarNfse();
        echo $xml;
        
        
        file_put_contents('xml/nfse_teste_01.xml',$xml);

Arquivo WSDL

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ws="http://nfse.abrasf.org.br" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="nfse" targetNamespace="http://nfse.abrasf.org.br">
  <wsdl:types>
    <xsd:schema targetNamespace="http://nfse.abrasf.org.br">
        <xsd:complexType name="input">
            <xsd:sequence>
                <xsd:element name="nfseCabecMsg" type="xsd:string" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="nfseDadosMsg" type="xsd:string" minOccurs="1" maxOccurs="1"/>
            </xsd:sequence>
        </xsd:complexType>
        <xsd:complexType name="output">
            <xsd:sequence>
                <xsd:element name="outputXML" type="xsd:string" />
            </xsd:sequence>
        </xsd:complexType>
        <xsd:element name="CancelarNfseRequest" type="ws:input" />
        <xsd:element name="CancelarNfseResponse" type="ws:output" />
        <xsd:element name="ConsultarLoteRpsRequest" type="ws:input" />
        <xsd:element name="ConsultarLoteRpsResponse" type="ws:output" />
        <xsd:element name="ConsultarNfseServicoPrestadoRequest" type="ws:input" />
        <xsd:element name="ConsultarNfseServicoPrestadoResponse" type="ws:output" />
        <xsd:element name="ConsultarNfseServicoTomadoRequest" type="ws:input" />
        <xsd:element name="ConsultarNfseServicoTomadoResponse" type="ws:output" />
        <xsd:element name="ConsultarNfsePorFaixaRequest" type="ws:input" />
        <xsd:element name="ConsultarNfsePorFaixaResponse" type="ws:output" />
        <xsd:element name="ConsultarNfsePorRpsRequest" type="ws:input" />
        <xsd:element name="ConsultarNfsePorRpsResponse" type="ws:output" />
        <xsd:element name="RecepcionarLoteRpsRequest" type="ws:input" />
        <xsd:element name="RecepcionarLoteRpsResponse" type="ws:output" />
        <xsd:element name="GerarNfseRequest" type="ws:input" />
        <xsd:element name="GerarNfseResponse" type="ws:output" />
        <xsd:element name="SubstituirNfseRequest" type="ws:input" />
        <xsd:element name="SubstituirNfseResponse" type="ws:output" />
        <xsd:element name="RecepcionarLoteRpsSincronoRequest" type="ws:input" />
        <xsd:element name="RecepcionarLoteRpsSincronoResponse" type="ws:output" />
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="CancelarNfseRequest"><wsdl:part element="ws:CancelarNfseRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="CancelarNfseResponse"><wsdl:part element="ws:CancelarNfseResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarLoteRpsRequest"><wsdl:part element="ws:ConsultarLoteRpsRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarLoteRpsResponse"><wsdl:part element="ws:ConsultarLoteRpsResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfseServicoPrestadoRequest"><wsdl:part element="ws:ConsultarNfseServicoPrestadoRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfseServicoPrestadoResponse"><wsdl:part element="ws:ConsultarNfseServicoPrestadoResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfseServicoTomadoRequest"><wsdl:part element="ws:ConsultarNfseServicoTomadoRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfseServicoTomadoResponse"><wsdl:part element="ws:ConsultarNfseServicoTomadoResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfsePorFaixaRequest"><wsdl:part element="ws:ConsultarNfsePorFaixaRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfsePorFaixaResponse"><wsdl:part element="ws:ConsultarNfsePorFaixaResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfsePorRpsRequest"><wsdl:part element="ws:ConsultarNfsePorRpsRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="ConsultarNfsePorRpsResponse"><wsdl:part element="ws:ConsultarNfsePorRpsResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="RecepcionarLoteRpsRequest"><wsdl:part element="ws:RecepcionarLoteRpsRequest" name="parameters"/></wsdl:message>
  <wsdl:message name="RecepcionarLoteRpsResponse"><wsdl:part element="ws:RecepcionarLoteRpsResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="GerarNfseRequest"><wsdl:part element="ws:GerarNfseRequest" name="parameters"/></wsdl:message> 
  <wsdl:message name="GerarNfseResponse"><wsdl:part element="ws:GerarNfseResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="SubstituirNfseRequest"><wsdl:part element="ws:SubstituirNfseRequest" name="parameters"/></wsdl:message> 
  <wsdl:message name="SubstituirNfseResponse"><wsdl:part element="ws:SubstituirNfseResponse" name="parameters"/></wsdl:message>
  <wsdl:message name="RecepcionarLoteRpsSincronoRequest"><wsdl:part element="ws:RecepcionarLoteRpsSincronoRequest" name="parameters"/></wsdl:message> 
  <wsdl:message name="RecepcionarLoteRpsSincronoResponse"><wsdl:part element="ws:RecepcionarLoteRpsSincronoResponse" name="parameters"/></wsdl:message>
  <wsdl:portType name="nfse">
    <wsdl:operation name="CancelarNfse">
      <wsdl:input message="ws:CancelarNfseRequest"/>
      <wsdl:output message="ws:CancelarNfseResponse"/>
    </wsdl:operation>
    <wsdl:operation name="ConsultarLoteRps">
      <wsdl:input message="ws:ConsultarLoteRpsRequest"/>
      <wsdl:output message="ws:ConsultarLoteRpsResponse"/>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfseServicoPrestado">
      <wsdl:input message="ws:ConsultarNfseServicoPrestadoRequest"/>
      <wsdl:output message="ws:ConsultarNfseServicoPrestadoResponse"/>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfseServicoTomado">
      <wsdl:input message="ws:ConsultarNfseServicoTomadoRequest"/>
      <wsdl:output message="ws:ConsultarNfseServicoTomadoResponse"/>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfsePorFaixa">
      <wsdl:input message="ws:ConsultarNfsePorFaixaRequest"/>
      <wsdl:output message="ws:ConsultarNfsePorFaixaResponse"/>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfsePorRps">
      <wsdl:input message="ws:ConsultarNfsePorRpsRequest"/>
      <wsdl:output message="ws:ConsultarNfsePorRpsResponse"/>
    </wsdl:operation>
    <wsdl:operation name="RecepcionarLoteRps">
      <wsdl:input message="ws:RecepcionarLoteRpsRequest"/>
      <wsdl:output message="ws:RecepcionarLoteRpsResponse"/>
    </wsdl:operation>
    <wsdl:operation name="GerarNfse">
      <wsdl:input message="ws:GerarNfseRequest"/>
      <wsdl:output message="ws:GerarNfseResponse"/>
    </wsdl:operation>
    <wsdl:operation name="SubstituirNfse">
      <wsdl:input message="ws:SubstituirNfseRequest"/>
      <wsdl:output message="ws:SubstituirNfseResponse"/>
    </wsdl:operation>
    <wsdl:operation name="RecepcionarLoteRpsSincrono">
      <wsdl:input message="ws:RecepcionarLoteRpsSincronoRequest"/>
      <wsdl:output message="ws:RecepcionarLoteRpsSincronoResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="nfseSOAP" type="ws:nfse">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="CancelarNfse">
      <soap:operation soapAction="http://nfse.abrasf.org.br/CancelarNfse"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ConsultarLoteRps">
      <soap:operation soapAction="http://nfse.abrasf.org.br/ConsultarLoteRps"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfseServicoPrestado">
      <soap:operation soapAction="http://nfse.abrasf.org.br/ConsultarNfseServicoPrestado"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfseServicoTomado">
      <soap:operation soapAction="http://nfse.abrasf.org.br/ConsultarNfseServicoTomado"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfsePorFaixa">
      <soap:operation soapAction="http://nfse.abrasf.org.br/ConsultarNfsePorFaixa"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="ConsultarNfsePorRps">
      <soap:operation soapAction="http://nfse.abrasf.org.br/ConsultarNfsePorRps"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RecepcionarLoteRps">
      <soap:operation soapAction="http://nfse.abrasf.org.br/RecepcionarLoteRps"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
   <wsdl:operation name="GerarNfse">
      <soap:operation soapAction="http://nfse.abrasf.org.br/GerarNfse"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
   <wsdl:operation name="SubstituirNfse">
      <soap:operation soapAction="http://nfse.abrasf.org.br/SubstituirNfse"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
   <wsdl:operation name="RecepcionarLoteRpsSincrono">
      <soap:operation soapAction="http://nfse.abrasf.org.br/RecepcionarLoteRpsSincrono"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
   </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="NfseWSService">
    <wsdl:port binding="ws:nfseSOAP" name="nfseSOAP">
      <soap:address location="https://limeira.iibr.com.br/api/soap/notafiscal.php"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Erro que é retornado

ArrayArrayArrayArrayArrayArrayArrayArraySOAP-ERROR: Encoding: object has no 'nfseCabecMsg' property
Fatal error: Uncaught Error: Call to a member function GerarNfse() on string in /var/www/html/erp/NFSE/enviar_nfse.php:87 Stack trace: #0 {main} thrown in /var/www/html/erp/NFSE/enviar_nfse.php on line 87
4
  • tem bastante coisa na pergunta, mas faltou dizer qual é o erro Commented 12/07/2019 às 11:34
  • kkk, você tem razão Ricardo, me perdoe. "ArrayArrayArrayArrayArrayArrayArrayArraySOAP-ERROR: Encoding: object has no 'nfseCabecMsg' property Fatal error: Uncaught Error: Call to a member function GerarNfse() on string in /var/www/html/erp/NFSE/enviar_nfse.php:87 Stack trace: #0 {main} thrown in /var/www/html/erp/NFSE/enviar_nfse.php on line 87" Commented 12/07/2019 às 11:37
  • Nunca vi tanto erro.... Echo retorna array... Array... E gerarNfse.... Commented 12/07/2019 às 12:48
  • hehe, no final deu tudo certo :D Commented 12/07/2019 às 20:07

1 Resposta 1

0

O erro diz está faltando o campo nfseCabecMsg

O XML de envio tem que ser neste formato

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nfse="http://nfse.abrasf.org.br">
   <soapenv:Header/>
   <soapenv:Body>
      <nfse:GerarNfseRequest>
         <nfseCabecMsg>?</nfseCabecMsg>
         <nfseDadosMsg></nfseDadosMsg>
      </nfse:GerarNfseRequest>
   </soapenv:Body>
</soapenv:Envelope>

Uma dica, use o SOAPUI para importar o WSDL e ver as requisições e serviços disponíveis para este webservice

https://www.devmedia.com.br/soapui-testes-de-web-services-rapido-e-descomplicado/37461

11
  • Consegui realizar o processo aqui, porém esta me retornando o resultado em "StdClass" e preciso em "xml" , como faço isso? Commented 12/07/2019 às 13:59
  • MSG: stdClass Object ( [outputXML] => E10 RPS já informado. Para essa Inscrição Municipal/CNPJ Commented 12/07/2019 às 13:59
  • Da uma olhada se ajuda pt.stackoverflow.com/questions/83518/…
    – André
    Commented 12/07/2019 às 14:06
  • Não deu certo André, :( Commented 12/07/2019 às 14:17
  • pelo que eu entendi voce precisa iterar nesse objeto outputXML, porque a informação já esta vindo certo?
    – André
    Commented 12/07/2019 às 14:18

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .