Search in sources :

Example 16 with SOAPElement

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

the class MessageUtil method getJMSChildElementValue.

public static String getJMSChildElementValue(SOAPElement soapElement, String localName) throws SOAPException {
    String value = null;
    SOAPElement se = getJMSChildElement(soapElement, localName);
    if (se != null) {
        value = se.getValue();
    }
    return value;
}
Also used : SOAPElement(jakarta.xml.soap.SOAPElement)

Example 17 with SOAPElement

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

the class MessageUtil method setService.

/**
 * XXX chiaming 06/19/2008- OLD -- to be removed
 */
public static void setService(SOAPMessage soapm, String value) throws SOAPException {
    SOAPHeaderElement mh = MessageUtil.getMessageHeaderElement(soapm);
    SOAPElement service = MessageUtil.addJMSChildElement(mh, Constants.SERVICE);
    service.setValue(value);
    soapm.saveChanges();
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) SOAPElement(jakarta.xml.soap.SOAPElement)

Example 18 with SOAPElement

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

the class MUTube method addHeader.

private static void addHeader(Message m, Set<QName> notUnderstoodHeaders) throws SOAPException {
    for (QName qname : notUnderstoodHeaders) {
        SOAPElement soapEl = SOAPVersion.SOAP_12.getSOAPFactory().createElement(MU_HEADER_DETAIL);
        soapEl.addNamespaceDeclaration("abc", qname.getNamespaceURI());
        soapEl.setAttribute("qname", "abc:" + qname.getLocalPart());
        Header header = new DOMHeader<Element>(soapEl);
        m.getHeaders().add(header);
    }
}
Also used : DOMHeader(com.sun.xml.ws.message.DOMHeader) Header(com.sun.xml.ws.api.message.Header) QName(javax.xml.namespace.QName) SOAPElement(jakarta.xml.soap.SOAPElement) DOMHeader(com.sun.xml.ws.message.DOMHeader)

Example 19 with SOAPElement

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

the class SOAPFaultBuilderTest method createFault.

private static SOAPFault createFault(SOAPVersion soapVersion) throws Exception {
    SOAPFactory fac = soapVersion.getSOAPFactory();
    SOAPFault sf = fac.createFault("This is a fault.", soapVersion.faultCodeClient);
    Detail d = sf.addDetail();
    SOAPElement de = d.addChildElement(DETAIL1_QNAME);
    de.addAttribute(new QName("", "msg1"), "This is the first detail message.");
    de = d.addChildElement(DETAIL2_QNAME);
    de.addAttribute(new QName("", "msg2"), "This is the second detail message.");
    return sf;
}
Also used : QName(javax.xml.namespace.QName) SOAPElement(jakarta.xml.soap.SOAPElement) SOAPFault(jakarta.xml.soap.SOAPFault) SOAPFactory(jakarta.xml.soap.SOAPFactory) Detail(jakarta.xml.soap.Detail)

Example 20 with SOAPElement

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

the class SAAJFactoryTest method testResetDefaultNamespaceToGlobalWithWoodstax.

/**
 * 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 woodstax.
 * </p>
 */
public void testResetDefaultNamespaceToGlobalWithWoodstax() throws Exception {
    XMLInputFactory inputFactory = XMLInputFactory.newFactory();
    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