Skip to content

Commit

Permalink
Now supporting XSI namespace overrides (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddolcimascolo authored and jsdevel committed Jun 20, 2019
1 parent d1c6a7e commit d4bc843
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/wsdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import * as elements from './elements';

const debug = debugBuilder('node-soap');

const XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';

function xmlEscape(obj) {
if (typeof (obj) === 'string') {
if (obj.substr(0, 9) === '<![CDATA[' && obj.substr(-3) === ']]>') {
Expand Down Expand Up @@ -305,7 +307,7 @@ export class WSDL {

for (attributeName in elementAttributes) {
const res = splitQName(attributeName);
if (res.name === 'nil' && xmlns[res.prefix] === 'http://www.w3.org/2001/XMLSchema-instance' && elementAttributes[attributeName] &&
if (res.name === 'nil' && xmlns[res.prefix] === XSI_URI && elementAttributes[attributeName] &&
(elementAttributes[attributeName].toLowerCase() === 'true' || elementAttributes[attributeName] === '1')
) {
hasNilAttribute = true;
Expand All @@ -319,7 +321,15 @@ export class WSDL {

// Pick up the schema for the type specified in element's xsi:type attribute.
let xsiTypeSchema;
const xsiType = elementAttributes['xsi:type'];
let xsiType;

for (const prefix in xmlns) {
if (xmlns[prefix] === XSI_URI && (`${prefix}:type` in elementAttributes)) {
xsiType = elementAttributes[`${prefix}:type`];
break;
}
}

if (xsiType) {
const type = splitQName(xsiType);
let typeURI;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "CustomObject",
"fullNames": "Opportunity"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://soap.sforce.com/2006/04/metadata"><soap:Body><tns:readMetadata xmlns:tns="http://soap.sforce.com/2006/04/metadata" xmlns="http://soap.sforce.com/2006/04/metadata"><tns:type>CustomObject</tns:type><tns:fullNames>Opportunity</tns:fullNames></tns:readMetadata></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"result": {
"records": [
{
"attributes": {
"XMLSchema-instance:type": "CustomObject"
},
"fullName": "Opportunity",
"businessProcesses": [
{
"fullName": "Some Process",
"isActive": true
},
{
"fullName": "Another Process",
"isActive": false
}
],
"enableFeeds": false,
"enableHistory": true
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<readMetadataResponse>
<result>
<records xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="CustomObject">
<fullName>Opportunity</fullName>
<businessProcesses>
<fullName>Some Process</fullName>
<isActive>true</isActive>
</businessProcesses>
<businessProcesses>
<fullName>Another Process</fullName>
<isActive>false</isActive>
</businessProcesses>
<enableFeeds>false</enableFeeds>
<enableHistory>true</enableHistory>
</records>
</result>
</readMetadataResponse>
</soapenv:Body>
</soapenv:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Salesforce.com Metadata API version 33.0
Copyright 2006-2015 Salesforce.com, inc. All Rights Reserved
-->
<definitions targetNamespace="http://soap.sforce.com/2006/04/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/2006/04/metadata">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/2006/04/metadata">
<xsd:element name="readMetadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="type" type="xsd:string"/>
<xsd:element name="fullNames" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="readMetadataResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="tns:ReadResult"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Metadata">
<xsd:sequence>
<xsd:element name="fullName" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ReadResult">
<xsd:sequence>
<xsd:element name="records" minOccurs="0" maxOccurs="unbounded" type="tns:Metadata"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CustomObject">
<xsd:complexContent>
<xsd:extension base="tns:Metadata">
<xsd:sequence>
<xsd:element name="businessProcesses" minOccurs="0" maxOccurs="unbounded" type="tns:BusinessProcess"/>
<xsd:element name="enableFeeds" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="enableHistory" minOccurs="0" type="xsd:boolean"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="BusinessProcess">
<xsd:complexContent>
<xsd:extension base="tns:Metadata">
<xsd:sequence>
<xsd:element name="description" minOccurs="0" type="xsd:string"/>
<xsd:element name="isActive" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="values" minOccurs="0" maxOccurs="unbounded" type="tns:PicklistValue"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:simpleType name="ForecastCategories">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Omitted"/>
<xsd:enumeration value="Pipeline"/>
<xsd:enumeration value="BestCase"/>
<xsd:enumeration value="Forecast"/>
<xsd:enumeration value="Closed"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="PicklistValue">
<xsd:complexContent>
<xsd:extension base="tns:Metadata">
<xsd:sequence>
<xsd:element name="allowEmail" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="closed" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="color" minOccurs="0" type="xsd:string"/>
<xsd:element name="controllingFieldValues" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
<xsd:element name="converted" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="cssExposed" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="default" type="xsd:boolean"/>
<xsd:element name="description" minOccurs="0" type="xsd:string"/>
<xsd:element name="forecastCategory" minOccurs="0" type="tns:ForecastCategories"/>
<xsd:element name="highPriority" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="probability" minOccurs="0" type="xsd:int"/>
<xsd:element name="reverseRole" minOccurs="0" type="xsd:string"/>
<xsd:element name="reviewed" minOccurs="0" type="xsd:boolean"/>
<xsd:element name="won" minOccurs="0" type="xsd:boolean"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="readMetadataResponse">
<part element="tns:readMetadataResponse" name="parameters"/>
</message>
<message name="Header">
<part name="CallOptions" element="tns:CallOptions"/>
<part name="DebuggingHeader" element="tns:DebuggingHeader"/>
<part name="DebuggingInfo" element="tns:DebuggingInfo"/>
<part name="SessionHeader" element="tns:SessionHeader"/>
</message>
<message name="readMetadataRequest">
<part element="tns:readMetadata" name="parameters"/>
</message>
<portType name="MetadataPortType">
<operation name="readMetadata">
<documentation>Reads metadata entries synchronously.</documentation>
<input message="tns:readMetadataRequest"/>
<output message="tns:readMetadataResponse"/>
</operation>
</portType>
<binding name="MetadataBinding" type="tns:MetadataPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="readMetadata">
<soap:operation soapAction=""/>
<input>
<soap:header use="literal" part="SessionHeader" message="tns:Header"/>
<soap:header use="literal" part="CallOptions" message="tns:Header"/>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="MetadataService">
<documentation>Manage your Salesforce.com metadata</documentation>
<port binding="tns:MetadataBinding" name="Metadata">
<soap:address location="https://na24.salesforce.com/services/Soap/m/33.0"/>
</port>
</service>
</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ignoredNamespaces": {
"namespaces": ["targetNamespace", "typedNamespace"],
"override": "true"
}
}

0 comments on commit d4bc843

Please sign in to comment.