Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决javax.xml.bind.UnmarshallException?_Java_Rest_Web Services - Fatal编程技术网

如何解决javax.xml.bind.UnmarshallException?

如何解决javax.xml.bind.UnmarshallException?,java,rest,web-services,Java,Rest,Web Services,我是新的RESTful web服务,在阅读了一些文档之后,我处于调用web服务的状态。当我查看响应对象时,看起来我从服务生产者那里收到了200状态,但我也得到了javax.xml.bind.UnmarshallException。当代码到达读取实体时,会出现此异常。我有点不知所措,因为我不知道该做什么或看什么来解决这个错误 对象的XML表示 @XmlRootElement( name = "Somethig", namespace = "http://respone.something.com"

我是新的RESTful web服务,在阅读了一些文档之后,我处于调用web服务的状态。当我查看响应对象时,看起来我从服务生产者那里收到了200状态,但我也得到了
javax.xml.bind.UnmarshallException
。当代码到达读取实体时,会出现此异常。我有点不知所措,因为我不知道该做什么或看什么来解决这个错误

对象的XML表示

@XmlRootElement( name = "Somethig", namespace = "http://respone.something.com" )
@ReleaseInfo( version = "v4", description = "Response for Validate Email 
Service" )
public class ThirdPartyValidateEMailAddressResponse extends BaseResponse {

private String emailAddressProvided;
private String emailAddressReturned;
private String mailboxName;
private String domainName;
private String topLevelDomain;
private String topLevelDomainDesc;
private boolean syntaxCorrected;
private boolean caseStandardized;
private boolean domainNameUpdated;
客户端代码:

public ValidateEMailAddressServiceResponse validateEMailAddress( ValidateEMailAddressServiceRequest request ) throws Exception {

    WebTarget service = config.createWebResource(request.getServiceURL());

    ValidateEMailAddressServiceResponse resp = new ValidateEMailAddressServiceResponse();

    service = service.path(SOMETHING).path(SOMETHING).path(SOMETHING).register(ThirdPartyValidateEmailResponseXMLReader.class);

    ValidateEMailAddressServiceRequestParameter parameter = null;
    parameter = request.getParameter(ValidateEMailAddressServiceRequestParameter.PARAMETERS.emailAddress.name());
    if (parameter != null) {
        service = service.queryParam(ValidateEMailAddressServiceRequestParameter.PARAMETERS.emailA

    Invocation.Builder b = applyHeaders(service, request.getHeaders(), request.getHttpHeaders());

    if(request.getAccepts() != null){
        b = b.accept(request.getAccepts().value());
    }

    Response response = b.get(Response.class);

    try {
        resp = (ValidateEMailAddressServiceResponse) handleBaseResponse(resp, response);


        // Managing business or error response
        ThirdPartyValidateEMailAddressResponse thirdPartyResponse = null;
        if (shouldProcessEntity(SOMETHING+ SOMETHING + SOMETHING, resp)) {
            if (ContentType.XML.equals(request.getAccepts()) || ContentType.JSON.equals(request.getAccepts())) {
                thirdPartyResponse = response.readEntity(ThirdPartyValidateEMailAddressResponse.class);
            }
            else {
                throw new Exception("Invalid Content Type found while processing response");
            }

        }
        else {
            thirdPartyResponse = new ThirdPartyValidateEMailAddressResponse();
            thirdPartyResponse.setMessages(createMessagesFromHTTPStatus(resp));
            response.close();
        }

    }
    catch (IOException e) {
        throw new EISClientException("Exception in processing ValidateEMailAddress", e);
    }

    return resp;
}
看起来就在这里失败了

thirdPartyResponse = 
response.readEntity(ThirdPartyValidateEMailAddressResponse.class);
堆栈跟踪:

mig.eis.client.EISClientException: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; Premature end of file.]
请让我知道,如果还有什么需要从我这边调试这个问题


谢谢

EOF过早表示文件没有完整的XML。XML标记似乎缺少一些值。包括XML以便我们可以看到它。感谢Dakoda的回复,但请您详细说明是哪种XML。客户端应用程序有一个对象,上面有XML注释,就像XmlRootElement一样。你说这是因为我没有任何XML文件。解组将对象的XML表示形式转换为类。如果你不知道那里有什么,那么你需要发布你的代码,这样我们才能看到它。我已经发布了充当实体/响应的类,还有客户端代码。过早的EOF表示文件没有完整的XML。XML标记似乎缺少一些值。包括XML以便我们可以看到它。感谢Dakoda的回复,但请您详细说明是哪种XML。客户端应用程序有一个对象,上面有XML注释,就像XmlRootElement一样。你说这是因为我没有任何XML文件。解组将对象的XML表示形式转换为类。如果你不知道那里有什么,那么你需要发布你的代码,这样我们才能看到它。我已经发布了充当实体/响应的类,以及客户端代码。