{"record":{"id":"9d2a5569f2027524","repo":"pentaho/pentaho-kettle","slug":"unable-to-convert-value-textcontent-for-field-field","errorCode":null,"errorMessage":"Unable to convert value [ + textContent + ] for field [ + field.getWsName() + ], type [ + field.getXsdType() + ]","messagePattern":"Unable to convert value \\[ \\+ textContent \\+ \\] for field \\[ \\+ field\\.getWsName\\(\\) \\+ \\], type \\[ \\+ field\\.getXsdType\\(\\) \\+ \\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/webservices/WebService.java","lineNumber":1031,"sourceCode":"      // Unknown field : don't look any further, it's not a field we want to use.\n      //\n      return false;\n    }\n\n    // if it's a text node or if we recognize the field type, we just grab the value\n    //\n    if ( node.getNodeType() == Node.TEXT_NODE || !field.isComplex() ) {\n      Object rowValue = null;\n\n      // See if this is a node we expect as a return value...\n      //\n      String textContent = node.getTextContent();\n      try {\n        rowValue = getValue( textContent, field );\n        outputRowData[ outputIndex ] = rowValue;\n        return true;\n      } catch ( Exception e ) {\n        throw new KettleException( \"Unable to convert value [\"\n          + textContent + \"] for field [\" + field.getWsName() + \"], type [\" + field.getXsdType() + \"]\", e );\n      }\n    } else if ( node.getNodeType() == Node.ELEMENT_NODE ) {\n      // Perhaps we're dealing with complex data types.\n      // Perhaps we can just ship the XML snippet over to the next steps.\n      //\n      try {\n        StringWriter childNodeXML = new StringWriter();\n        transformer.transform( new DOMSource( node ), new StreamResult( childNodeXML ) );\n        outputRowData[ outputIndex ] = childNodeXML.toString();\n        return true;\n      } catch ( Exception e ) {\n        throw new KettleException( \"Unable to transform DOM node with name [\" + node.getNodeName() + \"] to XML\", e );\n      }\n    }\n\n    // Nothing found, return false\n    //","sourceCodeStart":1013,"sourceCodeEnd":1049,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/webservices/WebService.java#L1013-L1049","documentation":"KettleException thrown by WebService.getNodeValue when getValue(textContent, field) cannot convert the DOM node's text content into the Kettle value type declared for the field (field.getXsdType()). The message echoes the offending text, field name, and XSD type.","triggerScenarios":"DOM output processing: node.getTextContent() yields a string that fails conversion in getValue() — e.g. non-numeric text for an Integer/Number field, empty string for a Date, or locale-formatted numbers like '1,234.56'.","commonSituations":"Field XSD type configured in the step doesn't match what the service actually sends; server changed the value format (decimal separator, date format); optional element present but empty; null-like values ('nil', 'N/A') sent as text.","solutions":["Check the value and type in the message and correct the field's XSD type in the step's output field definitions to match the response.","Handle empty/nil values: verify the server should be sending them and set the field type to String if conversion isn't possible.","If the service sends locale-formatted numbers or non-ISO dates, request XML-schema-safe formatting from the service or convert via a subsequent step.","Re-fetch WSDL/field metadata after a service contract change."],"exampleFix":"// before\n// field \"quantity\" configured as Integer, server sends \"12.5\"\n// after\n// set field \"quantity\" XSD type to Number (double) to accept 12.5","handlingStrategy":"validation","validationCode":"// Validate each output field's declared XSD type against a sample response value before the run:\nObject sample = sampleValueFor(field); // from a test call\nif (field.getXsdType().equalsIgnoreCase(\"Integer\") && !sample.toString().matches(\"-?\\\\d+\")) {\n  throw new IllegalStateException(\"Type mismatch for field \" + field.getWsName() + \": \" + sample);\n}","typeGuard":null,"tryCatchPattern":"try {\n  // run transformation\n} catch (KettleException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to convert value\")) {\n    // relax the field's XSD type to String or correct it per the message's value/type\n  }\n}","preventionTips":["Match each output field's XSD type to what the service actually returns.","Prefer String types when values may be empty or nil.","Re-fetch field definitions after WSDL changes."],"tags":["kettle","webservice","type-conversion"],"backgroundTag":"type-mismatch","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"}