为什么要将 WSDL 文件传递​​给 soap 服务器?

Why pass WSDL file to soap server?

我学了一点 WSDL here. I also knows what is SOAP

但是here,在创建nodejs soap 服务器时,他们将WSDL 文件传递​​给soap 服务器。我的问题是他们为什么这样做?目的是什么?我以为 WSDL 只是一个项目规范(描述一个 web 服务集),为什么要将它传递给真正的服务器?

var soap = require('..').soap;
var WSDL = soap.WSDL;
var path = require('path');

// Pass in WSDL options if any

var options = {};
WSDL.open('./wsdls/stockquote.wsdl',options,
  function(err, wsdl) {
    // You should be able to get to any information of this WSDL from this object. Traverse
    // the WSDL tree to get  bindings, operations, services, portTypes, messages,
    // parts, and XSD elements/Attributes.

    var getQuoteOp = wsdl.definitions.bindings.StockQuoteSoap.operations.GetQuote;
    // print operation name
    console.log(getQuoteOp.$name);
    var service = wsdl.definitions.services['StockQuote'];
    //print service name
    console.log(service.$name);
});

WSDL 文档不仅仅是一个项目规范。它类似于 OOP 世界中的接口。这是一份合同,它告诉 consumer/users 您的服务以下信息:

  1. 此服务所在的位置。
  2. 此服务提供哪些操作
  3. 此服务使用的消息是什么样的,即数据结构。

编码完成后,您将发布此合同,以便使用该服务的客户可以使用此合同生成客户代码。这是我们发布 WSDL 的主要原因。