Skip to content

Commit

Permalink
Added Fix for failing tests and improved logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Singh authored and Aman Singh committed Dec 2, 2024
1 parent fc413ac commit fe5e3a5
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 13 deletions.
50 changes: 50 additions & 0 deletions lib/WsdlInformationService20.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,56 @@ class WsdlInformationService20 {
return this.getElementFromInterfaceOperationInOut(interfaceOperation, elementsFromWSDL, principalPrefix, tag);
}

/**
* finds the element from the port type operation object
* @param {object} parsedXml the content file in javascript object representation
* @param {object} bindingOperation binding operation to find the element
* @param {object} elementsFromWSDL all the elements of the document
* @param {string} principalPrefix the principal prefix of the document
* @param {string} protocolPrefix the binding information for the binding
* @param {string} inputTag the tag for search of input
* @param {string} headerTag the tag for search of header
* @param {object} tnsNamespace tns namespace object
* @returns {object} the WSDLObject
*/
getElementFromBindingOperation(parsedXml, bindingOperation, elementsFromWSDL, principalPrefix, protocolPrefix,
inputTag, headerTag, tnsNamespace) {
let inputInformation = getNodeByName(bindingOperation, principalPrefix, inputTag),
headerInformation = getNodeByName(inputInformation, protocolPrefix, headerTag),
messageName, elementName,
elementsArray = [];
if (headerInformation) {
if (!Array.isArray(headerInformation)) {
headerInformation = [headerInformation];
}
headerInformation.forEach((header) => {
let foundElement;
messageName = getAttributeByName(header, ATTRIBUTE_MESSAGE);
elementName = this.getMessageElementNameByMessageName(parsedXml, principalPrefix, messageName, tnsNamespace);
if (elementName === EMPTY_ELEMENT_BY_DEFAULT) {
elementsArray.push(createEmptyElement(elementName));
return;
}
elementName = excludeSeparatorFromName(elementName);

if (Array.isArray(elementsFromWSDL)) {
foundElement = elementsFromWSDL.find((element) => {
return element.name === elementName;
});
}

if (foundElement === undefined) {
elementsArray.push(createErrorElement({}, elementName));
}
else {
elementsArray.push(foundElement);
}
});
return elementsArray;
}
return [];
}

/**
* finds the element from the interface operation object when is called
* for input or output
Expand Down
2 changes: 1 addition & 1 deletion lib/WsdlToPostmanCollectionMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class WsdlToPostmanCollectionMapper {
createItemsFromOperations(operations, urlVariablesData, securityPolicyArray, xmlParser) {
let items = operations.map((operation) => {
let requestBody = this.wsdlToPostmanCollectionBodyMapper
.getBody(operation, operation.input[0], [operation.header[0], ...securityPolicyArray], xmlParser),
.getBody(operation, operation.input[0], [operation.header, securityPolicyArray], xmlParser),
postmanItem = {
name: operation.name,
request: {
Expand Down
24 changes: 12 additions & 12 deletions lib/utils/SOAPMessageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ class SOAPMessageHelper {
const soapParametersUtils = new SOAPBody(xmlParser),
soapHeaderUtils = new SOAPHeader(xmlParser);

if (Array.isArray(headerInfo)) {
headerInfo.forEach((header) => {
try {
if (Array.isArray(headerInfo) && headerInfo.length === 2) {
if (Array.isArray(headerInfo[0])) {
headerInfo[0].forEach((header) => {
headerElement = { ...headerElement, ...soapParametersUtils.create(header, protocol) };
}
catch {
header = { ...headerElement,
...soapHeaderUtils.create(headerInfo, protocol) };
}
});
});
}
headerElement = { ...headerElement,
...soapHeaderUtils.create(headerInfo[1], protocol) };

if (Object.keys(headerElement).length > 0) {
jObj[envelopeAndProtocol][headerAndProtocol] = headerElement;
}
}
else {
headerElement = { ...headerElement,
...soapHeaderUtils.create(headerInfo, protocol) };
jObj[envelopeAndProtocol][headerAndProtocol] = soapHeaderUtils.create(headerInfo, protocol);
}
jObj[envelopeAndProtocol][headerAndProtocol] = headerElement;
jObj[envelopeAndProtocol][bodyAndProtocol] = soapParametersUtils.create(rootParametersElement,
protocol);

Expand Down
5 changes: 5 additions & 0 deletions test/data/validWSDLs11/elementFormDefaultQualified.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@
<xsd:element name="Xpath" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Workday_Common_HeaderType">
<xsd:sequence>
<xsd:element name="Include_Reference_Descriptors_In_Response" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:attribute name="version" type="xsd:string" wd:fixed="v39.0" />
</xsd:schema>
</wsdl:types>
Expand Down
5 changes: 5 additions & 0 deletions test/unit/SchemaPack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ describe('SchemaPack convert unit test WSDL 1.1 with options', function () {
}, {}),
expectedOutput = `<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wd:Workday_Common_Headerxmlns:wd="urn:com.workday/bsvc">
<wd:Include_Reference_Descriptors_In_Response>true</wd:Include_Reference_Descriptors_In_Response>
</wd:Workday_Common_Header>
</soap:Header>
<soap:Body>
<wd:Put_Disability_Request xmlns:wd="urn:com.workday/bsvc" wd:Add_Only="true" wd:version="v39.0">
<wd:Disability_Reference wd:Descriptor="string">
Expand Down

0 comments on commit fe5e3a5

Please sign in to comment.