当使用CXF 2.1.4(生成的客户端)使用webserice时,我在根据WSDL中的以下XSD片段获取响应时遇到问题。 CXF生成表示它的List,但是当我执行服务时,响应为空。我使用wireshark来处理我正在回收的内容,实际上响应XMl正如预期的那样,但是CXF只是给了我null对象。公开的服务是使用.NET实现的。
在响应对象的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>
以下是应该“保留”来自Web服务的响应的Generated java类
/*
* some imports here
*/
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="GestionSIIFResult" minOccurs="0">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </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>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any/>
* </sequence>
* </restriction>
* </complexContent>
* </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 :(得分:1)
List
返回的getContent()
可能包含各种org.w3c.dom.Element
,JAXBElement
或完全绑定的类。
如果JAXB上下文无法识别<Siif>
元素,那么JAXB将安全地播放它并使用表示Element
及其子节点的单个<Siif>
对象填充列表。如果 识别它们,它将直接包含 JAXBElement
which in turn contains a
Siif object, or it may contain the
Siif`对象。
Java无法在其类型中表达这种变化,因此只能绑定到List<Object>
。