Java 驼峰CXF-操作输出解组错误
我有wsdl(我无法更改)-这是必需的部分:Java 驼峰CXF-操作输出解组错误,java,apache-camel,cxf,wsdl2java,Java,Apache Camel,Cxf,Wsdl2java,我有wsdl(我无法更改)-这是必需的部分: <xs:complexType name="out"> <xs:sequence> <xs:element name="isValid" type="xs:boolean" minOccurs="0"/> <xs:element name="errorMessage"
<xs:complexType name="out">
<xs:sequence>
<xs:element name="isValid"
type="xs:boolean"
minOccurs="0"/>
<xs:element name="errorMessage"
type="xs:string"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="GetDataResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return"
type="tns:out"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<message name="GetDataResponseMessage">
<part name="parameters"
element="tns:GetDataResponse"/>
</message>
<operation name="GetData">
<output message="tns:GetDataResponseMessage"/>
</operation>
我创建CXF端点:
CxfEndpoint endpoint = new CxfEndpoint();
endpoint.setAddress("address");
endpoint.setServiceClass(MyService.class);
endpoint.setWsdlURL(WSDL_LOCATION);
我称之为驼峰行动:
.setHeader(CxfConstants.OPERATION_NAMESPACE, namespace())
.setHeader(CxfConstants.OPERATION_NAME, operationName())
.to(endpoint)
服务返回以下响应主体:
<m:GetDataResponse xmlns:m="...">
<m:return xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<isValid>true</isValid>
<errorMessage>sample error</errorMessage>
</m:return>
</m:GetDataResponse>
您应该发布“Out”类的定义,它似乎遗漏了一些名称空间信息。是的,Out类中没有信息:受保护的布尔值是有效的;保护字符串错误消息;
<m:GetDataResponse xmlns:m="...">
<m:return xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<isValid>true</isValid>
<errorMessage>sample error</errorMessage>
</m:return>
</m:GetDataResponse>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "out", propOrder = {
"isValid",
"errorMessage"
})
public class Out {
protected Boolean isValid;
protected String errorMessage;
/**
* Gets the value of the isValid property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isIsValid() {
return isValid;
}
/**
* Sets the value of the isValid property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setIsValid(Boolean value) {
this.isValid = value;
}
/**
* Gets the value of the errorMessage property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getErrorMessage() {
return errorMessage;
}
/**
* Sets the value of the errorMessage property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setErrorMessage(String value) {
this.errorMessage = value;
}
/**
* Generates a String representation of the contents of this type.
* This is an extension method, produced by the 'ts' xjc plugin
*
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, JAXBToStringStyle.DEFAULT_STYLE);
}
}