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
遭遇していますが、名前空間が正しく設定されていないのは要素です。