本文整理匯總了Java中javax.xml.ws.handler.soap.SOAPMessageContext.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPMessageContext.getMessage方法的具體用法?Java SOAPMessageContext.getMessage怎麽用?Java SOAPMessageContext.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.ws.handler.soap.SOAPMessageContext
的用法示例。
在下文中一共展示了SOAPMessageContext.getMessage方法的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: handleInbound
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
log.info("handleInbound");
try
{
SOAPMessage soapMessage = msgContext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
String value = soapElement.getValue();
soapElement.setValue(value + "|AuthIn");
}
catch (SOAPException e)
{
throw new WebServiceException(e);
}
return true;
}
示例8: verifyXOPPackage
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
private boolean verifyXOPPackage(MessageContext context)
{
try
{
SOAPMessageContext msgContext = (SOAPMessageContext)context;
SOAPMessage soapMsg = msgContext.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
SOAPBody body = soapEnv.getBody();
boolean found = scanNodes(body.getChildNodes());
if(found) throw new IllegalStateException("XOP request not properly inlined");
}
catch (SOAPException ex)
{
throw new WebServiceException(ex);
}
return true;
}
示例9: handleMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
@Override
public boolean handleMessage(SOAPMessageContext msgContext)
{
SOAPMessage message = msgContext.getMessage();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
try
{
message.writeTo(bout);
if (!isOutbound(msgContext))
{
appendContentToRequestElement(message, isWSAEnabled(bout.toString()));
}
}
catch (Exception e)
{
}
return true;
}
示例10: 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("Set-Cookie");
// proper approach through MessageContext.HTTP_RESPONSE_HEADERS
if (cookies == null) {
@SuppressWarnings("unchecked")
Map<String, List<String>> httpHeaders = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_RESPONSE_HEADERS);
List<String> l = httpHeaders.get("Set-Cookie");
if (l != null && !l.isEmpty()) {
cookies = l.toArray(new String[l.size()]);
}
}
if (cookies != null && cookies.length == 1)
inboundCookie = cookies[0];
return true;
}
示例11: handleOutbound
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
log.info("handleOutbound");
try
{
SOAPMessage soapMessage = msgContext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
String value = soapElement.getValue();
soapElement.setValue(value + "|CustomOut");
}
catch (SOAPException e)
{
throw new WebServiceException(e);
}
return true;
}
示例12: handleOutbound
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
log.info("handleOutbound");
// legacy JBossWS-Native approach
SOAPMessage soapMessage = msgContext.getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
mimeHeaders.setHeader("Cookie", "client-cookie=true");
// proper approach through MessageContext.HTTP_REQUEST_HEADERS
Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
httpHeaders.put("Cookie", Collections.singletonList("client-cookie=true"));
msgContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
inboundCookie = null;
return true;
}
示例13: 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);
}
}
示例14: handleOutbound
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
log.info("handleOutbound");
try
{
SOAPMessage soapMessage = msgContext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
String value = soapElement.getValue();
soapElement.setValue(value + "|AuthOut");
}
catch (SOAPException e)
{
throw new WebServiceException(e);
}
return true;
}
示例15: addMessage
import javax.xml.ws.handler.soap.SOAPMessageContext; //導入方法依賴的package包/類
private synchronized void addMessage(final SOAPMessageContext context) {
final SOAPMessage msg = context.getMessage();
final String msgText = soapMessage2String(msg);
final String dateTime = DateConverter
.convertLongToIso8601DateTimeFormat(System.currentTimeMillis(),
TimeZone.getTimeZone("GMT"));
messageList.add(dateTime + "\n" + msgText);
}