标签: node-soap

如何强制使用命名空间前缀?

我正在尝试使用SOAP Web服务,但是WSDL有点坏了,所以我必须做一些自定义node-soap.

我想要的理想SOAP信封就是这个:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <getImagesDefinition xmlns="http://services.example.com/"/>
    </Body>
</Envelope>
Run Code Online (Sandbox Code Playgroud)

到目前为止,这是nodejs我必须调用服务的代码:

var soap = require('soap');
var url = 'http://www.example.com/services/imagesizes?wsdl';

soap.createClient(url, function(err, client) {

    client.setEndpoint('http://www.example.com/services/imagesizes');
    client.getImagesDefinition(null, function(err, result) {
        console.log(result);
    });
    console.log(client.lastRequest)

}); 
Run Code Online (Sandbox Code Playgroud)

我必须手动设置端点,因为它在WSDL文件中被破坏了

打印时得到的信封client.lastRequest是这样的:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
               xmlns:tns="http://services.example.com/">
    <soap:Body>
        <getImagesDefinition />
    </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

我知道如果我可以强制主体上的命名空间前缀<tns:getImagesDefinition />而不是<getImagesDefinition />请求完美地工作.

有什么办法让我强行吗?

我阅读文档说这tns是一个默认忽略的命名空间,所以我尝试通过这样做来改变它:

var options = {
    ignoredNamespaces: {
        namespaces: [],
        override: true
    }
}
Run Code Online (Sandbox Code Playgroud)

并将该对象发送到该soap.createClient方法,但我发现信封没有区别.

无论如何我强迫这个?或者获得理想的SOAP信封?

谢谢!

soap node.js node-soap

11
推荐指数
2
解决办法
5454
查看次数

node-soap客户端(Node.js)中数组字段的命名空间

如何为数组配置node-soap客户端集命名空间不仅适用于对象?

我对'sendPatient'方法的参数:

params = {
        patientCard: {
          patient: {
            firstName: 'test',
            lastName: 'test'
          },
          identifiers:
            {
              code: "123456789",
              codeType: 1
            }
        }
      };
client.sendPatient(params, ...)
Run Code Online (Sandbox Code Playgroud)

node-soap产品:

<soap:Envelope                                                     
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"           
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"            
  xmlns:tns="http://xxx/patient/api/"     
  xmlns:bi="http://xxx/base/info/build/">              
  <soap:Header></soap:Header>                                      
  <soap:Body>                                                      
    <tns:sendPatient                                               
      xmlns:tns="http://xxx/patient/api/" 
      xmlns="http://xxx/patient/api/">    
      <tns:patientCard>                                            
        <ns1:patient                                               
          xmlns:ns1="http://xxx/patient/">
          <ns1:firstName>test</ns1:firstName>
          <ns1:lastName>test</ns1:lastName>                      
        </ns1:patient>                                             
        <ns1:identifiers                                           
          xmlns:ns1="http://xxx/patient/">
          <ns1:code>123456789</ns1:code>                         
          <ns1:codeType>1</ns1:codeType>                           
        </ns1:identifiers>                                         
      </tns:patientCard>                                           
    </tns:sendPatient>                                             
  </soap:Body>                                                     
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

它的工作原理,但我需要发送标识符数组,而不仅仅是一个,所以当我放入数组时

