При использовании веб-службы с CXF 2.1.4 (сгенерированный клиент) у меня возникают проблемы при получении ответа на основе следующего фрагмента XSD в WSDL. CXF Генерирует список, представляющий его, но когда я выполняю службу, ответ становится нулевым. Я использовал wireshark для того, что я получал, и действительно, XMl отвечает, как и ожидалось, но CXF просто дает мне нулевой объект. Предоставленные сервисы реализованы с использованием .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>
Ниже приведен сгенерированный Java-класс, который должен «содержать» ответ от веб-службы
<code>/*
* 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>
*
*
*
* /
@XmlAccessorType (XmlAccessType.FIELD)
@XmlType (name = "", propOrder = {
"GestionSIIFResult"
})
@XmlRootElement (name = "GestionSIIFResponse")
открытый класс GestionSIIFResponse {
@XmlElement (name = "GestionSIIFResult")
защищенный GestionSIIFResponse.GestionSIIFResult gestionSIIFResult;
/ **
* Получает значение свойства gestionSIIFResult.
*
* @вернуть
* возможный объект
* {@link GestionSIIFResponse.GestionSIIFResult}
*
* /
public GestionSIIFResponse.GestionSIIFResult getGestionSIIFResult () {
вернуть gestionSIIFResult;
}
/ **
* Устанавливает значение свойства gestionSIIFResult.
*
* @param value
* разрешенный объект
* {@link GestionSIIFResponse.GestionSIIFResult}
*
* /
public void setGestionSIIFResult (значение GestionSIIFResponse.GestionSIIFResult) {
this.gestionSIIFResult = значение;
}
/ **
*
Java-класс для анонимного сложного типа.
*
*
Следующий фрагмент схемы определяет ожидаемое содержимое, содержащееся в этом классе.
*
*
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
*
*
*
* /
@XmlAccessorType (XmlAccessType.FIELD)
@XmlType (name = "", propOrder = {
«Содержание»
})
открытый статический класс GestionSIIFResult {
@XmlMixed
@XmlAnyElement (lax = true)
защищенный список содержание;
/ **
* Получает значение свойства содержимого.
*
*
* Этот метод доступа возвращает ссылку на текущий список,
* не снимок. Поэтому любые изменения, которые вы вносите в
* возвращенный список будет присутствовать внутри объекта JAXB.
* Вот почему нет метода set
для свойства content.
*
*
* Например, чтобы добавить новый элемент, сделайте следующее:
*
* getContent().add(newItem);
*
*
*
*
* Объекты следующих типов разрешены в списке
* {@link Object}
* {@link String}
*
*
* /
общедоступный список getContent () {
if (content == null) {
content = new ArrayList ();
}
вернуть 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
);*/
}