@postman/wsdl-to-postman
Advanced tools
Comparing version 1.13.1 to 1.14.0
@@ -5,2 +5,8 @@ # WSDL to Postman Changelog | ||
## [v1.14.0] - 2024-12-09 | ||
### Added | ||
- [#10466](https://github.com/postmanlabs/postman-app-support/issues/10466) Added support for soap headers in request body | ||
## [v1.13.1] - 2024-07-22 | ||
@@ -128,4 +134,6 @@ | ||
[Unreleased]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.13.1...HEAD | ||
[Unreleased]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.14.0...HEAD | ||
[v1.14.0]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.13.1...v1.14.0 | ||
[v1.13.1]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.13.0...v1.13.1 | ||
@@ -132,0 +140,0 @@ |
@@ -80,7 +80,9 @@ const | ||
* @param {Object} xmlParser the xml parser for the process | ||
* @param {array} headers the headers for the soap body | ||
* @returns {string} the rootParametersElement in xml string | ||
*/ | ||
convertInputToMessage(rootParametersElement, headerInfo, protocol, xmlParser) { | ||
convertInputToMessage(rootParametersElement, headerInfo, protocol, xmlParser, headers) { | ||
let envelopeAndProtocol = protocol + envelopeName, | ||
jObj = {}, | ||
headerElement = {}, | ||
bodyAndProtocol = protocol + bodyName, | ||
@@ -103,3 +105,17 @@ resultMessage = '', | ||
soapHeaderUtils = new SOAPHeader(xmlParser); | ||
jObj[envelopeAndProtocol][headerAndProtocol] = soapHeaderUtils.create(headerInfo, protocol); | ||
if (headers && Array.isArray(headers) && headers.length > 0) { | ||
headers.forEach((header) => { | ||
headerElement = { ...headerElement, ...soapParametersUtils.create(header, protocol) }; | ||
}); | ||
headerElement = { ...headerElement, | ||
...soapHeaderUtils.create(headerInfo, protocol) }; | ||
if (Object.keys(headerElement).length > 0) { | ||
jObj[envelopeAndProtocol][headerAndProtocol] = headerElement; | ||
} | ||
} | ||
else { | ||
jObj[envelopeAndProtocol][headerAndProtocol] = soapHeaderUtils.create(headerInfo, protocol); | ||
} | ||
jObj[envelopeAndProtocol][bodyAndProtocol] = soapParametersUtils.create(rootParametersElement, | ||
@@ -106,0 +122,0 @@ protocol); |
@@ -42,2 +42,3 @@ const | ||
INPUT_TAG = 'input', | ||
HEADER_TAG = 'header', | ||
OUTPUT_TAG = 'output', | ||
@@ -94,2 +95,3 @@ FAULT_TAG = 'fault', | ||
this.InputTagName = INPUT_TAG; | ||
this.HeaderTagName = HEADER_TAG; | ||
this.NameTag = NAME_TAG; | ||
@@ -266,3 +268,52 @@ this.OutputTagName = OUTPUT_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 []; | ||
} | ||
/** | ||
@@ -269,0 +320,0 @@ * finds the element from the port type operation object |
@@ -38,2 +38,3 @@ const | ||
INPUT_TAG = 'input', | ||
HEADER_TAG = 'header', | ||
OUTPUT_TAG = 'output', | ||
@@ -72,2 +73,3 @@ OUTFAULT_TAG = 'outfault', | ||
this.InputTagName = INPUT_TAG; | ||
this.HeaderTagName = HEADER_TAG; | ||
this.NameTag = NAME_TAG; | ||
@@ -510,2 +512,52 @@ this.OutputTagName = OUTPUT_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 | ||
@@ -512,0 +564,0 @@ * for input or output |
@@ -66,2 +66,3 @@ 'use strict'; | ||
this.input = ''; | ||
this.header = ''; | ||
this.output = ''; | ||
@@ -68,0 +69,0 @@ this.fault = ''; |
@@ -219,2 +219,12 @@ const | ||
); | ||
wsdlOperation.header = this.informationService.getElementFromBindingOperation( | ||
parsedXml, | ||
bindingOperation, | ||
elements, | ||
principalPrefix, | ||
bindingTagInfo.protocolPrefix, | ||
this.informationService.InputTagName, | ||
this.informationService.HeaderTagName, | ||
newWsdlObject.tnsNamespace, | ||
); | ||
wsdlOperation.output = this.informationService.getElementFromPortTypeInterfaceOperation( | ||
@@ -221,0 +231,0 @@ parsedXml, |
@@ -40,11 +40,14 @@ const XML = 'xml', | ||
* @param {object} xmlParser the parser class to parse xml to object or vice versa | ||
* @param {array} soapBodyHeaders the headers for the soap body | ||
* @returns {array} An array with all items generated in postman item definition format | ||
*/ | ||
getBody(operation, elementToCreateBody, securityPolicyArray, xmlParser) { | ||
getBody(operation, elementToCreateBody, securityPolicyArray, xmlParser, soapBodyHeaders) { | ||
if (operation.protocol === SOAP_PROTOCOL || | ||
operation.protocol === SOAP12_PROTOCOL) { | ||
return this.createBodyForSOAP(elementToCreateBody, securityPolicyArray, xmlParser, operation.protocol); | ||
return this.createBodyForSOAP(elementToCreateBody, securityPolicyArray, xmlParser, | ||
operation.protocol, soapBodyHeaders); | ||
} | ||
if (operation.protocol === HTTP_PROTOCOL) { | ||
return this.createBodyForHTTP(operation, elementToCreateBody, securityPolicyArray, true, xmlParser); | ||
return this.createBodyForHTTP(operation, elementToCreateBody, securityPolicyArray, true, | ||
xmlParser, soapBodyHeaders); | ||
} | ||
@@ -65,4 +68,3 @@ } | ||
operation.protocol === SOAP12_PROTOCOL) { | ||
return this.getSOAPBodyMessage(elementToCreateBody, securityPolicyArray, operation.protocol, | ||
xmlParser); | ||
return this.getSOAPBodyMessage(elementToCreateBody, securityPolicyArray, operation.protocol, xmlParser); | ||
} | ||
@@ -82,9 +84,10 @@ if (operation.protocol === HTTP_PROTOCOL) { | ||
* @param {string} protocol the operation protocol | ||
* @param {array} headers headers for soap body | ||
* @returns {array} An array with all items generated in postman item definition format | ||
*/ | ||
createBodyForSOAP(elementToCreateBody, securityPolicyArray, xmlParser, protocol) { | ||
createBodyForSOAP(elementToCreateBody, securityPolicyArray, xmlParser, protocol, headers) { | ||
return { | ||
mode: 'raw', | ||
raw: this.getSOAPBodyMessage(elementToCreateBody, securityPolicyArray, protocol, | ||
xmlParser), | ||
xmlParser, headers), | ||
options: { | ||
@@ -106,5 +109,6 @@ raw: { | ||
* @param {object} xmlParser the parser class to parse xml to object or vice versa | ||
* @param {array} soapBodyHeaders the headers for the soap body | ||
* @returns {array} An array with all items generated in postman item definition format | ||
*/ | ||
createBodyForHTTP(operation, elementToCreateBody, securityPolicyArray, isInput, xmlParser) { | ||
createBodyForHTTP(operation, elementToCreateBody, securityPolicyArray, isInput, xmlParser, soapBodyHeaders) { | ||
if (isInput) { | ||
@@ -121,3 +125,4 @@ if (operation.method === GET_METHOD) { | ||
} | ||
return this.createBodyForSOAP(elementToCreateBody, securityPolicyArray, xmlParser, SOAP_PROTOCOL); | ||
return this.createBodyForSOAP(elementToCreateBody, securityPolicyArray, xmlParser, | ||
SOAP_PROTOCOL, soapBodyHeaders); | ||
} | ||
@@ -129,3 +134,3 @@ else if (!isInput) { | ||
return this.getSOAPBodyMessage(elementToCreateBody, securityPolicyArray, SOAP_PROTOCOL, | ||
xmlParser); | ||
xmlParser, soapBodyHeaders); | ||
} | ||
@@ -143,8 +148,9 @@ } | ||
* @param {object} xmlParser the parser class to parse xml to object or vice versa | ||
* @param {array} headers the headers for soap body | ||
* @returns {string} the message xml with the structure determined in the | ||
* elements and the default values examples | ||
*/ | ||
getSOAPBodyMessage(nodeElement, securityPolicyArray, protocol, xmlParser) { | ||
getSOAPBodyMessage(nodeElement, securityPolicyArray, protocol, xmlParser, headers) { | ||
return this.sOAPMessageHelper.convertInputToMessage(nodeElement, securityPolicyArray, protocol, | ||
xmlParser); | ||
xmlParser, headers); | ||
} | ||
@@ -151,0 +157,0 @@ |
@@ -342,3 +342,3 @@ const { | ||
let requestBody = this.wsdlToPostmanCollectionBodyMapper | ||
.getBody(operation, operation.input[0], securityPolicyArray, xmlParser), | ||
.getBody(operation, operation.input[0], securityPolicyArray, xmlParser, operation.header), | ||
postmanItem = { | ||
@@ -345,0 +345,0 @@ name: operation.name, |
{ | ||
"name": "@postman/wsdl-to-postman", | ||
"version": "1.13.1", | ||
"version": "1.14.0", | ||
"description": "Convert a given WSDL specification (1.1) to Postman Collection", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1331545
35029
2