本文整理汇总了Java中javax.xml.ws.handler.soap.SOAPMessageContext.get方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPMessageContext.get方法的具体用法?Java SOAPMessageContext.get怎么用?Java SOAPMessageContext.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.ws.handler.soap.SOAPMessageContext
的用法示例。
在下文中一共展示了SOAPMessageContext.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean request = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!request) {
try {
SOAPMessage msg = context.getMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPHeader header = env.getHeader();
if (header == null) {
header = env.addHeader();
return false;
}
Node node = (Node) header.getElementsByTagName("token").item(0);
String token = node.getChildNodes().item(0).getNodeValue();
if (token != null && token.equals("Kalango Lab")) {
System.out.println("Token válido");
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
return true;
}
示例2: logToSystemOut
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
private void logToSystemOut(SOAPMessageContext smc) {
if (LOGGER.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue())
sb.append("Missatge SOAP enviat: ");
else
sb.append("Missatge SOAP rebut: ");
SOAPMessage message = smc.getMessage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
message.writeTo(baos);
sb.append(baos.toString());
} catch (Exception ex) {
sb.append("Error al processar el missatge XML: " + ex.getMessage());
}
LOGGER.debug(sb.toString());
}
}
示例3: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext c) {
SOAPMessage msg = c.getMessage();
boolean request = ((Boolean) c.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));
try {
if (request) { // This is a request message.
// Write the message to the output stream
log.debug("Request:\n"
+ Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
}
else { // This is the response message
log.debug("Response:\n"
+ Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
}
}
catch (Exception e) {
log.error(e);
}
return Boolean.TRUE;
}
示例4: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!isRequest) { // only incoming messages
try {
SOAPMessage soapMsg = context.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
SOAPBody soapBody = soapEnv.getBody();
if (soapBody != null) {
// Should have a SOAPBody and a listall response...
NodeList nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_LIST_ALL_RESPONSE);
if (nodeList.getLength() > 0) { // check for listAllResponse
// tag first!
nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_ELEMENT);
recursiveRenamespace(nodeList); // renamespace...
soapMsg.saveChanges();
}
}
} catch (Exception e) {
catchMessages(e);
}
}
return true;
}
示例5: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!isRequest) { // only incoming messages
try {
SOAPMessage soapMsg = context.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
SOAPBody soapBody = soapEnv.getBody();
if (soapBody != null) {
// Should have a SOAPBody and a listall response...
NodeList nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDY_LIST_ALL_RESPONSE);
if (nodeList.getLength() > 0) { // check for listAllResponse
// tag first!
nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDIES_ELEMENT);
recursiveRenamespace(nodeList); // renamespace...
soapMsg.saveChanges();
}
}
} catch (Exception e) {
catchMessages(e);
}
}
return true;
}
示例6: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
public boolean handleMessage(SOAPMessageContext messagecontext) {
Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
try {
SOAPMessage soapMessage = messagecontext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
Node firstChild = soapBody.getFirstChild();
String timeStamp = getTimestamp();
String signature = getSignature(firstChild.getLocalName(), timeStamp, secretBytes);
appendTextElement(firstChild, "Signature", signature);
appendTextElement(firstChild, "Timestamp", timeStamp);
} catch(SOAPException se) {
throw new RuntimeException("SOAPException was thrown.", se);
}
}
return true;
}
示例7: logToSystemOut
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
/**
* Log message
* @param smc SOAPMessageContext
*/
private void logToSystemOut(SOAPMessageContext smc) {
Boolean outboundProperty = (Boolean)
smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue()) {
logger.info("Outbound: ");
} else {
logger.info("Inbound: ");
}
SOAPMessage message = smc.getMessage();
try {
ByteArrayOutputStream outString = new ByteArrayOutputStream();
message.writeTo(outString);
String strMsg = new String(outString.toByteArray());
logger.info("" + strMsg);
} catch (Exception e) {
logger.error("Exception in SOAP Handler #1: " + e);
}
}
示例8: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
boolean isResponse = Boolean.FALSE.equals(context.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY));
if (isResponse) {
QName action = (QName) context.get(SOAPMessageContext.WSDL_OPERATION);
if ("Create".equals(action.getLocalPart())) {
Iterator<?> childIter = getBodyChildren(context);
while(childIter.hasNext()) {
Object node = childIter.next();
if (node instanceof SOAPElement) {
SOAPElement el = (SOAPElement) node;
if ("Shell".equals(el.getLocalName())) {
childIter.remove();
}
}
}
}
}
return true;
}
示例9: handleInbound
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
log.info("handleInbound");
// legacy JBossWS-Native approach...
SOAPMessage soapMessage = msgContext.getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
String[] cookies = mimeHeaders.getHeader("Cookie");
// proper approach through MessageContext.HTTP_REQUEST_HEADERS
if (cookies == null) {
@SuppressWarnings("unchecked")
Map<String, List<String>> httpHeaders = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> l = httpHeaders.get("Cookie");
if (l != null && !l.isEmpty()) {
cookies = l.toArray(new String[l.size()]);
}
}
if (cookies != null && cookies.length == 1 && cookies[0].equals("client-cookie=true"))
setCookieOnResponse = true;
return true;
}
示例10: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (false == outboundProperty) {
this.inboundMessageAttachments = (Map<String, DataHandler>) context
.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
}
return true;
}
示例11: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@Override
public boolean handleMessage(final SOAPMessageContext msgCtx) {
// Indicator telling us which direction this message is going in
final Boolean outInd = (Boolean) msgCtx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
// Handler must only add security headers to outbound messages
if (outInd.booleanValue()) {
try {
// Get the SOAP Envelope
final SOAPEnvelope envelope = msgCtx.getMessage().getSOAPPart().getEnvelope();
// Header may or may not exist yet
SOAPHeader header = envelope.getHeader();
if (header == null)
header = envelope.addHeader();
// Add WSS Usertoken Element Tree
final SOAPElement security = header.addChildElement("Security", "wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
final SOAPElement userToken = security.addChildElement("UsernameToken", "wsse");
userToken.addChildElement("Username", "wsse").addTextNode(userId);
userToken.addChildElement("Password", "wsse").addAttribute(new QName("Type"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText").addTextNode(password);
} catch (final Exception e) {
e.printStackTrace();
return false;
}
}
return true;
}
示例12: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
/**
* The method is invoked for normal processing of outbound messages.
*
* @param context
* the message context.
* @return An indication of whether handler processing should continue for
* the current message. Return <code>true</code> to continue
* processing.
*
* @throws Exception
* Causes the JAX-WS runtime to cease fault message processing.
**/
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean request_p = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (request_p.booleanValue()) {
try {
SOAPMessage msg = context.getMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPHeader hdr = env.getHeader();
if (hdr == null) {
hdr = env.addHeader();
}
QName qname_user = new QName("http://com/auth/", "auth");
SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
helem_user.setActor(VERSION);
if (version != null && version.trim().length() != 0) {
helem_user.addTextNode(version);
}
msg.saveChanges();
message = soapMessage2String(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}
示例13: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
/**
* The method is invoked for normal processing of outbound messages.
*
* @param context
* the message context.
* @return An indication of whether handler processing should continue for
* the current message. Return <code>true</code> to continue
* processing.
*
* @throws Exception
* Causes the JAX-WS runtime to cease fault message processing.
**/
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean request_p = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (request_p.booleanValue()) {
try {
SOAPMessage msg = context.getMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPHeader hdr = env.getHeader();
if (hdr == null) {
hdr = env.addHeader();
}
QName qname_user = new QName("http://com/auth/", "auth");
SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
helem_user.setActor(VERSION);
if (version == null || version.trim().length() == 0) {
helem_user.addTextNode(apiVersionInfo.getProperty(VERSION));
} else {
helem_user.addTextNode(version);
}
msg.saveChanges();
message = soapMessage2String(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}
示例14: parseServiceName
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
public static String parseServiceName(SOAPMessageContext context) {
String serviceName = "";
QName serviceQName = (QName) context.get(MessageContext.WSDL_SERVICE);
if (serviceQName != null) {
serviceName = serviceQName.getLocalPart();
}
return serviceName;
}
示例15: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", })
@Override
public boolean handleMessage(SOAPMessageContext context) {
boolean isOut = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
// outbound
if (isOut == true) {
Map<String, List<String>> headers = (Map<String, List<String>>) context
.get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> ls = new ArrayList<String>();
ls.add(MonitorServerUtil.getUAVClientSrc(appid));
if (headers == null) {
headers = new HashMap<String, List<String>>();
context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
}
// when service use axis 1.4, SOAPAction header is necessary
if (!headers.containsKey("SOAPAction")) {
List<String> soapActionHeader = new ArrayList<String>();
soapActionHeader.add("\"\"");
headers.put("SOAPAction", soapActionHeader);
}
headers.put("UAV-Client-Src", ls);
for (String key : this.headerMeta.keySet()) {
headers.remove(key);
}
headers.putAll(this.headerMeta);
}
// inbound
else {
getTargetServer(context);
}
return true;
}