Abrindo o endereço do webservice, que chamou a atenção o final ASMX, significa igual SP com manual:
https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx?op=nfeDistDFeInteresse
Um manual pra ajudar.
Moderador: Moderadores
METHOD GetWebService( cUF, cServico, cAmbiente, cProjeto ) CLASS SefazClass
METHOD GetWebService( cUF, nWsServico, cAmbiente, cProjeto ) CLASS SefazClass
cStat 215
Rejeicao: Falha no esquema xml
<nfeDistDFeInteresseResponse xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe">
<nfeDistDFeInteresseResult>
<retDistDFeInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
<tpAmb>2</tpAmb>
<verAplic>1.1.5</verAplic>
<cStat>239</cStat>
<xMotivo>Rejeicao: Cabecalho - Versao do arquivo XML nao suportada</xMotivo>
<dhResp>2015-08-01T02:07:17</dhResp>
<ultNSU>000000000000000</ultNSU>
<maxNSU>000000000000000</maxNSU>
</retDistDFeInt>
</nfeDistDFeInteresseResult>
</nfeDistDFeInteresseResponse>
<?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://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<nfeDistDFeInteresse xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe">
<nfeDadosMsg>
<distDFeInt xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
<tpAmb>2</tpAmb>
<cUFAutor>MS</cUFAutor>
<CNPJ>01234567000177</CNPJ> // Obs: CNPJ alterado
<distNSU>
<ultNSU>000000000000000</ultNSU>
</distNSU>
</distDFeInt>
</nfeDadosMsg>
</nfeDistDFeInteresse>
</soap:Body>
</soap:Envelope>
STATIC FUNCTION UrlWebService( cUF, cAmbiente, nWsService, cVersao )
...
CASE cUF == "AN" .AND. cAmbiente == WSPRODUCAO
DO CASE
...
CASE nWsService == WSNFEDISTRIBUICAODFE ; cUrlWS := 'https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx'
ENDCASE
CASE cUF == "AN" .AND. cAmbiente == WSHOMOLOGACAO
DO CASE
CASE nWsService == WSNFEDISTRIBUICAODFE ; cUrlWS := 'https://hom.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx'
ENDCASE
...
METHOD NFeDistribuicaoDFe( cCNPJ, indTodas, indEmi ) CLASS SefazClass
local nUltNSU, aRetorno:=HASH(),;
cUF, cCertificado, cAmbiente
default cCNPJ := "01234567000155" // Obs CNPJ alterado
default indTodas := 0 // 0 = Todas NF-e, 1 = Somente as NF-e que ainda não tiveram manifestação, 2 = Item anterior inluindo NF-e que não tiveram ciência da operacao
default indEmi := 0 // 0 = Todos emitentes e remetentes (incluso notas de transferencias), 1 = Somente notas por emissor / rementete diferente do CNPJ informado
default nUltNSU := 0 // Ultimo NSU recebido
default cCertificado := ::cCertificado
default cAmbiente := '2' //::cAmbiente
default cUF := 'MS'
::cVersaoXml := "3.10"
::cServico := "http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe"
::cSoapAction := "http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse"
::cWebService := ::GetWebService( cUF, WSNFEDISTRIBUICAODFE, cAmbiente, WSPROJETONFE )
*-- XML Miolo
::cXmlDados := ""
::cXmlDados += [<distDFeInt xmlns="http://www.portalfiscal.inf.br/nfe" versao="] + ::cVersaoXML + [">]
::cXmlDados += XmlTag( "tpAmb", cAmbiente )
::cXmlDados += XmlTag( "cUFAutor", "MS" ) //'<cUFAutor>'+::cUFAutor+'</cUFAutor>'+;
::cXmlDados += XmlTag( "CNPJ", cCNPJ ) //'<CNPJ>'+::cCNPJ+'</CNPJ>'+;
::cXmlDados += [<distNSU>]
::cXmlDados += XmlTag( "ultNSU", STRZERO(nUltNSU,15) )
::cXmlDados += [</distNSU>]
::cXmlDados += [</distDFeInt>]
MEMOWRIT("\distDFeInt-ped.xml", ::cXmlDados,.F.) // Miolo XML
//-- Comentei a chamada do método abaixo e transcrevi ele pra acompanhar isoladamente.
//::XmlSoapPost( cUF, cCertificado, WSPROJETONFE)
DO CASE
CASE Empty( ::cWebService )
::cXmlRetorno := "Erro SOAP: Não há endereço de webservice"
RETURN NIL
CASE Empty( ::cServico )
::cXmlRetorno := "Erro SOAP: Não há nome do serviço"
RETURN NIL
CASE Empty( ::cSoapAction )
::cXmlRetorno := "Erro SOAP: Não há endereço de SOAP Action"
RETURN NIL
CASE Empty( ::cVersaoXml )
::cXmlRetorno := "Erro SOAP: Não há número de versão"
RETURN NIL
ENDCASE
IF Empty( cUF )
::cXmlRetorno := "Erro SOAP: Não há sigla de UF"
RETURN NIL
ENDIF
//::XmlSoapEnvelope( cUF, cProjeto) //Nao usei por enquanto devido não ter o Header etc
::cXmlSoap := ""
::cXmlSoap += [<?xml version="1.0" encoding="utf-8"?>] // UTF-8
::cXmlSoap += [<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ]
::cXmlSoap += [xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">]
::cXmlSoap += [<soap:Body>]
::cXmlSoap += '<nfeDistDFeInteresse xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe">'
::cXmlSoap += '<nfeDadosMsg>'
::cXmlSoap += ::cXmlDados
::cXmlSoap += '</nfeDadosMsg>'
::cXmlSoap += '</nfeDistDFeInteresse>'
::cXmlSoap += [</soap:Body>]
::cXmlSoap += [</soap:Envelope>]
MEMOWRIT("distDFeEnvelope-ped.xml", ::cXMLSoap, .F.)
::MicrosoftXmlSoapPost()
IF Upper( Left( ::cXmlRetorno, 4 ) ) == "ERRO"
RETURN NIL
ENDIF
IF "<soap:Body>" $ ::cXmlRetorno .AND. "</soap:Body>" $ ::cXmlRetorno
::cXmlRetorno := XmlNode( ::cXmlRetorno, "soap:Body" )
ELSE
::cXmlRetorno := "Erro SOAP: XML retorno não está no padrão " + ::cXmlRetorno
ENDIF
MEMOWRIT("distDFeRetorno.xml", ::cXMLRetorno, .F.)
RETURN ::cXmlRetorno
::cServico := "http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe"
::cSoapAction := "http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse"
::cServico := "http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe"
::cSoapAction := "nfeDistDFeInteresse"
METHOD XmlSoapEnvelope( cUF, cProjeto ) CLASS SefazClass
cUF := iif( cUF == NIL, ::cUF, cUF )
cProjeto := iif( cProjeto == NIL, ::cProjeto, cProjeto )
::cXmlSoap := ""
::cXmlSoap += [<?xml version="1.0" encoding="utf-8"?>] // UTF-8
::cXmlSoap += [<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ]
::cXmlSoap += [xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">]
IF ::cSoapAction == "nfeDistDFeInteresse"
::cXmlSoap += [<nfeDistDFeInteresse xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe">]
ELSE
::cXmlSoap += [<soap12:Header>]
::cXmlSoap += [<] + cProjeto + [CabecMsg xmlns="] + ::cServico + [">]
::cXmlSoap += [<cUF>] + UFCodigo( cUF ) + [</cUF>]
::cXmlSoap += [<versaoDados>] + ::cVersaoXml + [</versaoDados>]
::cXmlSoap += [</] + cProjeto + [CabecMsg>]
::cXmlSoap += [</soap12:Header>]
ENDIF
::cXmlSoap += [<soap12:Body>]
::cXmlSoap += [<] + cProjeto + [DadosMsg xmlns="] + ::cServico + [">]
::cXmlSoap += ::cXmlDados
::cXmlSoap += [</] + cProjeto + [DadosMsg>]
::cXmlSoap += [</soap12:Body>]
IF ::cSoapAction == "nfeDistDFeInteresse"
::cXmlSoap += [</nfeDistDFeInteresse>]
ENDIF
::cXmlSoap += [</soap12:Envelope>]
RETURN ::cXmlSoap
#ifdef __XHARBOUR__
oDOMDoc := xhb_CreateObject( _MSXML2_DOMDocument )
#else
oDOMDoc := win_oleCreateObject( _MSXML2_DOMDocument )
#endif
oDOMDoc:async := .F.
oDOMDoc:validateOnParse := .T.
oDOMDoc:resolveExternals := .F.
oDOMDoc:preserveWhiteSpace := .T.
oDOMDoc:LoadXML(cXML)
IF oDOMDoc:parseError:errorCode <> 0 // XML não carregado
cMsgErro := "Não foi possível carregar o documento pois ele não corresponde ao seu Schema"+HB_OsNewLine() +;
" Linha: " + STR(oDOMDoc:parseError:line)+HB_OsNewLine() +;
" Caractere na linha: " + STR(oDOMDoc:parseError:linepos)+HB_OsNewLine() +;
" Causa do erro: " + oDOMDoc:parseError:reason+HB_OsNewLine() +;
"code: "+STR(oDOMDoc:parseError:errorCode)
aRetorno['OK'] := .F.
aRetorno['MsgErro'] := cMsgErro
RETURN(aRetorno)
ENDIF
#ifdef __XHARBOUR__
oDOMDoc := xhb_CreateObject( _MSXML2_DOMDocument )
#else
oDOMDoc := win_oleCreateObject( _MSXML2_DOMDocument )
#endif
oDOMDoc:async := .F.
oDOMDoc:validateOnParse := .T.
oDOMDoc:resolveExternals := .F.
oDOMDoc:preserveWhiteSpace := .T.
oDOMDoc:LoadXML(cXML)
IF oDOMDoc:parseError:errorCode <> 0 // XML não carregado
cMsgErro := "Não foi possível carregar o documento pois ele não corresponde ao seu Schema"+HB_OsNewLine() +;
" Linha: " + STR(oDOMDoc:parseError:line)+HB_OsNewLine() +;
" Caractere na linha: " + STR(oDOMDoc:parseError:linepos)+HB_OsNewLine() +;
" Causa do erro: " + oDOMDoc:parseError:reason+HB_OsNewLine() +;
"code: "+STR(oDOMDoc:parseError:errorCode)
aRetorno['OK'] := .F.
aRetorno['MsgErro'] := cMsgErro
RETURN(aRetorno)
ENDIF
IF cXml != oDomDoc:Xml
? "XML modificado por DomDOC"
? "original"
? cXml
? "Após DomDoc"
? oDomDoc:Xml
ENDIF
RETURN
Usuários vendo este fórum: Nenhum usuário registrado online e 1 visitante