Search in sources :

Example 1 with SOAPElement

use of jakarta.xml.soap.SOAPElement in project openmq by eclipse-ee4j.

the class MessageUtil method getJMSChildElement.

public static SOAPElement getJMSChildElement(SOAPElement soapElement, String localName) throws SOAPException {
    SOAPElement se = null;
    Name name = createJMSName(localName);
    Iterator it = soapElement.getChildElements(name);
    if (it.hasNext()) {
        se = (SOAPElement) it.next();
    }
    return se;
}
Also used : SOAPElement(jakarta.xml.soap.SOAPElement) Iterator(java.util.Iterator) Name(jakarta.xml.soap.Name)

Example 2 with SOAPElement

use of jakarta.xml.soap.SOAPElement in project openmq by eclipse-ee4j.

the class MessageUtil method addJMSChildElement.

public static SOAPElement addJMSChildElement(SOAPElement element, String localName) throws SOAPException {
    Name name = createJMSName(localName);
    SOAPElement se = element.addChildElement(name);
    return se;
}
Also used : SOAPElement(jakarta.xml.soap.SOAPElement) Name(jakarta.xml.soap.Name)

Example 3 with SOAPElement

use of jakarta.xml.soap.SOAPElement in project openmq by eclipse-ee4j.

the class MessageUtil method getServiceAttribute.

public static String getServiceAttribute(SOAPMessage soapm, String localName) throws SOAPException {
    SOAPHeaderElement mh = getMessageHeaderElement(soapm);
    SOAPElement serviceElement = getJMSChildElement(mh, Constants.SERVICE);
    if (serviceElement == null) {
        throw new SOAPException("Message does not contain a Service SOAP Header Element.");
    }
    Name n = createJMSName(localName);
    String value = serviceElement.getAttributeValue(n);
    return value;
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) SOAPException(jakarta.xml.soap.SOAPException) SOAPElement(jakarta.xml.soap.SOAPElement) Name(jakarta.xml.soap.Name)

Example 4 with SOAPElement

use of jakarta.xml.soap.SOAPElement in project openmq by eclipse-ee4j.

the class MessageUtil method createResponseMessage2_save.

public static SOAPMessage createResponseMessage2_save(SOAPMessage req, SOAPMessage resp) throws SOAPException {
    // create message
    // SOAPMessage ackm = newMessageInstance();
    checkJMSMessageHeader(resp);
    // set ref to mid
    SOAPHeaderElement messageHeader = getMessageHeaderElement(req);
    String mid = getJMSChildElementValue(messageHeader, Constants.MESSAGE_ID);
    SOAPHeaderElement ackMsgHdr = getMessageHeaderElement(resp);
    SOAPElement se = getJMSChildElement(ackMsgHdr, Constants.REF_TO_MESSAGE_ID);
    se.setValue(mid);
    // get <from> value from req msg
    String from = getJMSChildElementValue(messageHeader, Constants.FROM);
    // get <to> element from resp msg
    SOAPElement toEle = getJMSChildElement(ackMsgHdr, Constants.TO);
    toEle.setValue(from);
    resp.saveChanges();
    return resp;
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) SOAPElement(jakarta.xml.soap.SOAPElement)

Example 5 with SOAPElement

use of jakarta.xml.soap.SOAPElement in project metro-jax-ws by eclipse-ee4j.

the class SAAJFactoryTest method testResetDefaultNamespaceToGlobalWithJDK.

/**
 * Test whether SAAJFactory.readAsSOAPMessage can handle default namespace reset correctly.
 *
 * <p>
 * This test emulates JDK-8159058 issue. The issue is that the default namespace reset was not respected
 * with built-in JDK XML input factory (it worked well with woodstax).
 * </p>
 *
 * <p>
 * This test operates against JDK XMLInputFactory.
 * </p>
 */
public void testResetDefaultNamespaceToGlobalWithJDK() throws Exception {
    XMLInputFactory inputFactory = getBuiltInJdkXmlInputFactory();
    XMLStreamReader envelope = inputFactory.createXMLStreamReader(new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<s:Body>" + "<SampleServiceRequest xmlns=\"http://sample.ex.org/\">" + "<RequestParams xmlns=\"\">" + "<Param1>hogehoge</Param1>" + "<Param2>fugafuga</Param2>" + "</RequestParams>" + "</SampleServiceRequest>" + "</s:Body>" + "</s:Envelope>"));
    StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null);
    SAAJFactory saajFac = new SAAJFactory();
    SOAPMessage soapMessage = saajFac.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage);
    // check object model
    SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild();
    assertEquals("SampleServiceRequest", request.getLocalName());
    assertEquals("http://sample.ex.org/", request.getNamespaceURI());
    SOAPElement params = (SOAPElement) request.getFirstChild();
    assertEquals("RequestParams", params.getLocalName());
    assertNull(params.getNamespaceURI());
    SOAPElement param1 = (SOAPElement) params.getFirstChild();
    assertEquals("Param1", param1.getLocalName());
    assertNull(param1.getNamespaceURI());
    Element param2 = (Element) params.getChildNodes().item(1);
    assertEquals("Param2", param2.getLocalName());
    assertNull(param2.getNamespaceURI());
    // check the message as string
    assertEquals("<SampleServiceRequest xmlns=\"http://sample.ex.org/\">" + "<RequestParams xmlns=\"\">" + "<Param1>hogehoge</Param1>" + "<Param2>fugafuga</Param2>" + "</RequestParams>" + "</SampleServiceRequest>", nodeToText(request));
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) SAAJFactory(com.sun.xml.ws.api.message.saaj.SAAJFactory) SOAPElement(jakarta.xml.soap.SOAPElement) Element(org.w3c.dom.Element) StringReader(java.io.StringReader) SOAPElement(jakarta.xml.soap.SOAPElement) StreamMessage(com.sun.xml.ws.message.stream.StreamMessage) SOAPMessage(jakarta.xml.soap.SOAPMessage) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

SOAPElement (jakarta.xml.soap.SOAPElement)24 SOAPMessage (jakarta.xml.soap.SOAPMessage)12 SOAPException (jakarta.xml.soap.SOAPException)10 SOAPBody (jakarta.xml.soap.SOAPBody)9 Name (jakarta.xml.soap.Name)7 SOAPHeaderElement (jakarta.xml.soap.SOAPHeaderElement)6 MessageFactory (jakarta.xml.soap.MessageFactory)5 QName (javax.xml.namespace.QName)5 Detail (jakarta.xml.soap.Detail)3 SOAPEnvelope (jakarta.xml.soap.SOAPEnvelope)3 SOAPFault (jakarta.xml.soap.SOAPFault)3 Iterator (java.util.Iterator)3 SAAJFactory (com.sun.xml.ws.api.message.saaj.SAAJFactory)2 StreamMessage (com.sun.xml.ws.message.stream.StreamMessage)2 SOAPFactory (jakarta.xml.soap.SOAPFactory)2 SOAPPart (jakarta.xml.soap.SOAPPart)2 ProtocolException (jakarta.xml.ws.ProtocolException)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringReader (java.io.StringReader)2