{"record":{"id":"a43bb5d95868ea55","repo":"pentaho/pentaho-kettle","slug":"wsdl-error-elementmissingexception","errorCode":"Wsdl.Error.ElementMissingException","errorMessage":"Wsdl.Error.ElementMissingException","messagePattern":"Wsdl\\.Error\\.ElementMissingException","errorType":"error_code","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/webservices/wsdl/WsdlTypes.java","lineNumber":94,"sourceCode":"    Schema s = getSchema( elementName.getNamespaceURI() );\n    if ( s == null ) {\n      throw new KettleStepException( BaseMessages\n        .getString( PKG, \"Wsdl.Error.MissingSchemaException\", elementName ) );\n    }\n\n    Element schemaRoot = s.getElement();\n    List<Element> elements = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.ELEMENT_NAME );\n\n    for ( Element e : elements ) {\n      String schemaElementName = e.getAttribute( WsdlUtils.NAME_ATTR );\n      if ( elementName.getLocalPart().equals( schemaElementName ) ) {\n        namedElement = e;\n        break;\n      }\n    }\n\n    if ( namedElement == null ) {\n      throw new KettleStepException( BaseMessages.getString(\n        PKG, \"Wsdl.Error.ElementMissingException\", elementName ) );\n    }\n    return namedElement;\n  }\n\n  /**\n   * Find a named &lt;complexType&gt; or &lt;simpleType&gt; in the types section of the WSDL.\n   *\n   * @param typeName\n   *          Name of the type to find.\n   * @return null if type not found.\n   */\n  protected Element findNamedType( QName typeName ) {\n\n    Schema s = getSchema( typeName.getNamespaceURI() );\n    if ( s == null ) {\n      return null;\n    }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/webservices/wsdl/WsdlTypes.java#L76-L112","documentation":"After locating the right schema, WsdlTypes.findNamedElement(QName) scans its child <element name=\"...\"> declarations. If no element whose name matches the QName's local part exists in that schema, a KettleStepException with message key Wsdl.Error.ElementMissingException is thrown — the schema is present but the specific element is not.","triggerScenarios":"findNamedElement(new QName(ns, \"Foo\")) where the schema for ns exists but contains no <element name=\"Foo\"> — e.g., the element is only defined as a complex type, or was renamed in a newer WSDL version.","commonSituations":"WSDL/service version upgrade renamed elements; developer confused complexType name with element name; the element lives in a different schema (different targetNamespace) than the one resolved; case mismatch in element name.","solutions":["Open the schema for that targetNamespace and confirm an <xsd:element name=\"...\"> with the exact local part exists.","If only a complexType exists, add a wrapping <xsd:element name=\"...\" type=\"tns:MyType\"/> and reference it.","Correct the namespace so the element is looked up in the schema that actually declares it.","Refresh to the current WSDL/XSD versions if the element was renamed."],"exampleFix":"<!-- before: schema has only a complexType -->\n<xsd:complexType name=\"Address\">...</xsd:complexType>\n<!-- after -->\n<xsd:complexType name=\"Address\">...</xsd:complexType>\n<xsd:element name=\"Address\" type=\"tns:Address\"/>","handlingStrategy":"validation","validationCode":"// Pre-check the schema contains the element before findNamedElement\nSchema s = wsdlTypes.getSchema(elementName.getNamespaceURI());\nboolean found = s != null && DomUtils.getChildElementsByName(s.getElement(), \"element\").stream()\n  .anyMatch(el -> elementName.getLocalPart().equals(el.getAttribute(\"name\")));\nif (!found) throw new IllegalArgumentException(\"Element '\" + elementName + \"' not declared in schema\");","typeGuard":null,"tryCatchPattern":"try {\n  Element el = wsdlTypes.findNamedElement(qname);\n} catch (KettleStepException kse) {\n  if (kse.getMessage() != null && kse.getMessage().contains(\"ElementMissing\")) {\n    logError(\"Element \" + qname.getLocalPart() + \" not in schema for \" + qname.getNamespaceURI(), kse);\n  }\n  throw kse;\n}","preventionTips":["Distinguish complexType names from element names","Verify the element's actual targetNamespace","Re-check element names after WSDL version upgrades"],"tags":["wsdl","xsd","schema","element"],"backgroundTag":"entity-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}