有人可以给我一个 RobinBuschmann/soap-typescript/soap-decorators 示例的详细示例。我正在寻找为 node-soap 创建一个 wsdl xml。RobinBuschmann/soap-typescript 的 github 上给出的示例似乎无法按原样工作。我将前三个代码片段放在一个名为 createWsdl.js 的文件中,并使用“node createWsdl.js”运行它,但出现错误。我怀疑我没有做正确的事。有人可以帮助我或给我一个实际有效的详细示例。
问问题
395 次
1 回答
1
我使用node-soap和soap-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;
}
于 2018-11-21T14:34:57.740 回答