Java 将模式位置添加到JAXB解组器

Java 将模式位置添加到JAXB解组器,java,xml,jaxb,unmarshalling,jaxb2,Java,Xml,Jaxb,Unmarshalling,Jaxb2,当JABX解组器尝试解组xml时,我面临以下错误 线程“main”javax.xml.bind.UnmarshaleException中出现异常 -除此之外: [org.xml.sax.saxpasseeption;行号:1;列号:456;与元素类型“customerProductStatus”关联的属性“xsi:nil”的前缀“xsi”未绑定。] 当我查看从服务器返回的xml时,它如下所示: <customerProductStatus xsi:nil = "true"></

当JABX解组器尝试解组xml时,我面临以下错误

线程“main”javax.xml.bind.UnmarshaleException中出现异常 -除此之外: [org.xml.sax.saxpasseeption;行号:1;列号:456;与元素类型“customerProductStatus”关联的属性“xsi:nil”的前缀“xsi”未绑定。]

当我查看从服务器返回的xml时,它如下所示:

<customerProductStatus xsi:nil = "true"></customerProductStatus>
您可以添加以下内容:

//Gets schema
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(xmlSchema);

JAXBContext jaxbContext1= JAXBContext.newInstance(Request.class);
Unmarshaller jaxbUnMarshaller1 = jaxbContext1.createUnmarshaller();

//Sets schema with unmarshaller
jaxbUnMarshaller1 .setSchema(schema);

Request request = (Request)jaxbUnMarshaller1.unmarshal(receiveData.getBinaryStream());
所需的软件包包括:

import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

谢谢,洁。我已经从WSDL生成了JAXB类,但我没有这样的模式文件。我应该如何在这里设置模式:setSchema(模式)我不习惯WSDL,可以这样做吗?它将使用WSDL文件作为获取模式的基础。是否有方法更新binding.xml中的任何内容以缓解此问题?
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;