use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.
the class ProviderMessageTestCase method testProviderMessage.
@Test
@RunAsClient
public void testProviderMessage() throws Exception {
SOAPMessage reqMsg = getRequestMessage();
SOAPEnvelope reqEnv = reqMsg.getSOAPPart().getEnvelope();
URL epURL = baseURL;
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage resMsg = con.call(reqMsg, epURL);
SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = resEnv.getHeader();
if (soapHeader != null)
soapHeader.detachNode();
assertEquals(reqEnv, resEnv);
}
use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.
the class ClientHandler method handleInbound.
@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
try {
SOAPMessage soapMessage = msgContext.getMessage();
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
String nsURI = soapEnvelope.getNamespaceURI();
SOAPElement soapElement = (SOAPElement) soapMessage.getSOAPBody().getChildElements().next();
soapElement = (SOAPElement) soapElement.getChildElements().next();
String value = soapElement.getValue();
soapElement.setValue(value + ":" + nsURI);
return true;
} catch (SOAPException ex) {
throw new WebServiceException(ex);
}
}
use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.
the class ServerHandler method handleInbound.
@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
try {
SOAPMessage soapMessage = msgContext.getMessage();
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
nsURI = soapEnvelope.getNamespaceURI();
return true;
} catch (SOAPException ex) {
throw new WebServiceException(ex);
}
}
use of javax.xml.soap.SOAPEnvelope in project Payara by payara.
the class WebServicesDelegateImpl method getName.
private Name getName(SOAPMessage message) {
Name rvalue = null;
SOAPPart soap = message.getSOAPPart();
if (soap != null) {
try {
SOAPEnvelope envelope = soap.getEnvelope();
if (envelope != null) {
SOAPBody body = envelope.getBody();
if (body != null) {
Iterator it = body.getChildElements();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof SOAPElement) {
rvalue = ((SOAPElement) o).getElementName();
break;
}
}
}
}
} catch (SOAPException se) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "WSS: Unable to get SOAP envelope", se);
}
}
}
return rvalue;
}
use of javax.xml.soap.SOAPEnvelope in project openhab1-addons by openhab.
the class Tr064Comm method constructTr064Msg.
/***
* sets all required namespaces and prepares the SOAP message to send
* creates skeleton + body data
*
* @param bodyData is attached to skeleton to form entire SOAP message
* @return ready to send SOAP message
*/
private SOAPMessage constructTr064Msg(SOAPBodyElement bodyData) {
SOAPMessage soapMsg = null;
try {
MessageFactory msgFac;
msgFac = MessageFactory.newInstance();
soapMsg = msgFac.createMessage();
soapMsg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
soapMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
SOAPPart part = soapMsg.getSOAPPart();
// valid for entire SOAP msg
String namespace = "s";
// create suitable fbox envelope
SOAPEnvelope envelope = part.getEnvelope();
envelope.setPrefix(namespace);
// delete standard namespace which was already set
envelope.removeNamespaceDeclaration("SOAP-ENV");
envelope.addNamespaceDeclaration(namespace, "http://schemas.xmlsoap.org/soap/envelope/");
Name nEncoding = envelope.createName("encodingStyle", namespace, "http://schemas.xmlsoap.org/soap/encoding/");
envelope.addAttribute(nEncoding, "http://schemas.xmlsoap.org/soap/encoding/");
// create empty header
SOAPHeader header = envelope.getHeader();
header.setPrefix(namespace);
// create body with command based on parameter
SOAPBody body = envelope.getBody();
body.setPrefix(namespace);
// bodyData already prepared. Needs only be added
body.addChildElement(bodyData);
} catch (Exception e) {
logger.error("Error creating SOAP message for fbox request with data {}", bodyData);
e.printStackTrace();
}
return soapMsg;
}
Aggregations