params = {
        patientCard: {
          patient: {
            firstName: 'test',
            lastName: 'test'
          },
          identifiers: [
            {
              code: "123456789",
              codeType: 1
            }, {
              code: "987654321",
              codeType: 2
            }
          ]
        } …
Run Code Online (Sandbox Code Playgroud)

xml soap wsdl node.js node-soap

5
推荐指数
1
解决办法
4449
查看次数

不使用WSDL的NodeJS SOAP

我正在处理只支持SOAP的Web服务.此外,我有一个NodeJS应用程序,从那里我应该通过soap调用使用此服务.

最大的问题是,Web Service在任何地方都没有WSDL api描述.所以我的问题是,我如何使用NodeJS,在没有WSDL的情况下使用Soap?到目前为止,我检查过NodeJS的所有库都要求我给它们WSDL url.我找到了一个不需要的C#,这里:C#-soap-without-wsdl

soap wsdl node.js node-soap

5
推荐指数
1
解决办法
2724
查看次数

使用 Node 通过 https 调用 SOAP Web Service

我正在尝试使用 node-soap https://github.com/vpulim/node-soap来调用 Web 服务,但是我在使用带有https的模块时遇到了问题。

在下面的代码我使用HTTP,我可以看到的功能和日志describe()中的About功能。(响应为空,可能是因为在使用 http(?) 时 WS 是这样设置的)

var soap = require('soap');
var url = "http://XXXXX/service.svc?DocArchiveService/DocArchiveV201409";
var auth = "Basic " + new Buffer("USERXXX" + ":" + "PWYYY").toString("base64");

var args = {};

soap.createClient(url, { wsdl_headers: {Authorization: auth} }, function(err, client) {

    console.log(client.describe().DocArchiveV201409.DocArchiveV201409Soap.About);

    client.DocArchiveV201409.DocArchiveV201409Soap.About(args, function(err, result){
        if (err) throw err;
        console.log(result);
    });
});
Run Code Online (Sandbox Code Playgroud)

输出:

{ input: {}, output: { AboutResult: 's:string' } }
Run Code Online (Sandbox Code Playgroud)

错误消息(这很好,因为无论如何响应都是空的):

错误:无法在完成时解析响应 (E:\Qlikview\SourceDocuments\UnderDevelopment\Node\node_modules\so ap\lib\client.js:383:19)

我的问题是,当使用 https 时,我得到了一个未定义的客户端。 …

soap node.js node-soap

4
推荐指数
1
解决办法
9126
查看次数

如何在node.js中使用node-soap或strong-soap添加soap标头

我正在尝试在节点中使用xml Web服务soap客户端,我不知道如何为我的示例添加soap标头.

看看strong-soap,有一种方法,addSoapHeader(value, qname, options)但我不确定在这种情况下我需要传递什么qname和options.

我的要求,我需要发送

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://schemas.foo.com/webservices/authentication" xmlns:hot="http://foo.com/webservices/hotelv3" xmlns:hot1="http://schemas.foo.com/webservices/hotelv3">
   <soapenv:Header>
      <aut:AuthenticationHeader>
         <aut:LoginName>foo</aut:LoginName>
         <aut:Password>secret</aut:Password>
         <aut:Culture>en_US</aut:Culture>
         <aut:Version>7.123</aut:Version>
      </aut:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <hot:BookHotelV3>
         <!--Optional:-->
         <hot:request>
            <hot1:RecordLocatorId>0</hot1:RecordLocatorId>
            <!--Optional:-->
            <hot1:RoomsInfo>
               <!--Zero or more repetitions:-->
               <hot1:RoomReserveInfo>
                  <hot1:RoomId>123</hot1:RoomId>
                  <hot1:ContactPassenger>
                     <hot1:FirstName>Joe</hot1:FirstName>
                     <hot1:LastName>Doe</hot1:LastName>
                  </hot1:ContactPassenger>
                  <hot1:AdultNum>2</hot1:AdultNum>
                  <hot1:ChildNum>0</hot1:ChildNum>
               </hot1:RoomReserveInfo>
            </hot1:RoomsInfo>
            <hot1:PaymentType>Obligo</hot1:PaymentType>
         </hot:request>
      </hot:BookHotelV3>
   </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

值应该是:

value = { LoginName:'foo', Password:'secret', Culture:'en_US', Version:7.123 }
Run Code Online (Sandbox Code Playgroud)

那qname应该是什么?auth:AuthenticationHeader?我在哪里指定命名空间?

node-soap有一个更简单的例子吗?我应该使用强力肥皂还是节肥皂?

javascript soap web-services strongloop node-soap

4
推荐指数
1
解决办法
2987
查看次数

使用 node-soap 连接 Bing Ads API

我正在尝试使用 node-soap 连接到 bing ads 肥皂 api。我已按照 bing文档中的建议创建了请求。但每次我尝试连接时,响应都会显示无效凭据(错误代码 - 105)消息 - 身份验证失败。提供的凭据无效或帐户处于非活动状态。

我能够使用 bing 提供的示例 C# 代码来验证 API。因此,很明显凭证/令牌工作得很好。

有没有办法通过我的方法或我的节点代码来识别问题。

soap.createClient(url, function (err, client) {
    if (err) {
        console.log("err", err);
    } else {
        client.addSoapHeader({
            'AuthenticationToken': '<AuthenticationToken>',
            'DeveloperToken': '<DeveloperToken>',
            'CustomerId': '<CustomerId>',
            'CustomerAccountId': '<CustomerAccountId>',
        });        
        client.SubmitGenerateReport(args, function (err, result) {
            if (err) {
                console.log("err", err.body);
            } else {
                console.log(result);
            }
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

PS:Bing 文档很糟糕。堆栈溢出万岁!

soap bing node.js node-soap bing-ads-api

4
推荐指数
1
解决办法
1465
查看次数

TypeError: obj.hasOwnProperty 在调用 Graphql 突变时不是函数

我收到一个奇怪的错误,无法弄清楚我做错了什么。我写了一个graphql突变来调用一个api:

domainStuff: async (parent, { command, params }, { models }) => {
  console.log("Params:", params);
  const result = await dd24Api(command, params);
  return result;
}
Run Code Online (Sandbox Code Playgroud)

这是我调用的函数:

export default async (command, parameter) => {
  const args = _.merge({ params: parameter }, auth);
  // Eleminate copying mistakes
  console.log(typeof args);
  const properCommand = command + "Async";
  const result = await soap
    .createClientAsync(apiWSDL)
    .then(client => {
       return client[properCommand](args)
         .then(res => {
            console.log(res[command + "Result"]);
          return res[command + "Result"];
    })
    .catch(err => {
      console.log(err);
      return err; …
Run Code Online (Sandbox Code Playgroud)

node.js node-soap graphql graphql-js

4
推荐指数
1
解决办法
7306
查看次数

如何使用node-soap库将文件附件添加到soap请求?

我需要向node.js应用程序的soap请求添加文件附件。

我能够使用node-soap库发送请求,现在我需要向该请求添加文件。

我使用Java客户端或soapUI进行了此操作,但是我必须在node.js中进行操作,也许可以覆盖默认请求对象吗?

soap-client node.js node-soap

4
推荐指数
1
解决办法
939
查看次数

使用Node JS的肥皂服务器

我正在尝试使用节点js创建一个soap服务。似乎最常见的做法是使用以下库:https : //www.npmjs.com/package/soap

他们有以下代码段:

var myService = {
  MyService: {
      MyPort: {
          MyFunction: function(args) {
              return {
                  name: args.name
              };
          },

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

          // This is how to receive incoming headers
          HeadersAwareFunction: function(args, cb, headers) {
              return {
                  name: headers.Token
              };
          },

          // You can also inspect the original `req`
          reallyDetailedFunction: function(args, cb, headers, req) {
              console.log('SOAP `reallyDetailedFunction` request …
Run Code Online (Sandbox Code Playgroud)

soap node.js node-soap

4
推荐指数
1
解决办法
4594
查看次数

节点肥皂 - 类型错误:回调不是函数

在 NodeJS 中的客户端上调用 SOAP 方法时,我收到以下通用 TypeScript 错误node-soap。我如何解决它?

示例代码

const [result] = await mySoapClient.Perform_Operation({ ... })
Run Code Online (Sandbox Code Playgroud)

错误

TypeError: callback is not a function
    at /Users/nick/node_modules/soap/lib/client.js:203:17
    at parseSync (/Users/nick/node_modules/soap/lib/client.js:305:24)
    at /Users/nick/node_modules/soap/lib/client.js:466:24
    at Request._callback (/Users/nick/node_modules/soap/lib/http.js:171:17)
    at Request.self.callback (/Users/nick/node_modules/request/request.js:185:22)
    at Request.emit (events.js:223:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at Request.<anonymous> (/Users/nick/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:223:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at IncomingMessage.<anonymous> (/Users/nick/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:312:28)
    at IncomingMessage.emit (events.js:228:7)
    at IncomingMessage.EventEmitter.emit (domain.js:475:20)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
Run Code Online (Sandbox Code Playgroud)

javascript node.js node-soap

4
推荐指数
1
解决办法
2195
查看次数