首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RobinBuschmann/soap-typescript/soap-decorators示例

RobinBuschmann/soap-typescript/soap-decorators示例
EN

Stack Overflow用户
提问于 2018-06-21 15:25:29
回答 1查看 382关注 0票数 0

有没有人可以给我一个详细的RobinBuschmann/soap-typescript/soap-decorators例子。我希望为node-soap创建一个wsdl xml。在RobinBuschmann/soap-typescript的github上给出的例子似乎不能正常工作。我将前三个代码片段放在一个名为createWsdl.js的文件中,并使用"node createWsdl.js“运行它,然后得到一个错误。我怀疑我做得不对。有没有人可以帮助我,或者给我一个实际有效的详细例子。

EN

回答 1

Stack Overflow用户

发布于 2018-11-21 22:34:58

我使用node-soapsoap-decorators与Quickbook进行通信。下面是我的app.ts文件中的内容:

代码语言:javascript
复制
this.express.use(
    '/soap',
    soap(this.quickbooksController, {
        overrideRootElement: {
            namespace: '',
            xmlnsAttributes: [
                {
                    name: 'xmlns',
                    value: 'http://developer.intuit.com/'
                }
            ]
        }
    })
);

控制器的注释如下:

代码语言:javascript
复制
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类型:

代码语言:javascript
复制
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;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50962718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档