Rumah  >  Soal Jawab  >  teks badan

nodejs调用wcf服务

一个小作业,目前有一个在本机上用nodejs调用本机wcf服务的一个需求,但是目前我还没搞明白wcf到底是个啥...看网上的说明也看不太懂,以前都是直接post接口...

从网上的wcf.js主页上看到这样代码:

 var BasicHttpBinding = require('wcf.js').BasicHttpBinding
      , Proxy = require('wcf.js').Proxy
      , binding = new BasicHttpBinding(
            { SecurityMode: "TransportWithMessageCredential"
            , MessageClientCredentialType: "UserName"
            })
      , proxy = new Proxy(binding, "http://localhost:7171/Service/clearUsername")
      , message =  "<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>" +
                     "<Header />" +
                       "<Body>" +
                         "<GetData xmlns='http://tempuri.org/'>" +
                           "<value>123</value>" +
                         "</GetData>" +
                        "</Body>" +
                   "</Envelope>"

    proxy.ClientCredentials.Username.Username = "yaron"
    proxy.ClientCredentials.Username.Password = "1234"

    proxy.send(message, "http://tempuri.org/IService/GetData", function(response, ctx) {
      console.log(response)
    });

没搞明白这段代码的意思,以及这里面两个网址和XML都是干什么的?

目前我本机上只有一个这个东西:

892670031-581ee02140c15_articlex.png

感觉还是比较乱...求老司机帮忙解释解释代码并且普及下wcf到底是个啥,在此谢过啦

高洛峰高洛峰2879 hari yang lalu1020

membalas semua(1)saya akan balas

  • 三叔

    三叔2016-11-07 10:30:23

    WCF是微软的通信协议,使用类似WSDL的文档来描述接口,通常与WebService相似,部分操作可以兼容WebService、Web API调用,与http,tcp绑定居多。由于复杂度高,这几年已经逐渐被restful代替。举个栗子,restful Web API没有oai文档的情况下仍然可以快速理解,但是wcf就算给你文档,你也不明白啥意思,何况wcf的接口描述文档比WSDL更复杂。

    balas
    0
  • Batalbalas