【问题标题】:RobinBuschmann/soap-typescript/soap-decorators ExampleRobinBuschmann/soap-typescript/soap-decorators 示例
【发布时间】:2018-11-21 22:34:57
【问题描述】:

谁能给我一个 RobinBuschmann/soap-typescript/soap-decorators 示例的详细示例。我正在寻找为 node-soap 创建一个 wsdl xml。 RobinBuschmann/soap-typescript 的 github 上给出的示例似乎无法按原样工作。我将前三个代码 sn-ps 放在一个名为 createWsdl.js 的文件中,并使用“node createWsdl.js”运行它,但出现错误。我怀疑我没有做正确的事。有人可以帮助我或给我一个实际有效的详细示例。

【问题讨论】:

    标签: node.js annotations schema decorator node-soap


    【解决方案1】:

    我使用 node-soapsoap-decorators 与 Quickbooks 进行通信。以下来自我的app.ts 文件:

    this.express.use(
        '/soap',
        soap(this.quickbooksController, {
            overrideRootElement: {
                namespace: '',
                xmlnsAttributes: [
                    {
                        name: 'xmlns',
                        value: 'http://developer.intuit.com/'
                    }
                ]
            }
        })
    );
    

    控制器的注释如下:

    import { SoapOperation, SoapService } from 'soap-decorators';
    import { AuthenticateRequest, AuthenticateResponse } from './model/authenticate.interface';
    
    @SoapService({
        portName: 'QBWebConnectorSvcSoap',
        serviceName: 'QBWebConnectorSvc',
        targetNamespace: 'http://developer.intuit.com/'
    })
    export class QuickbooksController {
    
        @SoapOperation(AuthenticateResponse)
        authenticate(data: AuthenticateRequest, res: (res: AuthenticateResponse) => any): void {
            res({ authenticateResult: { string: ['', 'NVU'] } });
        }
    }
    

    我的请求和响应对象被修饰为 XSD 类型:

    import { XSDComplexType, XSDElement } from 'soap-decorators';
    
    @XSDComplexType
    export class AuthenticateRequest {
    
        @XSDElement
        strUserName: string;
    
        @XSDElement
        strPassword: string;
    }
    
    @XSDComplexType
    class AuthenticateResult {
    
        @XSDElement({ type: 'string' })
        string: string[];
    }
    
    @XSDComplexType({ name: 'authenticateResponse' })
    export class AuthenticateResponse {
    
        @XSDElement
        authenticateResult: AuthenticateResult;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      相关资源
      最近更新 更多