2017-11-24 9 views
0

私は、角度4でインターフェイスできるリモートサーバーへの一連のエンドポイントを作成するためにnpm soapパッケージを試しています。私はドキュメントを読みましたが、まだ分かりませんその使用法。以下はWSDLです。以下のエンドポイントとのインターフェイスに使用できるクライアントを作成するにはどうすればよいですか。ここにWSDLがあります。authヘッダー付きのnpm石鹸

http://208.180.122.191:8081/niku/wsdl/Query/ts_pending_approvals?tenantId=clarity

私の期待は、私は次のように応答を得るべきであるということです。

var soap = require('soap'); 
var url = 'http://208.180.122.191:8081/niku/wsdl/Query/ts_pending_approvals?tenantId=clarity'; 
var args = {Username: "jdoe", Password: "*******"}; 
soap.createClient(url, function(err, client) { 
client.Login(args, function(err, result) { 
     console.log(result); 
    }); 
}); 

私は(client.describe())はconsole.logを呼び出すと、私は次を得る:

{ ts_pending_approvalsQueryService: 
    { ts_pending_approvalsQueryService: 
    { Query: [Object], 
    Login: [Object], 
    WrappedLogin: [Object], 
    Logout: [Object] } } } 

しかし、私はloginを呼び出してユーザー名とパスワードを渡すと、私は定義されません。 SoapUIを使用して、以下を使用してリクエストを正常に完了できました。私の質問は、ノードでこれをどのようにシミュレートするかです。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://www.niku.com/xog/Query"> 
<soapenv:Header/> 
<soapenv:Body> 
    <quer:Login> 
     <quer:Username>jdoe</quer:Username> 
     <quer:Password>******</quer:Password> 
    </quer:Login> 
</soapenv:Body> 
</soapenv:Envelope> 

答えて

0

私は私に期待される応答トークンを与えた、エンドポイントを設定することで、自分でこの問題を解決することができた:6312078__98C024DA-25CF-441E-A47B-A84DDE2FF140

var soap = require('soap'); 
var url = 'http://208.180.122.191:8081/niku/wsdl/Query/ts_pending_approvals'; 
var args = {Username: "jdoe", Password: "*****"}; 
soap.createClient(url, function(err, client) { 
    client.setEndpoint("http://208.180.122.191:8081/niku/xog") 
    client.Login(args,(error,result)=>{ 
     if (error) throw error; 
     console.log(result) 
    }) 
}); 

また、注目に値しますパッケージを利用しているときに追加のパラメータを送信した場合、複数のパラメータを必要とする複雑な構造に加えて、WSDLで指定された名前空間にマップするヘッダを送信する必要があることもあります。私はいくつかの試行錯誤の後でこれを理解することができました。以下の作業例を参照してください。

///////////////////////////////////////////////////////////////////////////////////////////////////// 
// 1TS Open Timesheet 

ppmRouter.get("/open_time_sheet",(req,res,next) => { 

    var resourceid = req.query.param_resourceid 

    var soap = require('soap'); 
    var url = config.wsdlQueryPath + 'open_time_sheet'; 
    var sheader = { Auth: {Username: config.xog_user, Password: config.password}} 
    var args = { 
     Query: {Code: "open_time_sheet"}, 
     Filter: { 
      param_resourceid: resourceid 
     } 
    }; 

    soap.createClient(url, function(err, client) { 
     client.addSoapHeader(sheader,"","tns","Auth"); 
     client.setEndpoint(config.xog_url) 
     client.Query(args,(error,result)=>{ 
      if (error) throw error; 
      console.log(result) 
      res.send(result) 
     }) 
    }); 

}) 
関連する問題