0
我正在處理一個寧靜的客戶端。我有這個XML標籤從RESTful Web服務:使用Jersey解編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">
像這樣的事情? @XmlRootElement(name =「ProductRegistration」) @XmlType(namespace =「http://www.mywebpage.com/schemas/provider-framework/pdi/2」) public class ProductRegistration { .... – Nacho321