如何创建节点肥皂wsdl文件?

时间:2018-06-21 15:01:10

标签: node.js web-services schema decorator node-soap

我正在阅读有关如何创建服务器Web服务的节点肥皂文档。我了解有关创建Web服务的所有内容,除了如何创建myservice.wsdl(按照下面的代码片段)。如果有人按照节点肥皂文档创建了Web服务,请指导我如何创建wsdl文件。预先谢谢你。

  var myService = {
      MyService: {
          MyPort: {
              MyFunction: function(args) {
                  return {
                      name: args.name
                  };
              },

              // This is how to define an asynchronous function.
              MyAsyncFunction: function(args, callback) {
                  // do some work
                  callback({
                      name: args.name
                  });
              },

              // This is how to receive incoming headers
              HeadersAwareFunction: function(args, cb, headers) {
                  return {
                      name: headers.Token
                  };
              },

              // You can also inspect the original `req`
              reallyDetailedFunction: function(args, cb, headers, req) {
                  console.log('SOAP `reallyDetailedFunction` request from ' + req.connection.remoteAddress);
                  return {
                      name: headers.Token
                  };
              }
          }
      }
  };

  var xml = require('fs').readFileSync('myservice.wsdl', 'utf8');

  //http server example
  var server = http.createServer(function(request,response) {
      response.end('404: Not Found: ' + request.url);
  });

  server.listen(8000);
  soap.listen(server, '/wsdl', myService, xml);

  //express server example
  var app = express();
  //body parser middleware are supported (optional)
  app.use(bodyParser.raw({type: function(){return true;}, limit: '5mb'}));
  app.listen(8001, function(){
      //Note: /wsdl route will be handled by soap module
      //and all other routes & middleware will continue to work
      soap.listen(app, '/wsdl', myService, xml);
  });

1 个答案:

答案 0 :(得分:0)

据我所知,没有一个Node.js SOAP模块为您创建WSDL文件。

您可以做的是使用服务来创建WSDL。

一个示例是http://marin.jb.free.fr/wsdl/,您可以使用它为所需的任何服务创建WSDL文件。