diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java index 53cc20f72f..57a99b1395 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java @@ -2312,10 +2312,20 @@ private void writeFromXmlDeserialization(JavaBlock methodBlock) { // Loop over all properties and generate their deserialization handling. AtomicReference ifBlockReference = new AtomicReference<>(ifBlock); - propertiesManager.forEachSuperXmlElement( - element -> handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, true)); - propertiesManager.forEachXmlElement( - element -> handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, false)); + propertiesManager.forEachSuperXmlElement(element -> { + if (element.isRequired() && element.isConstant()) { + return; + } + handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, true); + }); + propertiesManager.forEachXmlElement(element -> { + if (element.isRequired() && element.isConstant()) { + // the element is element of a constant, which can only have one value + // skip de-serialize + return; + } + handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, false); + }); ifBlock = ifBlockReference.get();