3

node-soapを使用して、既存の SOAP API とやり取りしています。複数のスキーマと名前空間で問題が発生しています。これは、私が読んでいるものから、既知の問題である可能性があります。セットアップは次のとおりです。2 つのスキーマを持つ 1 つの WSDL ファイルとやり取りしています。

WSDL (簡潔にするために属性と要素を削除):

<wsdl:definitions xmlns:tns="[rm-nsurl]" targetNamespace="[rm-nsurl]" ...>

   <!-- schema1 -->
  <schema xmlns:tns="[cm-nsurl]" targetNamespace="[cm-nsurl]" ...>
    <complexType abstract="true" name="Operation">
      <sequence>
        <element maxOccurs="1" minOccurs="0" name="operator" type="tns:Operator">...</element>
      </sequence>
    </<complexType
  </schema>

   <!-- schema2 -->
  <schema xmlns:cm="[cm-nsurl]" xmlns:tns="[rm-nsurl]" targetNamespace="[rm-nsurl]" ...>
    <complexType name="UserListOperation">
      <complexContent>
        <extension base="cm:Operation">...</extension>
      </complexContent>
    </complexType>
  </schema>

  ...
</wsdl:definitions>

重要な詳細は、2 つのスキーマtnsが異なる値として定義されていることです。schema2 の型が schema1 ( cm:Operation) の要素を参照する場合、cm の明示的な名前空間を使用します (これまでのところはtns良好tnsです) cm。これは問題を引き起こします。これは、node-soap が単一の全体的な値をtns使用rmしているcmためです。

問題が発生している例を次に示します。

WSDL メソッドに渡される要求オブジェクト:

{
  operations: [{
    operator: 'SET',
    operand: {
      id: 'abcd1234',
      description: 'a description'
    }
  }]
};

Node-soap で生成されたリクエスト XML:

<soap:Envelope xmlns:tns="[rm-nsurl]" xmlns:cm="[cm-nsurl]" ...>

  <soap:Body>
    <mutate xmlns="[rm-nsurl]">
      <operations>
        <operator>SET</operator>
        <operand><id>abcd1234</id><description>a description</description></operand>
      </operations>
    </mutate>
  </soap:Body>

</soap:Envelope>

リクエストエラー

[OperatorError.OPERATOR_NOT_SUPPORTED @ operations[0], RequiredError.REQUIRED @ operations[0].operator]

readme に記載されているように、要素の cm 名前空間をoperatorリクエスト オブジェクトに手動で含めることで、問題を回避できます。必要な情報はすべて WSDL で指定されているため、この状況で node-soap を使用するためのより良い方法があるかどうか疑問に思っています。

回避策を含む同じリクエスト オブジェクトを次に示します。

{
  operations: [{
    'cm:operator': 'SET',
    operand: {
      id: 'abcd1234',
      description: 'a description'
    }
  }]
};

具体的な詳細:これは私が使用している WSDL ですmutate操作を使用してこの問題にoperator遭遇していますが、名前空間が正しく設定されていないのは要素です。

4

0 に答える 0