NodeJS (React) with soap (WSSecurity)










0















I'm trying to connect to TERYT (Central Statistical Office in Poland) via SOAP, but whatever I do, it allways don't execute my method (in this case "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);

);


Header which work (made in 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>


How can I "copy" that into nodeJS?










share|improve this question




























    0















    I'm trying to connect to TERYT (Central Statistical Office in Poland) via SOAP, but whatever I do, it allways don't execute my method (in this case "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);

    );


    Header which work (made in 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>


    How can I "copy" that into nodeJS?










    share|improve this question


























      0












      0








      0








      I'm trying to connect to TERYT (Central Statistical Office in Poland) via SOAP, but whatever I do, it allways don't execute my method (in this case "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);

      );


      Header which work (made in 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>


      How can I "copy" that into nodeJS?










      share|improve this question
















      I'm trying to connect to TERYT (Central Statistical Office in Poland) via SOAP, but whatever I do, it allways don't execute my method (in this case "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);

      );


      Header which work (made in 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>


      How can I "copy" that into nodeJS?







      node.js strong-soap






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 22:00







      K. A. T.

















      asked Nov 13 '18 at 21:41









      K. A. T.K. A. T.

      48213




      48213






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289938%2fnodejs-react-with-soap-wssecurity%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289938%2fnodejs-react-with-soap-wssecurity%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto