无法理解npm soap包的工作原理

时间:2015-07-16 23:12:41

标签: api soap npm

我正在使用npm soap包连接到SOAP API并调用方法,而我并没有理解它应该如何工作。

例如,在API文档中,它以此为例:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://xxx">
    <soapenv:Header/>
    <soapenv:Body>
        <ser:setSessionParameters>
            <viewSettings>
                <forceLogoutSession>yes</forceLogoutSession>
                <rollingPeriod>Minutes30</rollingPeriod>
                <shiftStart>21600000</shiftStart>
                <statisticsRange>CurrentDay</statisticsRange>
                <timeZone>-28800000</timeZone>
                <idleTimeOut>1800</idleTimeOut>
            </viewSettings>
        </ser:setSessionParameters>
    </soapenv:Body>
</soapenv:Envelope>

如果我使用REST工具将此内容发送到API端点,它将按预期工作。

在我的代码中,如果我调用此方法调用:

var x = client.describe();
console.log(x.WsSupervisorService.WsSupervisorPort.setSessionParameters);

我收到了这个回复:

{
  input: {
    viewSettings: {
      appType: 'xs:string',
      forceLogoutSession: 'xs:boolean',
      rollingPeriod: 'rollingPeriod|xs:string|Minutes5,Minutes10,Minutes15,Minutes30,Hour1,Hours2,Hours3,Today',
      shiftStart: 'xs:int',
      statisticsRange: 'statisticsRange|xs:string|RollingHour,CurrentDay,CurrentWeek,CurrentMonth,Lifetime,CurrentShift',
      timeZone: 'xs:int',
      targetNSAlias: 'tns',
      targetNamespace: 'http://xxx'
    },
    targetNSAlias: 'tns',
    targetNamespace: 'http://xxx'
  },
  output: {
    targetNSAlias: 'tns',
    targetNamespace: 'http://xxx'
  }
}

但这失败了:

client.setSessionParameters({
  input: {
    viewSettings: {
      forceLogoutSession: true,
      rollingPeriod: 'Minutes30',
      shiftStart: 216000000,
      statisticsRange: 'CurrentDay',
      timeZone: -288000000,
      idleTimeOut: 1800
    }
  }
});

...产生这个错误:

  

{[错误:环境:客户端:端点{http://xxx/} WsSupervisorPort不包含以下操作元数据:setSessionParameters] stack:[Getter]}

我在这里不知所措。任何帮助都将非常感激!

1 个答案:

答案 0 :(得分:0)

只需尝试:

client.setSessionParameters({
    viewSettings: {
      forceLogoutSession: true,
      rollingPeriod: 'Minutes30',
      shiftStart: 216000000,
      statisticsRange: 'CurrentDay',
      timeZone: -288000000,
      idleTimeOut: 1800
  }
});
相关问题