What would the class for the web service method look like?
I got a WSDL partner for my web services. I am not very knowledgeable about web services, so I am a little skeptical about WSDL. One particular method allows us to get some information, but we can only use it once (or face a penalty). The problem is that it is being returned as "raw XML" inside the SOAP response, so I'm not entirely sure what will be returned and hence how to deal with it and store it properly.
The relevant part of the WSDL is this:
<s:element name="MethodResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="MethodResult">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
wsimport created the following class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"methodResult"
})
@XmlRootElement(name = "MethodResponse")
public class MethodResponse {
@XmlElement(name = "MethodResult")
protected MethodResponse.MethodResult methodResult;
public MethodResponse.MethodResult getMethodResult() {
return methodResult;
}
public void setMethodResult(MethodResponse.MethodResult value) {
this.methodResult = value;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
public static class MethodResult {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
}
}
So the question is, what will be the class of objects returned by getContent ()? The C # sample they provided doesn't have a MethodResponse or MethodResult, but the return type is just XmlNode.
By the way, although the code was generated by wsimport, the application uses Axis2. Other available methods return matching objects.
A simple test (example of a server running on Mono) was throwing an exception on the client side:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could not deserialize Soap message
Thanks in advance.
source to share
Mixed content elements are a little tricky in JAXB.
Yours List<Object>
could be a combination:
-
String
to present the text content in the element -
JAXBElement
to represent element types known to the schema that are not annotated@XmlRootElement
- Instances of classes known to the context that have
@XmlRootAnnotation
-
org.w3c.dom.Element
if the content is unknown to the context
The javadoc for @XmlMixed
goes in more detail, but at the heart of it.
source to share