PHP - Soap error

Asked

Viewed 427 times

2

Guys good morning, I have a problem with "SOAP" I confess that I am very lay, I already took a look on the internet and I could not identify where this the problem, I wonder if someone could give a strength?

So is the 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();
}

Sending file

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);

WSDL file

<?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>

Error that is returned

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

If you can help me understand what’s going on here, I’d be very grateful.

Thank you.

Michael Douglas

c. (19) 98866-5732

  • there is a lot in the question, but it failed to say what the mistake is

  • kkk, you’re right Ricardo, forgive me. "Arrayarrayarrayarrayarrayarraysoap-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"

  • I’ve never seen so many errors.... Echo returns array... Array... And gerarNfse....

  • Hehe, it all worked out in the end :D

1 answer

0

Good morning,

Error says is missing the field nfseCabecMsg

The upload XML has to be in this format

<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>

A tip, use SOAPUI to import the WSDL and see the requests and services available for this web service

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

  • I managed to accomplish the process here, but this returning me the result in "Stdclass" and precise in "xml", how do I do it?

  • MSG: stdClass Object ( [outputXML] => E10 RPS already informed. For this Registration§is Municipal/CNPJ

  • Take a look at https://answall.com/questions/83518/retonar-todos-values-em-array-stdclass-object

  • It didn’t work André, :(

  • from what I understand Voce needs to iterate on this outputXML object, because the information is already coming right?

  • That, coming from the web service, do I have to create the response output? that wouldn’t have to be from the server?

  • Looks like you need to create yes

  • André, I also created the output and the return was the same :/

  • See if you can help https://www.php.net/manual/en/simplexmlelement.asxml.php

  • $xml = new Simplexmlelement($string); echo $xml->asXML(); // <?xml ... <a><b><c>text</c><c>Stuff</c> ...

  • André, I got it in a different way, "$result->outputXML; "and I echo this variable, I start a header at the top and got a ball show, now I’m having trouble in the query area, it’s complicated :x

Show 6 more comments

Browser other questions tagged

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