当XMLElement属于响应类型时,我没有从Web服务获得响应
我尝试删除响应类型下的XML元素,并且网络服务响应良好。但是,只要将XML元素保留在webservice响应类型内,该服务就不会响应,而我只会收到超时错误。这意味着服务器无法理解如何理解响应类型?我在注释上做错什么了吗?我找不到这个问题的任何原因。 我尝试将Item类保留在Root类的内部以及外部。没有回应。
ResponseType和基础元素类型:
@XmlAccessorType(XmlAccessType.FIELD)
public class InterpreterResponse {
@XmlElement
protected Root root;
@XmlAttribute
protected String message;
public Root getRoot() {
return root;
}
public void setRoot(Root root) {
this.Root = root;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class Root {
@XmlElement
List<Item> item;
public List<Item> getItem() {
if (item == null) {
item = new ArrayList<>();
}
return item;
}
public void setItem(List<Item> items) {
item = items;
}
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public static class Item {
@XmlAttribute
String id;
@XmlAttribute
String appId;
@XmlAttribute
String parentAppId;
@XmlAttribute
String navtitle;
public String getId() {
return id != null ? id : "";
}
public void setId(String id) {
this.id = id;
}
public String getappId() {
return appId != null ? appId : "";
}
public void setappId(String appId) {
this.appId = appId;
}
public String getParentappId() {
return parentAppId != null ? parentAppId : "";
}
public void setParentappId(String parentAppId) {
this.parentAppId = parentAppId;
}
public String getNavtitle() {
return navtitle != null ? navtitle : "";
}
public void setNavtitle(String navtitle) {
this.navtitle = navtitle;
}
}
}
在实现端点中:
InterpreterResponse response = new InterpreterResponse();
Root root = new Root();
for (...) {
Item item = new Item();
item.setId("id");
...
root.getItem().add(item);
}
response.setRoot(root);
return response;
似乎已经生成了WSDL文件和模式:
<operation name="Interpreter">
<input message="tns:Interpreter" wsam:Action=".../InterpreterRequest"> </input>
<output message="tns:InterpreterResponse" wsam:Action=".../InterpreterResponse"> </output>
<fault name="javalinkException" message="tns:javalinkException" wsam:Action=".../javalinkException"> </fault>
</operation>
模式:
<xs:complexType name="InterpreterResponse">
<xs:complexContent>
<xs:sequence>
<xs:element name="root" type="ns1:root" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="message" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="root">
<xs:sequence>
<xs:element name="item" type="tns:item" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="item">
<xs:sequence>
<xs:element name="id" type="xs:string" minOccurs="0"/>
<xs:element name="navtitle" type="xs:string" minOccurs="0"/>
<xs:element name="parentAppId" type="xs:string" minOccurs="0"/>
<xs:element name="appId" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
我期望服务至少提供一些响应,而不是没有响应和超时。请帮助我了解我在做什么错。