本文整理汇总了Java中org.apache.axis2.context.MessageContext.isSOAP11方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.isSOAP11方法的具体用法?Java MessageContext.isSOAP11怎么用?Java MessageContext.isSOAP11使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.isSOAP11方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPingResponse
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void initPingResponse(MessageContext msgContext) {
if (msgContext.isSOAP11()) {
soapFactory = OMAbstractFactory.getSOAP11Factory();
} else {
soapFactory = OMAbstractFactory.getSOAP12Factory();
}
OMElement pingRequestElement = msgContext.getEnvelope().
getBody().getFirstChildWithName(new QName(TYPE_PING_REQUEST));
if (pingRequestElement != null) {
pingNamespace = pingRequestElement.getNamespace();
} else {
pingNamespace = soapFactory.createOMNamespace(PING_NAMESPACE,"");
}
pingResponse = soapFactory.createOMElement(TYPE_PING_RESPONSE, pingNamespace);
}
示例2: formatSOAPAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public String formatSOAPAction(MessageContext msgCtxt, OMOutputFormat format,
String soapActionString) {
// if SOAP 1.2 we attach the soap action to the content-type
// No need to set it as a header.
if (msgCtxt.isSOAP11()) {
if ("".equals(soapActionString)) {
return "\"\"";
} else {
if (soapActionString != null
&& !soapActionString.startsWith("\"")) {
// SOAPAction string must be a quoted string
soapActionString = "\"" + soapActionString + "\"";
}
return soapActionString;
}
}
return null;
}
示例3: initFaultInformation
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void initFaultInformation(MessageContext inMessageContext) {
SOAPFactory soapFactory;
if (inMessageContext.isSOAP11()) {
soapFactory = OMAbstractFactory.getSOAP11Factory();
} else {
soapFactory = OMAbstractFactory.getSOAP12Factory();
}
soapFaultCode = soapFactory.createSOAPFaultCode();
SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
soapFaultValue.setText(new QName("http://test.org", "TestFault", "test"));
soapFaultReason = soapFactory.createSOAPFaultReason();
SOAPFaultText soapFaultText = soapFactory.createSOAPFaultText(soapFaultReason);
soapFaultText.setText("This is some FaultReason");
soapFaultDetail = soapFactory.createSOAPFaultDetail();
QName qName = new QName("http://someuri.org", "FaultException");
OMElement detail = soapFactory.createOMElement(qName, soapFaultDetail);
qName = new QName("http://someuri.org", "ExceptionMessage");
Throwable e = new Exception("This is a test Exception");
while (e != null) {
OMElement exception = soapFactory.createOMElement(qName, null);
exception.setText(e.getMessage());
detail.addChild(exception);
e = e.getCause();
}
}
示例4: checkUnprocessed
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private static void checkUnprocessed(SOAPEnvelope envelope, List<QName> unprocessed, List<QName> understood, MessageContext msgContext) throws AxisFault{
for (QName headerQName : unprocessed) {
if (understood != null && !understood.isEmpty()) {
if (understood.contains(headerQName)) {
if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
log.debug("MustUnderstand header registered as understood on AxisOperation: " + headerQName);
}
continue;
}
}
if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
log.debug("MustUnderstand header not processed or registered as understood " + headerQName);
}
// Throw a MustUnderstand fault for the current SOAP version
String prefix = envelope.getNamespace().getPrefix();
if (!msgContext.isSOAP11()) {
if (prefix == null || "".equals(prefix)) {
prefix = SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX;
}
// TODO: should we be using a prefix on the faultcode? What about
// the QName object Constants.FAULT_SOAP12_MUSTUNDERSTAND?
throw new AxisFault(Messages.getMessage("mustunderstandfailed",
prefix,
headerQName.toString()),
SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND);
} else {
// TODO: should we be using a prefix on the faultcode? What about
// the QName object Constants.FAULT_MUSTUNDERSTAND?
throw new AxisFault(Messages.getMessage("mustunderstandfailed",
prefix,
headerQName.toString()),
SOAP11Constants.FAULT_CODE_MUST_UNDERSTAND);
}
}
}
示例5: triggerAddressingFault
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private static void triggerAddressingFault(MessageContext messageContext,
String faultInformationKey,
Object faultInformationValue, String faultcode,
String faultSubcode, String faultReason)
throws AxisFault {
Map faultInformation =
(Map)messageContext.getLocalProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
if (faultInformation == null) {
faultInformation = new HashMap();
messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
}
faultInformation.put(faultInformationKey, faultInformationValue);
if (messageContext.isSOAP11()) {
faultcode = (faultSubcode != null) ? faultSubcode : faultcode;
} else {
setFaultCode(messageContext, faultcode, faultSubcode);
}
OperationContext oc = messageContext.getOperationContext();
if (oc != null) {
oc.setProperty(Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS, "false");
}
messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.FALSE);
String namespace =
(String)messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
throw new AxisFault(faultReason, new QName(namespace, faultcode,
AddressingConstants.WSA_DEFAULT_PREFIX));
}
示例6: getContentType
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public String getContentType(MessageContext msgCtxt, OMOutputFormat format,
String soapActionString) {
String encoding = format.getCharSetEncoding();
String contentType = format.getContentType();
if (log.isDebugEnabled()) {
log.debug("contentType from the OMOutputFormat =" + contentType);
}
if (encoding != null && contentType != null &&
contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED)==-1) {
contentType += "; charset=" + encoding;
}
// action header is not mandated in SOAP 1.2. So putting it, if
// available
if (!msgCtxt.isSOAP11() && (soapActionString != null)
&& !"".equals(soapActionString.trim())
&& !"\"\"".equals(soapActionString.trim())) {
contentType = contentType + "; action=\"" + soapActionString+ "\"";
}
// This is a quick safety catch. Prior versions of SOAPFormatter
// placed a ';' at the end of the content-type. Many vendors ignore this
// last ';'. However it is not legal and some vendors report an error.
// To increase interoperability, the ';' is stripped off.
contentType = contentType.trim();
if (contentType.lastIndexOf(";") == (contentType.length()-1)) {
contentType = contentType.substring(0, contentType.length()-1);
}
if (log.isDebugEnabled()) {
log.debug("contentType returned =" + contentType);
}
return contentType;
}
示例7: doProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Override
protected InvocationResponse doProcessing(final MessageContext mc) throws AxisFault {
SOAPEnvelope env = null;
// SOAP Envelope only needs to be created when Holodeck B2B initiates the exchange
// or when response does not yet contain one
if ((isInFlow(RESPONDER) && (env = mc.getEnvelope()) == null) || isInFlow(INITIATOR)) {
// For request use P-Mode, for response use SOAP version from request
log.debug("Check for SOAP version");
SOAPEnv.SOAPVersion version;
if (isInFlow(INITIATOR)) {
log.debug("Use P-Mode of primary message unit to get SOAP version");
final IMessageUnitEntity primaryMU = MessageContextUtils.getPrimaryMessageUnit(mc);
if (primaryMU == null) {
log.debug("No message unit in this response, no envelope needed");
return InvocationResponse.CONTINUE;
}
final IPMode pmode = HolodeckB2BCoreInterface.getPModeSet().get(primaryMU.getPModeId());
// Currently only One-Way MEPs are supported, so always on first leg
final ILeg leg = pmode.getLeg(primaryMU.getLeg());
version = leg.getProtocol() != null && "1.1".equals(leg.getProtocol().getSOAPVersion()) ?
SOAPEnv.SOAPVersion.SOAP_11 : SOAPEnv.SOAPVersion.SOAP_12;
} else {
log.debug("Get version from request context");
final OperationContext opContext = mc.getOperationContext();
final MessageContext reqMsgContext = opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
version = (reqMsgContext.isSOAP11() ? SOAPEnv.SOAPVersion.SOAP_11 : SOAPEnv.SOAPVersion.SOAP_12);
}
log.debug("Create SOAP " + (version == SOAPEnv.SOAPVersion.SOAP_11 ? "1.1" : "1.2") + " envelope");
env = SOAPEnv.createEnvelope(version);
try {
// Add the new SOAP envelope to the message context and continue processing
mc.setEnvelope(env);
} catch (final AxisFault ex) {
log.fatal("Could not add the SOAP envelope to the message!");
throw new AxisFault("Could not add the SOAP envelope to the message!");
}
log.debug("Added SOAP envelope to message context");
} else {
log.debug("Check that ebMS namespace is declared on the SOAP envelope");
SOAPEnv.declareNamespaces(env);
}
log.debug("Add empty eb3:Messaging element");
final SOAPHeaderBlock messaging = Messaging.createElement(env);
return InvocationResponse.CONTINUE;
}
示例8: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
// this handler will be used to check the fault handling of Axis2.
// this will create some dummy faults and send
SOAPFactory soapFac = msgContext.isSOAP11() ? OMAbstractFactory.getSOAP11Factory() :
OMAbstractFactory.getSOAP12Factory();
// I have a sudden fake error ;)
OMElement firstElement = msgContext.getEnvelope().getBody().getFirstElement();
OMElement detailEntry = soapFac.createOMElement("MoreInfo", null);
detailEntry.setText(DETAIL_MORE_INFO);
if (ERR_HANDLING_WITH_MSG_CTXT.equals(firstElement.getLocalName())) {
SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
soapFaultCode.declareNamespace("http://someuri.org", "m");
if (msgContext.isSOAP11()) {
soapFaultCode.setText(M_FAULT_EXCEPTION);
} else {
SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
soapFaultValue.setText(M_FAULT_EXCEPTION);
}
SOAPFaultReason soapFaultReason = soapFac.createSOAPFaultReason();
if (msgContext.isSOAP11()) {
soapFaultReason.setText(FAULT_REASON);
} else {
SOAPFaultText soapFaultText = soapFac.createSOAPFaultText();
soapFaultText.setLang("en");
soapFaultText.setText(FAULT_REASON);
soapFaultReason.addSOAPText(soapFaultText);
}
SOAPFaultDetail faultDetail = soapFac.createSOAPFaultDetail();
faultDetail.addDetailEntry(detailEntry);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, soapFaultReason);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, faultDetail);
throw new AxisFault("A dummy exception has occurred");
} else if (ERR_HANDLING_WITH_AXIS_FAULT.equals(firstElement.getLocalName())) {
throw new AxisFault(new QName(M_FAULT_EXCEPTION), FAULT_REASON, null, null,
detailEntry);
}
return InvocationResponse.CONTINUE;
}
示例9: findSOAPAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private static String findSOAPAction(MessageContext messageContext) {
String soapActionString = null;
Parameter parameter =
messageContext.getTransportOut().getParameter(HTTPConstants.OMIT_SOAP_12_ACTION);
if (parameter != null && JavaUtils.isTrueExplicitly(parameter.getValue()) &&
!messageContext.isSOAP11()) {
return "\"\"";
}
Object disableSoapAction = messageContext.getOptions().getProperty(
Constants.Configuration.DISABLE_SOAP_ACTION);
if (!JavaUtils.isTrueExplicitly(disableSoapAction)) {
// first try to get the SOAP action from message context
soapActionString = messageContext.getSoapAction();
if (log.isDebugEnabled()) {
log.debug("SOAP Action from messageContext : (" + soapActionString + ")");
}
if (isGeneratedName(soapActionString)) {
if (log.isDebugEnabled()) {
log.debug("Will not use SOAP Action because (" + soapActionString + ") was auto-generated");
}
soapActionString = null;
}
if ((soapActionString == null) || (soapActionString.length() == 0)) {
// now let's try to get WSA action
soapActionString = messageContext.getWSAAction();
if (log.isDebugEnabled()) {
log.debug("SOAP Action from getWSAAction was : (" + soapActionString + ")");
}
if (messageContext.getAxisOperation() != null
&& ((soapActionString == null) || (soapActionString
.length() == 0))) {
// last option is to get it from the axis operation
String axisOpSOAPAction = messageContext.getAxisOperation().
getSoapAction();
if (log.isDebugEnabled()) {
log.debug("SOAP Action from AxisOperation was : (" + axisOpSOAPAction + ")");
}
if (isGeneratedName(axisOpSOAPAction)) {
if (log.isDebugEnabled()) {
log.debug("Will not override SOAP Action because (" + axisOpSOAPAction + ") in AxisOperation was auto-generated");
}
} else {
soapActionString = axisOpSOAPAction;
}
}
}
}
//Since action is optional for SOAP 1.2 we can return null here.
if (soapActionString == null && messageContext.isSOAP11()) {
soapActionString = "\"\"";
}
return soapActionString;
}
示例10: validateBindings
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* To check whether the incoming request has come in valid binding , we check whether service
* author has disabled any binding using parameters
* <code>org.apache.axis2.Constants.Configuration.DISABLE_SOAP12</code>
* <code>org.apache.axis2.Constants.Configuration.DISABLE_SOAP11</code>
* <code>org.apache.axis2.Constants.Configuration.DISABLE_REST</code>
* @param service msgctx the current MessageContext
* @throws AxisFault in case of error
*/
private void validateBindings(MessageContext msgctx) throws AxisFault {
AxisService service = msgctx.getAxisService();
if (msgctx.isDoingREST()) {
boolean disableREST = false;
Parameter disableRESTParameter = service
.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
if (disableRESTParameter != null
&& JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
disableREST = true;
}
if (disableREST) {
throw new AxisFault(Messages.getMessage("bindingDisabled","Http"));
}
} else if (msgctx.isSOAP11()) {
boolean disableSOAP11 = false;
Parameter disableSOAP11Parameter = service
.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP11);
if (disableSOAP11Parameter != null
&& JavaUtils.isTrueExplicitly(disableSOAP11Parameter.getValue())) {
disableSOAP11 = true;
}
if (disableSOAP11) {
throw new AxisFault(Messages.getMessage("bindingDisabled","SOAP11"));
}
} else {
boolean disableSOAP12 = false;
Parameter disableSOAP12Parameter = service
.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
if (disableSOAP12Parameter != null
&& JavaUtils
.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
disableSOAP12 = true;
}
if(disableSOAP12) {
throw new AxisFault(Messages.getMessage("bindingDisabled","SOAP12"));
}
}
}