Hello! I am trying to access the SOAP service of homologation of the IRS to execute the service status query, I have already made all possible combinations (including those present in the last one manual published) in the SOAP construct and unsuccessful message data, below the features and results of the tests:
>WSDL used to build the SOAP client (source: link ) :
<?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 generated:
<?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>
Message XML:
<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>
Request XML response :
<?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>
When attempting to resolve the problem by inferring that the additional namespaces in SOAP evelope were the cause, construct request with them < in> namespaces of the response, changing from:
<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/">
To:
<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">
But I did not succeed. Anyway, if anyone here has faced this problem and can share the solution would be great!
Technologies used:
NodeJS
node-soap (github.com/vpulim/node-soap)
Calling code for 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!'));
}
});
});
Thank you!
Paulo Eduardo Ferreira Ventura