0

我正在为一个安静的客户工作。我有来自 restful web 服务的这个 xml 标签:

<ProductRegistration pf:urn="urn:nipf:product-registration:IB:NIC:9472693" pf:url="http://immix-dev.natinst.com/cpr-rest/1/en/product-registration/IB:NIC:9472693.xml?dataset=full" pf:locale="en">

……

这个元素包含我需要存储的几样东西。我有这个 java 对象来存储标签和我需要的所有信息。

@XmlRootElement(name ="ProductRegistration")
public class ProductRegistration {

    private ProductItem productItem;    
    private InstalledProduct installedProduct;

    @XmlElement(name = "productItem")
    public ProductItem getProductItem() {
        return productItem;
    }
    public void setProductItem(ProductItem productItem) {
        this.productItem = productItem;
    }

    @XmlElement(name = "installedProduct")
    public InstalledProduct getInstalledProduct() {
        return installedProduct;
    }
    public void setInstalledProduct(InstalledProduct installedProduct) {
        this.installedProduct = installedProduct;
    }
}

我正在做这样的连接:

public Collection<ProductRegistration> get(String url){
        GenericType<Collection<ProductRegistration>> productRegistrationType = new GenericType<Collection<ProductRegistration>>(){};

        WebResource webResource = getWebResource(url);      

        return webResource.get(productRegistrationType);
}

它发送一个集合,因为 WS 返回一个 productRegistration 对象列表。但是当我尝试将 WS 的结果存储在 Java 对象中时,我收到“错误请求”错误。有任何想法吗? - 编辑 -

信封长这样:

<ProductRegistrations xmlns:pdi="http://www.mywebpage.com/schemas/provider-framework/pdi/2" xmlns:contact="http://www.mywebpage.com/schemas/provider-framework/contact/1" xmlns:pf="http://www.mywebpage.com/schemas/provider-framework/1/providers" xmlns:ib="http://www.mywebpage.com/schemas/provider-framework/ib/2" xmlns="http://www.mywebpage.com/schemas/provider-framework/cpr/1" xmlns:tca="http://www.mywebpage.com/schemas/provider-framework/tca/1" xmlns:up="http://www.mywebpage.com/schemas/provider-framework/up/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" pf:url="http://immix-dev.mywebpage.com/cpr-rest/1/en/product-registration/byContact.xml?contactRepresentation=urn:nipf:up-contact-address:2061817&dataset=full" retrieved="true" xsi:schemaLocation="http://www.mywebpage.com/schemas/provider-framework/cpr/1 http://immix-dev.mywebpage.com/cpr-rest/1/meta/schema.xsd">
4

1 回答 1

-1

将命名空间注释添加到您的 ProductRegistration 类:

@XmlType(namespace="..wherever pf comes from..")
于 2013-01-31T15:13:46.357 回答