2011-02-04 50 views
3

當使用CXF 2.1.4(生成的客戶端)使用webserice時,我在根據WSDL中的以下XSD片段獲取響應時遇到問題。 CXF生成一個表示它的列表,但是當我執行該服務時,響應爲空。我使用wireshark來收集我正在收集的信息,事實上XMl的響應正如預期的那樣,但CXF只是給了我一個null對象。公開的服務使用.NET實現。如何使用CXF生成的客戶端讀取xs:任何響應?

在響應對象的XSD下面。而

<!--- chunk --> 
    <s:element name="GestionSIIFResponse"> 
    <s:complexType> 
     <s:sequence> 
     <s:element minOccurs="0" maxOccurs="1" name="GestionSIIFResult"> 
      <s:complexType mixed="true"> 
      <s:sequence> 
       <s:any /> 
      </s:sequence> 
      </s:complexType> 
     </s:element> 
     </s:sequence> 
    </s:complexType> 
    </s:element> 
    <!--- chunk --> 

這是我從服務獲取響應:

<soap:Body> 
    <GestionSIIFResponse xmlns="http://tempuri.org/"> 
    <GestionSIIFResult> 
     <Siif xmlns=""> 
      <Pagina>NUY001B</Pagina> 
      <Exitos> 
       <ExitoRep> 
       <CodExito>SIL0082</CodExito> 
       <DesExito>La transaccion se ha aplicado satisfactoriamente</DesExito> 
       </ExitoRep> 
      </Exitos> 
      <InformacionCab/> 
      <Repeticiones/> 
     </Siif> 
    </GestionSIIFResult> 
    </GestionSIIFResponse> 

下面是生成的Java類應該「持有」從Web服務的響應

/* 
* some imports here 
*/ 

/** 
* <p>Java class for anonymous complex type. 
* 
* <p>The following schema fragment specifies the expected content contained within this class. 
* 
* <pre> 
* &lt;complexType> 
* &lt;complexContent> 
*  &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
*  &lt;sequence> 
*   &lt;element name="GestionSIIFResult" minOccurs="0"> 
*   &lt;complexType> 
*    &lt;complexContent> 
*    &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
*     &lt;sequence> 
*     &lt;any/> 
*     &lt;/sequence> 
*    &lt;/restriction> 
*    &lt;/complexContent> 
*   &lt;/complexType> 
*   &lt;/element> 
*  &lt;/sequence> 
*  &lt;/restriction> 
* &lt;/complexContent> 
* &lt;/complexType> 
* </pre> 
* 
* 
*/ 
@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "", propOrder = { 
    "gestionSIIFResult" 
}) 
@XmlRootElement(name = "GestionSIIFResponse") 
public class GestionSIIFResponse { 

    @XmlElement(name = "GestionSIIFResult") 
    protected GestionSIIFResponse.GestionSIIFResult gestionSIIFResult; 

    /** 
    * Gets the value of the gestionSIIFResult property. 
    * 
    * @return 
    *  possible object is 
    *  {@link GestionSIIFResponse.GestionSIIFResult } 
    *  
    */ 
    public GestionSIIFResponse.GestionSIIFResult getGestionSIIFResult() { 
     return gestionSIIFResult; 
    } 

    /** 
    * Sets the value of the gestionSIIFResult property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link GestionSIIFResponse.GestionSIIFResult } 
    *  
    */ 
    public void setGestionSIIFResult(GestionSIIFResponse.GestionSIIFResult value) { 
     this.gestionSIIFResult = value; 
    } 


    /** 
    * <p>Java class for anonymous complex type. 
    * 
    * <p>The following schema fragment specifies the expected content contained within this class. 
    * 
    * <pre> 
    * &lt;complexType> 
    * &lt;complexContent> 
    *  &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
    *  &lt;sequence> 
    *   &lt;any/> 
    *  &lt;/sequence> 
    *  &lt;/restriction> 
    * &lt;/complexContent> 
    * &lt;/complexType> 
    * </pre> 
    * 
    * 
    */ 
    @XmlAccessorType(XmlAccessType.FIELD) 
    @XmlType(name = "", propOrder = { 
     "content" 
    }) 
    public static class GestionSIIFResult { 

