I am using node-soap to interface with an existing SOAP API. I'm running into a problem with multiple schemas and namespaces that, from what I'm reading, may be a known issue. Here's the setup, I'm interfacing with one WSDL file with two schemas:
WSDL (attributes and elements removed for brevity):
<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>
The important detail is that the two schemas define tns
as different values. When a type in schema2 references an element in schema1 (cm:Operation
), it uses the explicit namespace of cm (good so far), but then jumping into that referenced type in schema1 we are now seeing the tns
namespace used and in schema1 tns
is cm
. This causes a problem because node-soap is using a single overall value for tns
which in this case happens to be rm
and it does not explicitly use the cm
namespace when required.
Here's an example where I'm seeing the problem:
Request object passed to the WSDL method:
{
operations: [{
operator: 'SET',
operand: {
id: 'abcd1234',
description: 'a description'
}
}]
};
Node-soap generated request 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>
The request errors with
[OperatorError.OPERATOR_NOT_SUPPORTED @ operations[0], RequiredError.REQUIRED @ operations[0].operator]
I'm able to get around the problem by manually including the cm namespace for the operator
element in the request object as mentioned in the readme. I'm wondering if there is a better way to use node-soap in this situation, since all of the required information is specified in the WSDL, or have I run into one of the kinks that node-soap has regarding namespaces?
Here's the same request object with the workaround:
{
operations: [{
'cm:operator': 'SET',
operand: {
id: 'abcd1234',
description: 'a description'
}
}]
};
Concrete details: This is the WSDL I'm using. I am running into this problem using a mutate
operation and it is the operator
element that is getting namespaced incorrectly.