本文整理汇总了Java中org.apache.axis.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于org.apache.axis包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEmptyPasswordProcessing
import org.apache.axis.Message; //导入依赖的package包/类
/**
* Test that processes a UserNameToken with an empty password
*/
public void testEmptyPasswordProcessing() throws Exception {
InputStream in = new ByteArrayInputStream(EMPTY_PASSWORD_MSG.getBytes());
Message msg = new Message(in);
msg.setMessageContext(msgContext);
SOAPEnvelope utEnvelope = msg.getSOAPEnvelope();
Document doc = utEnvelope.getAsDocument();
if (LOG.isDebugEnabled()) {
LOG.debug("Empty password message: ");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
verify(doc);
}
示例2: getMessageAttachments
import org.apache.axis.Message; //导入依赖的package包/类
/**
* extract attachments from the current request
*
* @return a list of attachmentparts or
* an empty array for no attachments support in this axis
* buid/runtime
* @throws AxisFault
*/
private AttachmentPart[] getMessageAttachments() throws AxisFault {
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg = msgContext.getRequestMessage();
Attachments messageAttachments = reqMsg.getAttachmentsImpl();
int attachmentCount =
messageAttachments.getAttachmentCount();
AttachmentPart attachments[] = new AttachmentPart[attachmentCount];
Iterator it =
messageAttachments.getAttachments().iterator();
int count = 0;
while (it.hasNext()) {
AttachmentPart part = (AttachmentPart) it.next();
attachments[count++] = part;
}
return attachments;
}
示例3: invoke
import org.apache.axis.Message; //导入依赖的package包/类
/**
* @see org.apache.axis.handlers.LogHandler#invoke(org.apache.axis.MessageContext)
*/
public void invoke(MessageContext arg0) throws AxisFault {
Date now = new Date();
Message m = arg0.getResponseMessage();
if (m!=null){
respMessage = m.getSOAPPartAsString();
if (baseDir!=null)
dumpToFile(sdf.format(now)+"_response",m.getSOAPPartAsBytes());
return;
}
else
respMessage = null;
m = arg0.getRequestMessage();
if (m!=null){
reqMessage = m.getSOAPPartAsString();
if (baseDir!=null)
dumpToFile(sdf.format(now)+"_request",m.getSOAPPartAsBytes());
}
else
reqMessage = null;
}
示例4: logMessages
import org.apache.axis.Message; //导入依赖的package包/类
private void logMessages(MessageContext msgContext) throws AxisFault {
try {
Message inMsg = msgContext.getRequestMessage();
Message outMsg = msgContext.getResponseMessage();
StringBuffer msg = new StringBuffer();
if (start != -1) {
msg.append("= " + Messages.getMessage("elapsed00", "" + (System.currentTimeMillis() - start))).append('\n');
}
msg.append("= " + Messages.getMessage("inMsg00", (inMsg == null ? "null" : inMsg.getSOAPPartAsString()))).append('\n');
msg.append("= " + Messages.getMessage("outMsg00", (outMsg == null ? "null" : outMsg.getSOAPPartAsString()))).append('\n');
switch (logLevel) {
case "debug": log.debug(msg); break;
case "info": log.info(msg); break;
case "warn": log.warn(msg); break;
case "error": log.error(msg); break;
default:
log.trace(msg);
}
} catch (Exception e) {
log.error(Messages.getMessage("exception00"), e);
throw AxisFault.makeFault(e);
}
}
示例5: createResult
import org.apache.axis.Message; //导入依赖的package包/类
public void createResult(Object object) {
messageContext.setPastPivot(true);
try {
Message requestMessage = messageContext.getRequestMessage();
SOAPEnvelope requestEnvelope = requestMessage.getSOAPEnvelope();
RPCElement requestBody = getBody(requestEnvelope, messageContext);
Message responseMessage = messageContext.getResponseMessage();
SOAPEnvelope responseEnvelope = responseMessage.getSOAPEnvelope();
ServiceDesc serviceDescription = messageContext.getService().getServiceDescription();
RPCElement responseBody = createResponseBody(requestBody, messageContext, operation, serviceDescription, object, responseEnvelope, getInOutParams());
responseEnvelope.removeBody();
responseEnvelope.addBodyElement(responseBody);
} catch (Exception e) {
throw new ServerRuntimeException("Failed while creating response message body", e);
}
}
示例6: invoke
import org.apache.axis.Message; //导入依赖的package包/类
public void invoke(MessageContext msgContext) throws AxisFault {
try {
System.out.println("Starting Server verification");
Message inMsg = msgContext.getRequestMessage();
Message outMsg = msgContext.getResponseMessage();
// verify signed message
Document doc = inMsg.getSOAPEnvelope().getAsDocument();
String BaseURI = "http://xml-security";
CachedXPathAPI xpathAPI = new CachedXPathAPI();
Element nsctx = doc.createElement("nsctx");
nsctx.setAttribute("xmlns:ds", Constants.SignatureSpecNS);
Element signatureElem = (Element) xpathAPI.selectSingleNode(doc,
"//ds:Signature", nsctx);
// check to make sure that the document claims to have been signed
if (signatureElem == null) {
System.out.println("The document is not signed");
return;
}
XMLSignature sig = new XMLSignature(signatureElem, BaseURI);
boolean verify = sig.checkSignatureValue(sig.getKeyInfo().getPublicKey());
System.out.println("Server verification complete.");
System.out.println("The signature is" + (verify
? " "
: " not ") + "valid");
} catch (Exception e) {
throw AxisFault.makeFault(e);
}
}
示例7: invoke
import org.apache.axis.Message; //导入依赖的package包/类
public void invoke(MessageContext msgContext) throws AxisFault {
Message requestMessage = msgContext.getRequestMessage();
Message responseMessage = new Message(requestMessage.getSOAPEnvelope());
String[] fooHeader = requestMessage.getMimeHeaders().getHeader("foo");
if (fooHeader != null) {
responseMessage.getMimeHeaders().addHeader("foo", fooHeader[0]);
}
msgContext.setResponseMessage(responseMessage);
}
示例8: MessageRequestEntity
import org.apache.axis.Message; //导入依赖的package包/类
public MessageRequestEntity(final HttpPost method,
final Message message,
final boolean httpChunkStream) {
this.message = message;
this.method = method;
this.httpChunkStream = httpChunkStream;
}
示例9: sendResponseX
import org.apache.axis.Message; //导入依赖的package包/类
/**
* write a message to the response, set appropriate headers for content
* type..etc.
* @param res response
* @param responseMsg message to write
* @throws AxisFault
* @throws IOException if the response stream can not be written to
*/
private void sendResponseX(String contentType,
HttpServletResponse res,
Message responseMsg) throws AxisFault,
IOException {
if (responseMsg == null) {
res.setStatus(HttpServletResponse.SC_NO_CONTENT);
if (isDebug) {
log.debug("NO AXIS MESSAGE TO RETURN!");
}
} else {
if (isDebug) {
log.debug("Returned Content-Type:" + contentType);
}
try {
res.setContentType(contentType);
responseMsg.writeTo(res.getOutputStream());
} catch (SOAPException e) {
logException(e);
}
}
if (!res.isCommitted()) {
res.flushBuffer(); // Force it right now.
}
}
示例10: sendResponse
import org.apache.axis.Message; //导入依赖的package包/类
/**
* write a message to the response, set appropriate headers for content
* type..etc.
* @param res response
* @param responseMsg message to write
* @throws AxisFault
* @throws IOException if the response stream can not be written to
*/
private void sendResponse(String contentType,
HttpServletResponse res,
Message responseMsg) throws AxisFault,
IOException {
if (responseMsg == null) {
res.setStatus(HttpServletResponse.SC_NO_CONTENT);
if (isDebug) {
log.debug("NO AXIS MESSAGE TO RETURN!");
}
} else {
if (isDebug) {
log.debug("Returned Content-Type:" + contentType);
}
try {
ReqRspUtil.setContentType(res,contentType);
responseMsg.writeTo(res.getOutputStream());
} catch (SOAPException e) {
logException(e);
}
}
if (!res.isCommitted()) {
res.flushBuffer(); // Force it right now.
}
}
示例11: ping
import org.apache.axis.Message; //导入依赖的package包/类
public void ping(
org.apache.ws.axis.oasis.ping.TicketType pingTicket,
StringHolder text
) throws java.rmi.RemoteException {
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg = msgContext.getRequestMessage();
Vector results =
(Vector) msgContext.getProperty(WSHandlerConstants.RECV_RESULTS);
if (results == null) {
System.out.println("No security results!!");
}
// System.out.println("Number of results: " + results.size());
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult =
(WSHandlerResult) results.get(i);
Vector wsSecEngineResults = rResult.getResults();
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
(WSSecurityEngineResult) wsSecEngineResults.get(j);
int action =
((java.lang.Integer)wser.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
Principal principal =
(Principal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL);
if (action != WSConstants.ENCR && principal != null) {
// System.out.println(principal.getName());
}
}
}
}
示例12: getSOAPEnvelope
import org.apache.axis.Message; //导入依赖的package包/类
/**
* Constructs a soap envelope
*
* @return soap envelope
* @throws java.lang.Exception if there is any problem constructing the soap envelope
*/
protected SOAPEnvelope getSOAPEnvelope() throws Exception {
InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
Message msg = new Message(in);
msg.setMessageContext(msgContext);
return msg.getSOAPEnvelope();
}
示例13: testUsernameTokenNoPasswordType
import org.apache.axis.Message; //导入依赖的package包/类
/**
* Test that adds a UserNameToken with no password type to a WS-Security envelope
* See WSS-152 - https://issues.apache.org/jira/browse/WSS-152
* "Problem with processing Username Tokens with no password type"
* The 1.1 spec states that the password type is optional and defaults to password text,
* and so we should handle an incoming Username Token accordingly.
*/
public void testUsernameTokenNoPasswordType() throws Exception {
InputStream in = new ByteArrayInputStream(SOAPUTMSG.getBytes());
Message msg = new Message(in);
msg.setMessageContext(msgContext);
SOAPEnvelope utEnvelope = msg.getSOAPEnvelope();
Document doc = utEnvelope.getAsDocument();
if (LOG.isDebugEnabled()) {
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
verify(doc);
}
示例14: getSOAPMessage
import org.apache.axis.Message; //导入依赖的package包/类
/**
* Constructs a soap envelope
*
* @return soap envelope
* @throws Exception if there is any problem constructing the soap envelope
*/
protected Message getSOAPMessage() throws Exception {
InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
Message msg = new Message(in);
msg.setMessageContext(msgContext);
return msg;
}
示例15: createHttpRequest
import org.apache.axis.Message; //导入依赖的package包/类
/**
* Creates an HTTP request based on the message context.
*
* @param msgContext the Axis message context
* @return a new {@link HttpRequest} with content and headers populated
*/
private HttpRequest createHttpRequest(MessageContext msgContext)
throws SOAPException, IOException {
Message requestMessage =
Preconditions.checkNotNull(
msgContext.getRequestMessage(), "Null request message on message context");
// Construct the output stream.
String contentType = requestMessage.getContentType(msgContext.getSOAPConstants());
ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
logger.debug("Compressing request");
try (GZIPOutputStream gzipOs = new GZIPOutputStream(bos, BUFFER_SIZE)) {
requestMessage.writeTo(gzipOs);
}
} else {
logger.debug("Not compressing request");
requestMessage.writeTo(bos);
}
HttpRequest httpRequest =
requestFactory.buildPostRequest(
new GenericUrl(msgContext.getStrProp(MessageContext.TRANS_URL)),
new ByteArrayContent(contentType, bos.toByteArray()));
int timeoutMillis = msgContext.getTimeout();
if (timeoutMillis >= 0) {
logger.debug("Setting read and connect timeout to {} millis", timeoutMillis);
// These are not the same, but MessageContext has only one definition of timeout.
httpRequest.setReadTimeout(timeoutMillis);
httpRequest.setConnectTimeout(timeoutMillis);
}
// Copy the request headers from the message context to the post request.
setHttpRequestHeaders(msgContext, httpRequest);
return httpRequest;
}