2

I'm trying to access an goverment service to comunicate transportation guides using the SAFT specifications, but I keep receiving an 500, internal error.

I already validated the XML that I'm sending and already tried differents XMLs that I found in a forum some that are correct and some others that are giving more specific errors, but I keep getting the 500, internal error for some reason. Due to that, I thing that is something wrong in my invocation of the service with the https module of the nodejs. I do it like this:

request.log.setActionStart(request.requestID, "FINPT-WEBSERVICE", "webservice");
var options = {
    hostname: "servicos.portaldasfinancas.gov.pt",
    port: 701,
    path: "/sgdtws/documentosTransporte",
    method: "POST",
    pfx: fs.readFileSync('keys/TesteWebService.pfx'),
    cert: fs.readFileSync('keys/ChavePublicaAT.cer'),
    passphrase: "TESTEwebservice",
    agent: false,
    rejectUnauthorized: false,
    secureProtocol: 'SSLv3_method',
    headers: {
        "Content-Type": "text/xml;charset=UTF-8",
        "SOAPAction": "https://servicos.portaldasfinancas.gov.pt:701/sgdtws/documentosTransporte/",
    }
};
//options.agent = new https.Agent(options);
var reqFinWebs = https.request(options, function(resFinWebs) {
    console.log(resFinWebs.statusCode);
    if(resFinWebs.statusCode==200){
          //....
    });
    reqFinWebs.end(soapXML);
    console.log(soapXML);

I know that is vague, all I have to go on is this:

http://info.portaldasfinancas.gov.pt/NR/rdonlyres/3B4FECDB-2380-45D7-9019-ABCA80A7E99E/0/Comunicacao_Dados_Documentos_Transporte.pdf

that is in PT and what's on the programming portuguese comunity foruns, and I can't find anyone developing this in nodejs.

Also, it's not the certificates or the public key, thats an specific error and I move pass that.

Does anyone have any inside or similar situation? Any suggestions?

The error:

500
500 '<?xml version=\'1.0\' ?>\n<env:Envelope xmlns:env=\'http://schemas.xmlsoap.org/soap/envelope/\'>\n<env:Body>\n<env:Fault>\n<faultcode>env:Client</faultcode>\n<faultstring>InternalError</faultstring>\n</env:Fault>\n</env:Body>\n</env:Envelope>\n'
<?xml version='1.0' ?>
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Internal Error</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>

Any help is welcome, I hit a wall...

4

1 回答 1

7

已解决,必须指定标头内容长度:

headers: {
    "Accept": "text/xml",
    "Content-length": soapXML.length,
    "Content-Type": "text/xml;charset=UTF-8",
    "SOAPAction": "https://servicos.portaldasfinancas.gov.pt/sgdtws/documentosTransporte/",
}
于 2013-09-19T16:16:12.090 回答