oliveiros Posted January 9, 2019 Report Share Posted January 9, 2019 Pessoal, boa noite! Preciso de ajuda para identificar o que está errado nesta xml do e-social. Quando envio só volta 400 - Bad Request? <?xml version="1.0" encoding="ISO-8859-1"?> <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> <eSocial xmlns="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1"> <envioLoteEventos grupo="1"> <ideEmpregador> <tpInsc>1</tpInsc> <nrInsc>0000000</nrInsc> </ideEmpregador> <ideTransmissor> <tpInsc>1</tpInsc> <nrInsc>0000000000000000</nrInsc> </ideTransmissor> <eventos> <evento Id="ID10000001001000201901"> <eSocial xmlns="http://www.esocial.gov.br/schema/evt/evtInfoEmpregador/v02_04_02"> <evtInfoEmpregador Id="ID10000001001000201901"> <ideEvento> <tpAmb>2</tpAmb> <procEmi>1</procEmi> <verProc>SISFolha 32780</verProc> </ideEvento> <ideEmpregador> <tpInsc>1</tpInsc> <nrInsc>00000000</nrInsc> </ideEmpregador> <infoEmpregador> <inclusao> <idePeriodo> <iniValid>2018-08</iniValid> </idePeriodo> <infoCadastro> <nmRazao>...</nmRazao> <classTrib>10</classTrib> <natJurid>3131</natJurid> <indCoop>0</indCoop> <indConstr>0</indConstr> <indDesFolha>0</indDesFolha> <indOptRegEletron>1</indOptRegEletron> <indEntEd>N</indEntEd> <indEtt>N</indEtt> <contato> <nmCtt>...</nmCtt> <cpfCtt>...</cpfCtt> <foneFixo>...</foneFixo> </contato> <softwareHouse> <cnpjSoftHouse>...</cnpjSoftHouse> <nmRazao>AM2 SERVICOS DE INFORMATICA LTDA</nmRazao> <nmCont>...</nmCont> <telefone>...</telefone> <email>am2.tecnologia@uol.com.br</email> </softwareHouse> <infoComplementares> <situacaoPJ> <indSitPJ>0</indSitPJ> </situacaoPJ> </infoComplementares> </infoCadastro> </inclusao> </infoEmpregador> </evtInfoEmpregador> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> <Reference URI=""> <Transforms> <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> <DigestValue>BjeyC0pkTbpTqHOnsUN8H0bq4S3hG2GTtqqvy0wdaq4=</DigestValue> </Reference> </SignedInfo> <SignatureValue>...</SignatureValue> <KeyInfo> <X509Data> <X509Certificate>...</X509Certificate> </X509Data> </KeyInfo> </Signature> </eSocial> </evento> </eventos> </envioLoteEventos> </eSocial> </soap:Body> </soap:Envelope> Desde já agradeço a atenção. Oliveiros Junior Quote Link to comment Share on other sites More sharing options...
Alain da Silva Posted January 9, 2019 Report Share Posted January 9, 2019 bom dia Oliveiros, como vc esta assinando o arquivo? Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 9, 2019 Author Report Share Posted January 9, 2019 ola alain, uso um programa externo. Quando montei esse xml eu retirei a assinatura. Acho que o problema e alguma coisa na montagem do soap. Att., Oliveiros Junior Quote Link to comment Share on other sites More sharing options...
Alain da Silva Posted January 9, 2019 Report Share Posted January 9, 2019 tenta assim: <?xml version="1.0" encoding="ISO-8859-1"?> <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> <EnviarLoteEventos xmlnm="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1"> <eSocial xmlns="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1"> <envioLoteEventos grupo="1"> <ideEmpregador> qual programa externo esta usando? Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 9, 2019 Author Report Share Posted January 9, 2019 Olá Alain, 1- Para assinar estou utilizando XML Sign.exe; 2- O código do manual e-Social encoding="utf-8"; está informação está na primeira linha do XML mas na hora de mostrar no browser aparece encoding="ISO-8859-1". 3- Peguei um exemplo de XML já recebido pelo e-Social e comparei com o meu e acho que o problema esta no envelopamento. Você tem alguma idéia? Att., Oliveiros Junior Quote Link to comment Share on other sites More sharing options...
Alain da Silva Posted January 9, 2019 Report Share Posted January 9, 2019 tenta assim: xXml:='<?xml version="1.0" encoding="utf-8"?>' xXml+='<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' xXml+='<soap:Body>' xXml+='<EnviarLoteEventos xmlnm="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1">' xXml+='<eSocial xmlns="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1">' if oArq="EVTINI" xXml+='<envioLoteEventos grupo="1">' elseIf oArq="EVTNPER" xXml+='<envioLoteEventos grupo="2">' elseIf oArq="EVTPER" xXml+='<envioLoteEventos grupo="3">' endif xXml+='<ideEmpregador>' Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 9, 2019 Author Report Share Posted January 9, 2019 Olá Alain, Esse código é do xml aberto no meu browser: <?xml version="1.0" encoding="ISO-8859-1"?> <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> <EnviarLoteEventos xmlnm="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1"> <eSocial xmlns="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1"> <envioLoteEventos grupo="1"> <ideEmpregador> Este é da codificação: cEnvelope_XML := '<?xml version="1.0" encoding="utf-8"?>' cEnvelope_XML += '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' cEnvelope_XML += '<soap:Body>' cEnvelope_XML += '<EnviarLoteEventos xmlnm="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1">' cEnvelope_XML += '<eSocial xmlns="http://www.esocial.gov.br/schema/lote/eventos/envio/v1_1_1">' cEnvelope_XML += '<envioLoteEventos grupo="1">' cEnvelope_XML += '<ideEmpregador>' Estou usando no soap: URL := https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/enviarloteeventos/WsEnviarLoteEventos.svc Action := http://www.esocial.gov.br/servicos/empregador/lote/eventos/envio/v1_1_0/ServicoEnviarLoteEventos/EnviarLoteEventos E o retorno agora é: Resposta: Erro - Argument error Não estou entendo agora onde é o erro. Att., Oliveiros Junior Quote Link to comment Share on other sites More sharing options...
mkyx Posted January 10, 2019 Report Share Posted January 10, 2019 tem algo no link abaixo, que pode ajudar https://developer.mozilla.org/pt-BR/docs/Web/HTTP/Status/400 Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 11, 2019 Author Report Share Posted January 11, 2019 Olá Alain, Você possui uma rotina de envio? Estou usando esta abaixo, mas não envia de jeito algum: Function Transmitir_XML( cXML ) Local oServer, cCertificado, cSoapAction, cURL_Envio, cRetorno cCertificado:= "nome do certificado" cSOAPAction := "http://www.esocial.gov.br/servicos/empregador/lote/eventos/envio/v1_1_0/ServicoEnviarLoteEventos/EnviarLoteEventos" cURL_Envio:="https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/enviarloteeventos/WsEnviarLoteEventos.svc" // *----------------------------------------------------------------------------* TRY oServer := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' ) CATCH oServer := CreateObject( 'MSXML2.XMLHTTP' ) END oServer:Open( "POST", cURL_Envio, .F. ) oServer:SetRequestHeader( "SOAPAction", cSOAPAction ) oServer:SetRequestHeader( "Content-Type", "text/xml; charset=utf-8" ) oServer:Send( cXML ) oServer:WaitForResponse( 500 ) cRetorno := oServer:ResponseBody() ? cRetorno Return .T. Att., Oliveiros Junior Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 11, 2019 Author Report Share Posted January 11, 2019 mkyx, obrigado pela dica. Quote Link to comment Share on other sites More sharing options...
mkyx Posted January 11, 2019 Report Share Posted January 11, 2019 referente ao erro 400, olhem o que diz, em perguntas e repostas no site do e-social: 01.05 - (11/01/2018) Tentando a conexão com o Webservice, o serviço retorna: “a solicitação falhou com status HTTP 400: Bad Request”. Por quê? Acessos que retornam falhas de status HTTP 400 são por motivo de solicitação inválida. A solicitação não pôde ser entendida pelo servidor devido à sintaxe incorreta, sendo aconselhado não repetir a solicitação sem os devidos ajustes. Deve ser utilizada exatamente a URL divulgada no portal do eSocial e no Manual de Orientação do Desenvolvedor. Os motivos de falhas HTTP podem ser encontrados em sites de pesquisa, veja esta URL, por exemplo: https://support.microsoft.com/pt-br/help/943891/the-http-status-code-in-iis-7-0--iis-7-5--and-iis-8-0. Além disso, é importante verificar a seção "7.9. Certificação digital" do Manual de Orientação do Desenvolvedor, disponível na área de Documentação Técnica. Quote Link to comment Share on other sites More sharing options...
mkyx Posted January 11, 2019 Report Share Posted January 11, 2019 Oliveiros: nessa rotina de envio do e-social, não falta a linha onde define o certificado? essa linha: oServer:setOption( 3, "CURRENT_USER\MY\" + ::cCertificado ) ------------------------------- oServer:Open( "POST", cURL_Envio, .F. ) oServer:SetRequestHeader( "SOAPAction", cSOAPAction ) oServer:SetRequestHeader( "Content-Type", "text/xml; charset=utf-8" ) ??? Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 11, 2019 Author Report Share Posted January 11, 2019 Olá mkyx, eu esqueci de transcrever mas esta na rotina. Gostaria que o webservice retornasse algo mais não retorna outra coisa senão error argument. Quote Link to comment Share on other sites More sharing options...
Alain da Silva Posted January 11, 2019 Report Share Posted January 11, 2019 experimenta mudar aqui: cRetorno := oServer:responseText ?cRetorno Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 11, 2019 Author Report Share Posted January 11, 2019 Olá mkyx, cRetorno := oServer:ResponseBody() Aparece primeiro ResponseBody: DISP_E_MEMBERNOTFOUND Depois cRetorno sem nada. Quote Link to comment Share on other sites More sharing options...
giovanyvecchi Posted January 12, 2019 Report Share Posted January 12, 2019 Qual é o tipo de autorização do esquema do e-social ? Seria basic? Tipo assim: oHttpWeb:SetRequestHeader( "Authorization","Basic "+hb_base64Encode(cUserLogin+":"+cSenha) ) Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 12, 2019 Author Report Share Posted January 12, 2019 Olá Giovany, bom dia! Ele não pede senha, basta informar o certificado e enviar o XML. Att., Oliveiros Junior Quote Link to comment Share on other sites More sharing options...
giovanyvecchi Posted January 12, 2019 Report Share Posted January 12, 2019 Mude a linha do header oServer:SetRequestHeader( "Content-Type", "text/xml;charset=ISO-8859-1" ) Quote Link to comment Share on other sites More sharing options...
oliveiros Posted January 12, 2019 Author Report Share Posted January 12, 2019 Ola giovany, o leiaute do e-social e UTF-8 oliveiros Junior Quote Link to comment Share on other sites More sharing options...
giovanyvecchi Posted January 12, 2019 Report Share Posted January 12, 2019 Bom, tente criar um objeto xml assim oDocXml := CreateObject( "MSXML2.DOMDocument") oDocXml:LoadXML(cXml) ///Depois envie pelo objeto xml oServer:Send(oDocXml:xml) Tente tambem converter o xml oServer:Send(hb_StrToUTF8( oDocXml:xml)) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.