Olá! Estou tentando acessar o serviço SOAP de homologação da Receita Federal para executar a consulta de status de serviço, já fiz todas as combinações possíveis (incluindo as presentes no último manual publicado) na construção de request SOAP e dados de mensagem sem sucesso, abaixo os recursos e resultados dos testes:
WSDL utilizado para a construção do cliente SOAP (origem: https://homologacao.nfe.fazenda.sp.gov.br/ws/nfestatusservico2.asmx?WSDL):
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Serviço destinado à consulta do status do serviço prestado pelo Portal da Secretaria de Fazenda Estadual.</wsdl:documentation>
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<s:element name="nfeDadosMsg">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="nfeStatusServicoNF2Result">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="nfeCabecMsg" type="tns:nfeCabecMsg" />
<s:complexType name="nfeCabecMsg">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="cUF" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="versaoDados" type="s:string" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="nfeStatusServicoNF2Soap12In">
<wsdl:part name="nfeDadosMsg" element="tns:nfeDadosMsg" />
</wsdl:message>
<wsdl:message name="nfeStatusServicoNF2Soap12Out">
<wsdl:part name="nfeStatusServicoNF2Result" element="tns:nfeStatusServicoNF2Result" />
</wsdl:message>
<wsdl:message name="nfeStatusServicoNF2nfeCabecMsg">
<wsdl:part name="nfeCabecMsg" element="tns:nfeCabecMsg" />
</wsdl:message>
<wsdl:portType name="NfeStatusServico2Soap12">
<wsdl:operation name="nfeStatusServicoNF2">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Consulta Status do Serviço</wsdl:documentation>
<wsdl:input message="tns:nfeStatusServicoNF2Soap12In" />
<wsdl:output message="tns:nfeStatusServicoNF2Soap12Out" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NfeStatusServico2Soap12" type="tns:NfeStatusServico2Soap12">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="nfeStatusServicoNF2">
<soap12:operation soapAction="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2/nfeStatusServicoNF2" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:nfeStatusServicoNF2nfeCabecMsg" part="nfeCabecMsg" use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
<soap12:header message="tns:nfeStatusServicoNF2nfeCabecMsg" part="nfeCabecMsg" use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NfeStatusServico2">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Serviço destinado à consulta do status do serviço prestado pelo Portal da Secretaria de Fazenda Estadual.</wsdl:documentation>
<wsdl:port name="NfeStatusServico2Soap12" binding="tns:NfeStatusServico2Soap12">
<soap12:address location="https://homologacao.nfe.fazenda.sp.gov.br/ws/nfestatusservico2.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
SOAP request gerado:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<soap12:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<versaoDados>3.10</versaoDados>
<cUF>35</cUF>
</nfeCabecMsg>
</soap12:Header>
<soap12:Body>
<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<consStatServ versao="3.10">
<cUF>35</cUF>
<tpAmb>2</tpAmb>
<xServ>STATUS</xServ>
</consStatServ>
</nfeDadosMsg>
</soap12:Body>
</soap12:Envelope>
XML da mensagem:
<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<consStatServ versao="3.10">
<cUF>35</cUF>
<tpAmb>2</tpAmb>
<xServ>STATUS</xServ>
</consStatServ>
</nfeDadosMsg>
XML de resposta do request:
<?xml version="1.0" encoding="utf-8"?>
<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:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<cUF>35</cUF>
<versaoDados>3.10</versaoDados>
</nfeCabecMsg>
</soap:Header>
<soap:Body>
<nfeStatusServicoNF2Result xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">
<retConsStatServ versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
<tpAmb>2</tpAmb>
<verAplic>SP_NFE_PL_008i2</verAplic>
<cStat>587</cStat>
<xMotivo>Rejeição: Usar somente o namespace padrão da NF-e</xMotivo>
<cUF>35</cUF>
<dhRecbto>0001-01-01T00:00:00+00:00</dhRecbto>
</retConsStatServ>
</nfeStatusServicoNF2Result>
</soap:Body>
</soap:Envelope>
Nas tentativas de resolver o problema, inferindo que os namespaces adicionais no evelope SOAP fossem a causa, construi o request com os mesmos namespaces da resposta, alterando de:
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
para:
<soap12:Envelope xmlns:soap12="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">
Mas não obtive sucesso. Enfim, se alguém aqui já enfrentou este problema e puder compartilhar a solução seria ótimo!
Tecnologias utilizadas:
NodeJS
node-soap (github.com/vpulim/node-soap)
Código da chamada para o WS:
var url = __server_settings.nfe.wsdl[__server_settings.nfe.environments.STAGING].service_status;
var options = {
envelopeKey: 'soap12',
forceSoap12Headers: true
}
soap.createClient(url, options, function(err, client) {
pfx_utils.extractPfxInfo(path.resolve(__server_settings.paths.CERTIFICATES, 'certificate.pfx'), '<password>', function (err, results, key, certificate) {
if (err == null) {
client.setSecurity(new soap.ClientSSLSecurity(key, certificate));
var header = {
nfeCabecMsg: {
attributes: {
xmlns: 'http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2'
},
versaoDados: '3.10',
cUF: 35
}
};
client.addSoapHeader(header);
var data = {
consStatServ: {
attributes: {
versao: '3.10',
xmlns: 'http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2'
},
cUF: 35,
tpAmb: 2,
xServ: 'STATUS'
}
}
client.nfeStatusServicoNF2(data, function(err, result) {
console.log(result);
});
} else {
console.log(__('Error extracting data from certificate!'));
}
});
});
Grato!
Paulo Eduardo Ferreira Ventura