P
P
psvm2019-06-09 16:06:39
Java
psvm, 2019-06-09 16:06:39

SOAP web service sends unexpected element. How to properly process the response from the service in my case?

Hello!
The bottom line is this: there is a web service that I call and get a response. But there is an unexpected namespace in the response

Unmarshalling Error: unexpected element (uri:"urn:otrs-com:soap:functions", local:"SessionID"). Expected elements are <{}Error>,<{}SessionID>

The source code generated by cxf-codegen-plugin does not have this namespace. If it is written manually in the XmlRootElement of the generated class, then the answer is successfully parsed. When regenerating classes, I will lose all the changes accordingly.
What is the best practice in such situations, what is the best thing to do?
Thank you.
The same generated response class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "sessionID",
    "error"
})
@XmlRootElement(name = "SessionCreateResponse")
public class SessionCreateResponse {

    @XmlElement(name = "SessionID", required = true)
    protected String sessionID;
    @XmlElement(name = "Error")
    protected OTRSError error;

    /**
     * Gets the value of the sessionID property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSessionID() {
        return sessionID;
    }

    /**
     * Sets the value of the sessionID property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSessionID(String value) {
        this.sessionID = value;
    }

    /**
     * Gets the value of the error property.
     * 
     * @return
     *     possible object is
     *     {@link OTRSError }
     *     
     */
    public OTRSError getError() {
        return error;
    }

    /**
     * Sets the value of the error property.
     * 
     * @param value
     *     allowed object is
     *     {@link OTRSError }
     *     
     */
    public void setError(OTRSError value) {
        this.error = value;
    }

}

Content of package-info
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.otrs.org/TicketConnector/")
package org.otrs.ticketconnector;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question