1
我是CXF和JAXB的新手。我正尝试在CXF上使用eclipse来从Java类(自下而上)生成WSDL。如何避免CXF生成单独的类而不是使用退出XMLRootElement类(JAXB类)
创建接口作为研究员。
@WebService(name = "EBMData", targetNamespace = "http://business.kp.org/")
public interface EBMData {
@WebMethod
public @WebResult OPStatusDetails addEBMFields(InputFields fields);
@WebMethod
public @WebResult OPStatusDetails addOLIs(InputOLIs olis);
}
请求XML JAXB类是如下
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="InputFields")
@XmlRootElement(name="InputFields")
public class InputFields {
@XmlElement(name="FieldName", required=true)
String fieldName;
@XmlElement(name="Oli", required=true)
List<String> olis;
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public List<String> getOlis() {
return olis;
}
public void setOlis(List<String> olis) {
this.olis = olis;
}
}
响应XML JAXB类是如下
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="OPStatusDetails")
@XmlRootElement
public class OPStatusDetails {
@XmlElement(name="returnMessage", required=true)
String returnMessage;
public String getReturnCode() {
return returnMessage;
}
public void setReturnCode(String returnMessage) {
this.returnMessage = returnMessage;
}
}
一旦上面的类被创建,用于新建 - > Web服务,并且使用自下而上的方法选项。并生成WSDL。
一旦生成WSDL,可以注意到一个新的包被创建。与文件AddEBMFields.java
@XmlRootElement(name = "addEBMFields", namespace = "http://business.kp.org/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addEBMFields", namespace = "http://business.kp.org/")
public class AddEBMFields {
@XmlElement(name = "arg0")
private org.kp.business.xmls.InputFields arg0;
public org.kp.business.xmls.InputFields getArg0() {
return this.arg0;
}
public void setArg0(org.kp.business.xmls.InputFields newArg0) {
this.arg0 = newArg0;
}
}
和AddEBMFieldsResponse.java
@XmlRootElement(name = "addEBMFieldsResponse", namespace = "http://business.kp.org/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addEBMFieldsResponse", namespace = "http://business.kp.org/")
public class AddEBMFieldsResponse {
@XmlElement(name = "return")
private org.kp.business.xmls.OPStatusDetails _return;
public org.kp.business.xmls.OPStatusDetails getReturn() {
return this._return;
}
public void setReturn(org.kp.business.xmls.OPStatusDetails new_return) {
this._return = new_return;
}
}
由于这些文件我的要求是XML生成的,而不是为arg0字段,如下所示,它需要从InputFields.java引用。你能帮忙吗?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bus="http://business.kp.org/">
<soapenv:Header/>
<soapenv:Body>
<bus:addEBMFields>
<!--Optional:-->
<arg0>
<FieldName>?</FieldName>
<!--1 or more repetitions:-->
<Oli>?</Oli>
<Oli>?</Oli>
<Oli>?</Oli>
</arg0>
</bus:addEBMFields>
</soapenv:Body>
</soapenv:Envelope>
而且还我想如T
o know how my JAXB class should for the following soap request xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bus="http://business.kp.org/">
<soapenv:Header/>
<soapenv:Body>
<bus:addEBMFields>
<!--Optional:-->
<FieldName>?</FieldName>
<!--1 or more repetitions:-->
<Oli>?</Oli>
<Oli>?</Oli>
<Oli>?</Oli>
</bus:addEBMFields>
</soapenv:Body>
</soapenv:Envelope>