11

SOAP Web サービスを使用しようとしていますが、WSDL が壊れているため、.xml をカスタマイズする必要がありnode-soapます。

私が望む理想的な SOAP エンベロープは次のようなものです。

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <getImagesDefinition xmlns="http://services.example.com/"/>
    </Body>
</Envelope>

これまでのところ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)

}); 

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>

<tns:getImagesDefinition />リクエストの代わりに本文の名前空間プレフィックスを強制できれば、<getImagesDefinition />完全に機能することを私は知っています。

強制する方法はありますか?

tnsそれがデフォルトの無視された名前空間であるというドキュメントを読んだので、これを実行して変更しようとしました:

var options = {
    ignoredNamespaces: {
        namespaces: [],
        override: true
    }
}

そのオブジェクトをメソッドに送信しますがsoap.createClient、エンベロープに違いはありません。

これを強制する方法はありますか?それとも理想的な SOAP エンベロープにたどり着くのでしょうか?

ありがとう!

4

2 に答える 2

5

私はこの正確な問題に遭遇しました。私にとっての修正は、ignoredNamespaces をオーバーライドして、無視された名前空間として「tns」を削除することでした。

var options = { 
  ignoredNamespaces: {
    namespaces: ['targetNamespace', 'typedNamespace'],
    override: true
  }
}

うまくいかなかった理由はわかりませんが、ライブラリにバグがあり、その後修正された可能性があります。または、名前空間を含めず、空の配列を含めた可能性があります。

于 2016-05-20T17:38:19.980 に答える