本文整理汇总了Java中org.apache.axis2.context.MessageContext.getEnvelope方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getEnvelope方法的具体用法?Java MessageContext.getEnvelope怎么用?Java MessageContext.getEnvelope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getEnvelope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SoapHeader
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public SoapHeader(MessageContext messageContext) {
env = null;
hdr = null;
to = null;
action = null;
isSOAP12 = false;
isSOAP11 = false;
env = messageContext.getEnvelope();
if (env == null) return;
ns = env.getNamespace();
if (ns != null) {
isSOAP12 = ns.getNamespaceURI().contains("http://www.w3.org/2003/05/soap-envelope");
isSOAP11 = ns.getNamespaceURI().contains("http://schemas.xmlsoap.org/soap/envelope/");
}
hdr = MetadataSupport.firstChildWithLocalName(env, "Header");
if (hdr == null) return;
to = MetadataSupport.firstChildWithLocalName(hdr, "To");
action = MetadataSupport.firstChildWithLocalName(hdr, "Action");
}
示例2: getInHeader
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement getInHeader() throws XdsInternalException {
OperationContext oc = serviceClient.getLastOperationContext();
HashMap<String, MessageContext> ocs = oc.getMessageContexts();
MessageContext in = ocs.get("In");
if (in == null)
return null;
if (in.getEnvelope() == null)
return null;
if (in.getEnvelope().getHeader() == null)
return null;
return Util.deep_copy( in.getEnvelope().getHeader());
}
示例3: handleResponse
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* If there is a fault then need to handle that
* @param responseMessageContext responseMessageContext
* @throws AxisFault
*/
protected void handleResponse(MessageContext responseMessageContext) throws AxisFault {
SOAPEnvelope envelope = responseMessageContext.getEnvelope();
if (envelope == null) {
// If request is REST we assume the responseMessageContext is REST, so
// set the variable
InputStream inStream = (InputStream) responseMessageContext.
getProperty(MessageContext.TRANSPORT_IN);
if (inStream != null && checkContentLength(responseMessageContext)) {
envelope = TransportUtils.createSOAPMessage(
responseMessageContext);
responseMessageContext.setEnvelope(envelope);
}
responseMessageContext.setEnvelope(envelope);
}
if (envelope != null) {
if (envelope.hasFault()|| responseMessageContext.isProcessingFault()) {
//receiving a fault
AxisEngine.receive(responseMessageContext);
throw Utils.getInboundFaultFromMessageContext(responseMessageContext);
}
}
}
示例4: closeStaxBuilder
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Close the builders.
*
* @param messageContext
* @throws ServletException
*/
void closeStaxBuilder(MessageContext messageContext) throws ServletException {
if (closeReader && messageContext != null) {
try {
SOAPEnvelope envelope = messageContext.getEnvelope();
if(envelope != null) {
StAXBuilder builder = (StAXBuilder) envelope.getBuilder();
if (builder != null) {
builder.close();
}
}
} catch (Exception e) {
log.debug(e.toString(), e);
}
}
}
示例5: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
*
* @param trpUrl
* @param addUrl
* @param payload
* @param action
* @return soap envelop
* @throws org.apache.axis2.AxisFault
*/
public OMElement send(String trpUrl, String addUrl, OMElement payload, String action) throws AxisFault {
operationClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
setMessageContext(addUrl, trpUrl, action);
outMsgCtx.setEnvelope(createSOAPEnvelope(payload));
operationClient.addMessageContext(outMsgCtx);
operationClient.execute(true);
MessageContext inMsgtCtx = operationClient.getMessageContext("In");
SOAPEnvelope response = inMsgtCtx.getEnvelope();
return response;
}
示例6: createMultipleQuoteRequest
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Creating the multiple quote request
*
* @param trpUrl
* @param addUrl
* @param symbol
* @param iterations
* @return
* @throws java.io.IOException
*/
private OMElement createMultipleQuoteRequest(String trpUrl, String addUrl, String symbol,
int iterations) throws IOException {
operationClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
setMessageContext(addUrl, trpUrl, null);
outMsgCtx.setEnvelope(createSOAPEnvelope(symbol, iterations));
operationClient.addMessageContext(outMsgCtx);
operationClient.execute(true);
MessageContext inMsgtCtx = operationClient.getMessageContext("In");
SOAPEnvelope response = inMsgtCtx.getEnvelope();
return response;
}
示例7: writeMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault {
SOAPEnvelope envelope = msgContext.getEnvelope();
OMElement outputMessage = envelope;
if ((envelope != null) && msgContext.isDoingREST()) {
outputMessage = envelope.getBody().getFirstElement();
}
if (outputMessage != null) {
try {
OMOutputFormat format = new OMOutputFormat();
// Pick the char set encoding from the msgContext
String charSetEnc =
(String) msgContext
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
format.setDoOptimize(false);
format.setDoingSWA(false);
format.setCharSetEncoding(charSetEnc);
outputMessage.serializeAndConsume(out, format);
out.flush();
} catch (Exception e) {
throw AxisFault.makeFault(e);
}
} else {
throw new AxisFault(Messages.getMessage("outMessageNull"));
}
}
示例8: onMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* This is called when we receive a message.
*
* @param msgContext the (response) MessageContext
*/
public void onMessage(final MessageContext msgContext) {
// Transport input stream gets closed after calling setComplete
// method. Have to build the whole envelope including the
// attachments at this stage. Data might get lost if the input
// stream gets closed before building the whole envelope.
// TODO: Shouldn't need to do this - need to hook up stream closure to Axiom completion
this.envelope = msgContext.getEnvelope();
this.envelope.buildWithAttachments();
}
示例9: onMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* This is called when we receive a message.
*
* @param msgContext the (response) MessageContext
*/
public void onMessage(MessageContext msgContext) {
// Transport input stream gets closed after calling setComplete
// method. Have to build the whole envelope including the
// attachments at this stage. Data might get lost if the input
// stream gets closed before building the whole envelope.
// TODO: Shouldn't need to do this - need to hook up stream closure to Axiom completion
this.envelope = msgContext.getEnvelope();
this.envelope.buildWithAttachments();
}
示例10: writeTo
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void writeTo(MessageContext msgCtxt, OMOutputFormat format,
OutputStream out, boolean preserve) throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("start writeTo()");
log.debug(" preserve=" + preserve);
log.debug(" isOptimized=" + format.isOptimized());
log.debug(" isDoingSWA=" + format.isDoingSWA());
}
if (msgCtxt.isDoingMTOM()) {
int optimizedThreshold = Utils.getMtomThreshold(msgCtxt);
if(optimizedThreshold > 0){
if(log.isDebugEnabled()){
log.debug("Setting MTOM optimized Threshold Value on OMOutputFormat");
}
format.setOptimizedThreshold(optimizedThreshold);
}
}
try {
if (!(format.isOptimized()) && format.isDoingSWA()) {
writeSwAMessage(msgCtxt, out, format, preserve);
} else {
OMElement element = msgCtxt.getEnvelope();
if (preserve) {
element.serialize(out, format);
} else {
element.serializeAndConsume(out, format);
}
}
} catch (XMLStreamException e) {
throw AxisFault.makeFault(e);
} finally {
if (log.isDebugEnabled()) {
log.debug("end writeTo()");
}
}
}
示例11: createSoapRequest
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void createSoapRequest(MessageContext msgCtx, Element message, Operation op)
throws AxisFault {
if (op == null) {
throw new NullPointerException("Null operation");
}
// The message can be null if the input message has no part
if (op.getInput().getMessage().getParts().size() > 0 && message == null) {
throw new NullPointerException("Null message.");
}
if (msgCtx == null) {
throw new NullPointerException("Null msgCtx");
}
BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);
if (bop == null) {
throw new OdeFault("BindingOperation not found.");
}
BindingInput bi = bop.getBindingInput();
if (bi == null) {
throw new OdeFault("BindingInput not found.");
}
SOAPEnvelope soapEnv = msgCtx.getEnvelope();
if (soapEnv == null) {
soapEnv = soapFactory.getDefaultEnvelope();
msgCtx.setEnvelope(soapEnv);
}
// createSoapHeaders(soapEnv, getSOAPHeaders(bi), op.getInput().getMessage(), message);
SOAPBody soapBody = getSOAPBody(bi);
if (soapBody != null) {
org.apache.axiom.soap.SOAPBody sb = soapEnv.getBody() == null ?
soapFactory.createSOAPBody(soapEnv) : soapEnv.getBody();
createSoapBody(sb, soapBody, op.getInput().getMessage(), message, op.getName());
}
}
示例12: processThroughEngine
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Set up message properties to header as it received as MSMQ message properties
*
* @param message
* @return
* @throws AxisFault
*/
private boolean processThroughEngine(Message message) throws AxisFault {
// TODO: this only support text messages, need to improve it for binay
// messages
// Get the contentType from the MSMQ message
String contentType = message.getLabel();
if (log.isDebugEnabled()) {
log.info("Content Type of the message is : " + contentType);
}
MessageContext msgContext = endpoint.createMessageContext();
SOAPEnvelope soapEnvelope;
if (message.getCorrelationId() != null) {
msgContext.setProperty(MSMQConstants.MSMQ_CORRELATION_ID, message.getCorrelationId());
}
// Check if content type for the MSMQ messages is defined at proxy level as a parameter
if(msgContext.getParameter(MSMQConstants.PARAM_CONTENT_TYPE).getValue() != null){
//Overwrite the message's content type with the defined content type in the proxy
contentType = String.valueOf(msgContext.getParameter(MSMQConstants.PARAM_CONTENT_TYPE).getValue());
}
/*
* ContentTypeInfo contentTypeInfo =
* endpoint.getContentTypeRuleSet().getContentTypeInfo(message);
*/
MSMQUtil.setSOAPEnvelope(message, msgContext, contentType);
soapEnvelope = msgContext.getEnvelope();
msmqListener.handleIncomingMessage(msgContext, MSMQUtil.getTransportHeaders(message), null, contentType);
return true;
}
示例13: shouldInvoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public boolean shouldInvoke(MessageContext msgContext) throws AxisFault {
if (msgContext == null) {
return false;
}
SOAPEnvelope envelope = msgContext.getEnvelope();
return envelope.getHeader() != null;
}
示例14: testMulitref1
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testMulitref1() throws AxisFault {
RPCServiceClient sender = getRPCClient("EchoXMLService", "echoString");
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
OMElement method = fac.createOMElement("echoString", omNs);
OMElement value = fac.createOMElement("arg0", null);
value.addAttribute(fac.createOMAttribute("href", null, "#1"));
method.addChild(value);
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
envelope.getBody().addChild(method);
OMElement ref = fac.createOMElement("reference", null);
ref.addAttribute(fac.createOMAttribute("id", null, "1"));
ref.setText("hello Axis2");
envelope.getBody().addChild(ref);
MessageContext reqMessageContext = new MessageContext();
OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
reqMessageContext.setEnvelope(envelope);
opClinet.addMessageContext(reqMessageContext);
opClinet.execute(true);
MessageContext responseMessageContx =
opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPEnvelope env = responseMessageContx.getEnvelope();
assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "hello Axis2");
}
示例15: testaddSameRef
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testaddSameRef() throws AxisFault {
RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
OMElement method = fac.createOMElement("add", omNs);
OMElement value = fac.createOMElement("arg0", null);
value.addAttribute(fac.createOMAttribute("href", null, "#1"));
method.addChild(value);
OMElement value2 = fac.createOMElement("arg1", null);
value2.addAttribute(fac.createOMAttribute("href", null, "#1"));
method.addChild(value2);
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
envelope.getBody().addChild(method);
OMElement ref = fac.createOMElement("reference", null);
ref.addAttribute(fac.createOMAttribute("id", null, "1"));
ref.setText("10");
envelope.getBody().addChild(ref);
MessageContext reqMessageContext = new MessageContext();
OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
reqMessageContext.setEnvelope(envelope);
opClinet.addMessageContext(reqMessageContext);
opClinet.execute(true);
MessageContext responseMessageContx =
opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPEnvelope env = responseMessageContx.getEnvelope();
assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "20");
}