我正在尝试通过SOAP连接到TERYT(波兰中央统计局),但是无论我做什么,它都不会执行我的方法(在这种情况下为“ CzyZalogowany”)
import { NextFunction, Request, Response } from "express";
const TERYT_URL = "https://uslugaterytws1test.stat.gov.pl/wsdl/terytws1.wsdl",
TERYT_LOGIN = "TestPubliczny",
TERYT_PASSWORD = "TestPubliczny",
soap = require("strong-soap").soap,
wsSecurity = new soap.WSSecurity(TERYT_LOGIN, TERYT_PASSWORD, {
_passwordType: "PasswordText",
hasTimeStamp: true,
hasNonce: true,
}),
soapOptions = {
forceSoap12Headers: true,
envelopeKey: "soapenv",
},
soapHeaders = {
"wsa:Action": "http://tempuri.org/ITerytWs1/CzyZalogowany",
"wsa:To": "https://uslugaterytws1test.stat.gov.pl/terytws1.svc",
};
soap.createClient(TERYT_URL, soapOptions, function (err: any, client: any) {
if (!err) {
console.log("ok");
client.addSoapHeader(soapHeaders, "", "wsa", "http://www.w3.org/2005/08/addressing");
client.setSecurity(wsSecurity);
client.CzyZalogowany({}, function (err: any, response: any) {
if (!err) {
console.log("CzyZalogowany response:", response);
} else {
console.log("Error in CzyZalogowany:", err);
}
});
} else {
console.log("Error in createClient: ", err);
}
});
工作的标题(用PHP制造):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-2018-11-13T22:43:34+01:00">
<wsse:Username></wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NjVjNTEyYzkxNjM1NjMzOWMyODQyZDQwYTY4YWZiNGE=</wsse:Nonce>
<wsu:Created>2018-11-13T22:43:34+01:00</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
<wsa:Action>http://tempuri.org/ITerytWs1/CzyZalogowany</wsa:Action>
</soapenv:Header>
<soapenv:Body><ns1:CzyZalogowany/></soapenv:Body></soapenv:Envelope>
如何将其“复制”到nodeJS?