首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >问题解编组POJO

问题解编组POJO
EN

Stack Overflow用户
提问于 2014-04-30 20:45:49
回答 1查看 40关注 0票数 0

有一个webservice,它有我需要检索的3个java对象。这些是物体

代码语言:javascript
复制
 @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密码。客户端变量是一个泽西客户端。

代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-30 21:21:00

因此,问题是URI没有"http://“部分”。一旦我加进去,一切都成功了!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23397690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档