Blog from Saravanan Arumugam

Let us talk about Technologies

Category Archives: WSDL

Error: Schema with target namespace could not be found.


I was debugging a WSDL by downloading it and its reference XSDs in to my local machine. I got the following exception when I used SVCUtil

Exception

Error: Schema with target namespace ‘http://xmlns.oracle.com/Common/schemas/GetEmployeesPayrateRequest.V1′ could not be found.

Solution

We get this exception because the svcutil for some reason is not finding the referenced schema in the local disk. To solve it, try copying the xsd contents and place them as inline schema under <wsdl:types /> tag.

  <wsdl:types>
    <!--<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:import namespace="http://xmlns.oracle.com/Common/schemas/GetEmployeesPayrateRequest.V1" 
                  schemaLocation="GetEmployeePayrateRequest.v1.xsd"/>
      <xsd:import namespace="http://xmlns.oracle.com/Common/schemas/GetEmployeesPayrateResponse.V1" 
                  schemaLocation="GetEmployeePayratesResponse.v1.xsd"/>
    </xsd:schema>-->
    <xsd:schema elementFormDefault="unqualified" targetNamespace="http://xmlns.oracle.com/Common/schemas/GetEmployeesPayrateRequest.V1"
            xmlns="http://xmlns.oracle.com/Common/schemas/GetEmployeesPayrateRequest.V1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="GetEmployeesPayrateRequest">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="EMPLID" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
 
    <xsd:schema elementFormDefault="qualified"
            targetNamespace="http://xmlns.oracle.com/Common/schemas/W_GENERIC_RESPONSE8.v1"
            xmlns="http://xmlns.oracle.com/Common/schemas/W_GENERIC_RESPONSE8.v1"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="GetEmployeePayratesResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="JobRow">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="EmployeeId" type="xsd:string"/>
                  <xsd:element name="EmployeeName" type="xsd:string"/>
                  <xsd:element minOccurs="0" name="EffectiveDate" type="xsd:date"/>
                  <xsd:element name="HourlyRt" type="xsd:string"/>
                  <xsd:element name="DepartmentId" type="xsd:string"/>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>

Note that usually the WSDL will generate the <xsd:schema/> tag inside <wsdl:types /> element, and will fill it with multiple imports for every reference types. This has to be replaced by the actual schema definitions. I have just commented it out to show where the replacement has to happen.

Advertisements