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;
}
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;
}
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;
}
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;
}
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));
}
Aggregations