繁体   English   中英

整理POJO的问题

[英]Issues unmarshalling POJO

有一个Web服务包含3个我需要检索的Java对象。 这些是对象

 @XmlRootElement(name="licenseFile")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class XmlLicenseFile implements Cloneable
    {
        //URI Info
        public static final String URI_PATH = "licenseFiles";
        @XmlAttribute
        private String url;

        //Base License Info
        private String licenseFileId;
        private String licenseStatus; 
        private String licenseFileType; 
        private String licenseFileVersion;

        //Request Info
        private String requestSource;
        private String locale;
        private Boolean overrideErrors;
        private String internallyRequestingUserId;
        private String requestorUserProfileId;
        private String externalIpAddress;
        private Boolean internalUseOnly;

        //Contract Info
        private String serviceId; //Used to be called contractNumber
        private String contractAdminName;
        private String contractAdminEmail;
        private String organizationName;
        private String contractStartDate;
        private String contractEndDate;
        private Boolean overdraftAllowed;
        private String vlaType;
        private Integer vlaLogAutoSendFrequency;

        //Server Info
        @XmlElementWrapper(name="licenseServers")
        @XmlElement(name="licenseServer")
        private List<XmlLicenseServer> licenseServers;

        //License Package Info
        @XmlElementWrapper(name="licensePackages")
        @XmlElement(name="licensePackage")
        private List<XmlLicensePackage> licensePackages;

        //Error Info
        private String errorType; 
        private Integer errorCode;
        private String errorDescription;

        //Database Info
        private String creationDate;
        private String lastUpdateDate;

        //License Content
        private String licenseFileName;
        private String licenseFileContent;

        public String getOrganizationName() {
        return organizationName;
        }
        public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
        }
        // ALL OF THE OTHER SETTERS AND GETTERS GO HERE
 }   

@XmlRootElement(name="licensePackage")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlLicensePackage 
{
    //URI Info
    public static final String URI_PATH = "licensePackages";
    @XmlAttribute
    private String url;

    //Base Package Info
    private String licensePackageId;
    private String licenseFileId;
    private String packageStatus; 


    private String partNumber;

    //Package Info
    private String packageName;
    private String packageVersion; //Calculated
    private String operatingSystem; //Can be calculated or passed in

    //Generation Info
    private String serialNumber;
    private Integer seatCount;
    private String packageExpireDate;

    //Client/Concurrency Info
    private String concurrencyType; 
    private String clientType; 

    //Reconciliation Info
    private String productReconciliationId;

    //Error Info
    private String errorType; 
    private Integer errorCode;
    private String errorDescription;

    //Database Info
    private String creationDate;
    private String lastUpdateDate;
        //ALL THE GETTERS AND SETTERS
}

@XmlRootElement(name="licenseServer")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlLicenseServer
{
    private String serverName;
    private String computerId;
    //ALL SETTERS AND GETTERS HERE
}

我的问题是吸气剂。 这是GET代码。 客户变量是球衣客户。

public static XmlLicenseFile getLicenseFile(String key){
        XmlLicenseFile returnedFile = null;
        URI uri = constructURIByFileId(key); //THIS CREATES THE URI, AND I'VE CONFIRMED IT'S CORRECT
        try{
            WebResource webResource = client.resource(uri.toString());
            returnedFile = webResource.accept(MediaType.APPLICATION_XML).get(XmlLicenseFile.class);
            if(returnedFile == null){
                throw new ProviderException(ResponseErrorType.NOT_FOUND, "The license file doesn't exists", "", "");
            } //TODO Fill error cases
        }catch(Exception e){
            logger.error(e);
            throw new ProviderException(ResponseErrorType.INTERNAL_SERVICE_ERROR, "Internal Server Error", "", "");
        }
        return returnedFile;
    }

每当我尝试运行代码时,webResource.accept(MediaType.APPLICATION_XML).accept(XmlLicenseFile.class)部分中的代码都会失败。 它失败并显示ClientException。 知道为什么解组失败吗?

-编辑-这是正在构建的URI localhost / myWS / 1.0 / licenseFiles / EBB080CCFB02309AE0440021287E6A9E

如果我在浏览器中单击该URL,它将返回有效的licenseFile。

因此,问题在于URI没有“ http://”部分。 添加完后,一切正常! :D

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM