Skip to content

Question: Validating Output Of Parsing Xml Document #144

@bhreinb

Description

@bhreinb

Hi There,

I tried out your module to see whether it would be candidate library to use for automated testing of SOAP functionality. I detail my use case below with a sample file

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.company/bsvc">
    <soapenv:Header>
        <bsvc:Company_Common_Header>
            <!--Optional:-->
            <bsvc:Include_Reference_Descriptors_In_Response>?</bsvc:Include_Reference_Descriptors_In_Response>
        </bsvc:Company_Common_Header>
    </soapenv:Header>
</soapenv:Envelope>

I load that xml via the following code....

const xml = parser.parse((readFileSync('./files/DeleteWorkerDocument.xml', 'utf8')), {attributeNamePrefix : "_", ignoreAttributes : false, ignoreNameSpace : false});

However, I'm returned the following JSON payload...

{
  "_xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
  "_xmlns:bsvc": "urn:com.company/bsvc",
  "soapenv:Header": {
    "bsvc:Company_Common_Header": {
      "bsvc:Include_Reference_Descriptors_In_Response": "?"
    }
  }
}

Just wondering when I send the same xml to this service for example https://codebeautify.org/xmltojson how come I get a different payload to above?

{
	"Envelope": {
		"Header": {
			"Company_Common_Header": {
				"Include_Reference_Descriptors_In_Response": {
					"__prefix": "bsvc",
					"__text": "?"
				},
				"__prefix": "bsvc"
			},
			"__prefix": "soapenv"
		},
		"_xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
		"_xmlns:bsvc": "urn:com.company/bsvc",
		"__prefix": "soapenv"
	}
}

The last result rendered is generally what I get returned back when I use an online service to validate the integrity of the payload as opposed to this library. The latter payload is something I'm seeing quite frequently across online sites. Thoughts? What's the reasons for the discrepancies?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions