Mule 4 Nested XML Schema imports failing in APIKit Router

697 Views Asked by At

I am trying to put an XML Schema validation on the APIKit Router for validation of request

The schema structure is as follows

root.xsd -- (imports) --> notifications.xsd -- (imports) --> objects.xsd

All of these xsd files are placed in the same schema folder.

The problem that I am facing is that when I trigger any request to the API, it's unable to import the third schema (Objects.xsd), it gives the following error

********************************************************************************
Message               : File Not Found: /home/ion-mule/objects.xsd (No such file or directory)
Element               : demo/processors/0 @ raml-demo:demo.xml:17
Element DSL           : <apikit:router config-ref="demo-config"></apikit:router>
Error type            : MULE:UNKNOWN
FlowStack             : at demo-main(demo-main/processors/0 @ demo:demo.xml:17)
Payload Type          : org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider
--------------------------------------------------------------------------------

I have placed all the files properly in the same folder, but not sure why it is always not able to fetc the third xsd file.

Below is the schema and example payload

root.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:sobject.enterprise.soap.sforce.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/">
  <xsd:import schemaLocation="notifications.xsd" namespace="http://soap.sforce.com/2005/09/outbound" />
  <xsd:element name="Envelope">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Body">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element xmlns:q1="http://soap.sforce.com/2005/09/outbound" ref="q1:notifications" />
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xs:schema>

notifications.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://soap.sforce.com/2005/09/outbound" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/2005/09/outbound" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="objects.xsd" namespace="urn:sobject.enterprise.soap.sforce.com" />
  <xs:element name="notifications">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="SessionId" nillable="true" />
        <xs:element name="Url" type="xs:string" />
        <xs:element name="Notification">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Id" type="xs:string" />
              <xs:element name="sObject">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element xmlns:q1="urn:sobject.enterprise.soap.sforce.com" ref="q1:Id" />
                    <xs:element xmlns:q3="urn:sobject.enterprise.soap.sforce.com" ref="q2:Name" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

objects.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="urn:sobject.enterprise.soap.sforce.com" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:sobject.enterprise.soap.sforce.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Id" type="xs:string" />
  <xs:element name="Name" type="xs:unsignedShort" />
</xs:schema>

XML Example

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <notifications xmlns="http://soap.sforce.com/2005/09/outbound">
   <SessionId xsi:nil="true"/>
   <Url>https://somerandomurl.com</Url>
   <Notification>
    <Id>04l0uioAAM</Id>
    <sObject xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
     <sf:Id>xyx033fcml98i</sf:Id>
     <sf:Name>7654</sf:Name>
    </sObject>
   </Notification>
  </notifications>
 </soapenv:Body>
</soapenv:Envelope>

Please share your suggestions

0

There are 0 best solutions below