     @XmlMixed 
     @XmlAnyElement(lax = true) 
     protected List<Object> content; 

     /** 
     * Gets the value of the content property. 
     * 
     * <p> 
     * This accessor method returns a reference to the live list, 
     * not a snapshot. Therefore any modification you make to the 
     * returned list will be present inside the JAXB object. 
     * This is why there is not a <CODE>set</CODE> method for the content property. 
     * 
     * <p> 
     * For example, to add a new item, do as follows: 
     * <pre> 
     * getContent().add(newItem); 
     * </pre> 
     * 
     * 
     * <p> 
     * Objects of the following type(s) are allowed in the list 
     * {@link Object } 
     * {@link String } 
     * 
     * 
     */ 
     public List<Object> getContent() { 
      if (content == null) { 
       content = new ArrayList<Object>(); 
      } 
      return this.content; 
     } 

    } 

} 

以下生成的代理服務器端口

/** 
* This class was generated by Apache CXF 2.1.4 
* Mon Jan 17 12:02:39 COT 2011 
* Generated source version: 2.1.4 
* 
*/ 

@WebService(targetNamespace = "http://tempuri.org/", name = "WSGYG05Soap") 
@XmlSeeAlso({ObjectFactory.class}) 
public interface WSGYG05Soap { 

    @ResponseWrapper(localName = "GestionSIIFResponse", targetNamespace = "http://tempuri.org/", className = "suramericana.banw.servicios.tuya.v2.GestionSIIFResponse"/*"org.tempuri.GestionSIIFResponse"*/) 
    @RequestWrapper(localName = "GestionSIIF", targetNamespace = "http://tempuri.org/", className = "suramericana.banw.servicios.tuya.v2.GestionSIIF"/*"org.tempuri.GestionSIIF"*/) 
    @WebResult(name = "GestionSIIFResult", targetNamespace = "http://tempuri.org/") 
    @WebMethod(operationName = "GestionSIIF", action = "http://tempuri.org/GestionSIIF") 
    public GestionSIIFResponse.GestionSIIFResult gestionSIIF(
     @WebParam(name = "Peticion", targetNamespace = "http://tempuri.org/") 
     GestionSIIF.Peticion peticion, 
     @WebParam(header = true,name="CabAut", targetNamespace = "http://tempuri.org/") 
     CabAut cabAut 
    ); 
    //@ResponseWrapper(localName = "GestionSIIFResponse", targetNamespace = "http://tempuri.org/", className = "suramericana.banw.servicios.tuya.v2.GestionSIIFResponse"/*"org.tempuri.GestionSIIFResponse"*/) 
    //@RequestWrapper(localName = "GestionSIIF", targetNamespace = "http://tempuri.org/", className = "suramericana.banw.servicios.tuya.v2.GestionSIIF"/*"org.tempuri.GestionSIIF"*/) 
    //@WebResult(name = "GestionSIIFResult", targetNamespace = "http://tempuri.org/") 
    //@WebMethod(operationName = "GestionSIIF", action = "http://tempuri.org/GestionSIIF") 
    /*public GestionSIIFResponse.GestionSIIFResult gestionSIIF(
     @WebParam(name = "Peticion", targetNamespace = "http://tempuri.org/") 
     GestionSIIF.Peticion peticion, 
     @WebParam(header = true,name="CabAut", targetNamespace = "http://tempuri.org/") 
     CabAut cabAut 
    );*/ 
} 
+0

您可以粘貼從此wsdl生成的JAXB/JAX-WS註釋類/接口嗎? – whaley 2011-02-04 15:27:53

+0

確定完成!告訴我你是否需要更多信息。 :-D – mfcabrera 2011-02-04 16:01:09

回答

1

List通過getContent()可能潛在含有多種org.w3c.dom.ElementJAXBElement,或完全綁定類返回。

如果JAXB方面不承認<Siif>元素,然後將JAXB發揮它的安全,並與代表<Siif>及其子單Element對象填充列表。如果它確實識別它們,它將包含 JAXBElement which in turn contains a Siif object, or it may contain the Siif對象直接。

Java無法在其類型中表示該類型,因此只能綁定到List<Object>

相關問題