Axial depersonalization 2

I have Java code that accepts an XML (SOAP) message and returns a deserialized object:

public static <T> T deserializeObject(String xml, Class<T> clazz) throws AxisFault, Exception {
    assert xml != null : "xml != null";
    assert clazz != null : "clazz != null";

    T result = null;
    try {
        Message message = new Message(SOAP_START + xml + SOAP_END);
        result = (T)message.getSOAPEnvelope().getFirstBody().getObjectValue(clazz);
    } catch (Exception e) {
        // most likely namespace error due to removed namespaces
        Message message = new Message(SOAP_START_XSI + xml + SOAP_END);
        result = (T)message.getSOAPEnvelope().getFirstBody().getObjectValue(clazz);
    }
       return result;
    }

However, this code only works with Axis 1.4 :-( Can someone help me with this code to work with Axis 2?

In fact, I just need to know what to replace import org.apache.axis.Messagewith? Thanks in advance.

+3
source share
1 answer

Each message inside the Axis2 engine is wrapped inside a MessageContext object. When a SOAP message arrives at the system or is ready to be sent, we create an AXIOM object model for the SOAP message.

(, AXIOM AXIOM). AXIOM . , SOAP- Axis2.

// if you are within a handler, reference to the message context 
MessageContext messageContext; 

Handler.invoke(MessageContext).

SOAPEnvelope soapEnvelope = messageContext.getEnvelope();

: javax.xml.soap SOAPEnvelope

Axis2

+2

Source: https://habr.com/ru/post/1788148/


All Articles