使用 node-soap 创建 SOAP Web 服务 [英] Creating a SOAP Webservice With node-soap

查看:48
本文介绍了使用 node-soap 创建 SOAP Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了 git repo 的这个示例(https://github.com/vpulim/node-soap):

I followed this example of the git repo (https://github.com/vpulim/node-soap):

我已经创建了服务器 是否有必要在回调中创建服务器.据我了解 readFileSync 无论如何都是阻塞的.

I already created a server Is it necessary to create the server in the callback. From my understanding readFileSync is anyways blocking.

写非阻塞,把soap.listen放到回调里不是更好吗

Wouldn't it be better to write non blocking and put soap.listen into the callback

我从哪里获得:'myservice.wsdl'.我是否必须创建它/如何创建它?有发电机吗?

Where do I get: 'myservice.wsdl'. Do I have to create it/ How to create it? Is there a generator?

 exports.getService = () ->
  myService = {
    MyService: {
      MyPort: {

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

exports.getXml = () ->
  require('fs').readFileSync('myservice.wsdl', 'utf8', ()->
    server = http.createServer((request,response) ->
      response.end("404: Not Found: "+request.url)
    )
  )

server.coffee

...

http = require('http')
portHTTP = process.env.PORT || 61361
io = require('socket.io')
soap = require('soap')
soapService = require('./backend/soap/soap.service.js')

...

server = http.createServer(app).listen(portHTTP, () ->
  logger.info("Unsecure Express server listening on port #{portHTTP} environment: #{environment}")
)
soap.listen(server, '/wsdl', soapService.getService, soapService.getXml)

推荐答案

问题一解答:readFileSync是用来加载wsdl的,不是用来创建服务器的.所以没有必要在回调中创建服务器.

Answer to question 1: readFileSync is used to load the wsdl not to create the server. So it is not necessary to create server in callback.

问题 2 的答案:soap.listen 正在侦听请求,然后对其进行处理.# do some work 步骤可能会阻塞,因此该步骤之后的回调.

Answer to question 2: soap.listen is listening for a request and then that is processed. It is the # do some work step that could be blocking hence the callback after that step.

问题 3 的答案:您必须在编写 SOAP API 服务器时创建 wsdl,或者如果您正在使用现有服务,则应以 wsdl.

Answer to question 3: You have to either create your wsdl when writing your SOAP API server or if you are using an existing service it should be provided for use in the form of a url ending in wsdl.

wsdlxml 中,因此可以生成.查看使用注释的 wsdl 样式.

The wsdl is in xml and so could be generated. See which wsdl style to use notes.

另见我的soap示例项目nodejs_mock_agresso.

Also see my soap example project nodejs_mock_agresso.

这篇关于使用 node-soap 创建 SOAP Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