本文整理汇总了Java中org.apache.axis2.context.MessageContext.setAxisService方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setAxisService方法的具体用法?Java MessageContext.setAxisService怎么用?Java MessageContext.setAxisService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setAxisService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simulate
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void simulate() throws Exception {
MessageContext messageContext = new MessageContext();
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
HttpSession session = mock(HttpSession.class);
when(session.getAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE)).thenReturn(registry);
when(servletRequest.getSession()).thenReturn(session);
messageContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, servletRequest);
AxisService axisService = new AxisService();
axisService.addParameter(new Parameter(CarbonConstants.ADMIN_SERVICE_PARAM_NAME, "true"));
messageContext.setAxisService(axisService);
MessageContext.setCurrentMessageContext(messageContext);
final SimulationRequest simulationRequest = new SimulationRequest();
simulationRequest.setOperation("resourceexists");
simulationRequest.setPath("/test/2017/10/18");
CommonUtil.setSimulationService(new RegistryCoreServiceComponent.DefaultSimulationService());
HandlerManagementService managementService = new HandlerManagementService();
managementService.simulate(simulationRequest);
assertNotNull(CommonUtil.getSimulationResponse().getStatus());
assertEquals(3, CommonUtil.getSimulationResponse().getStatus().length);
}
示例2: testEmptyAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testEmptyAction() throws Exception {
// We shouldn't be able to route on an emtpy-string action.
MessageContext messageContext = new MessageContext();
AxisService as = new AxisService("Service1");
messageContext.setAxisService(as);
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
operation1.setSoapAction("");
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
operation2.setSoapAction("");
as.addOperation(operation1);
as.addOperation(operation2);
messageContext.setSoapAction("");
SOAPActionBasedDispatcher soapActionDispatcher = new SOAPActionBasedDispatcher();
soapActionDispatcher.invoke(messageContext);
assertNull(messageContext.getAxisOperation());
}
示例3: getWSDL
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Retrieves the WSDL data associated with the given serviceURL.
* @param out The output stream for the WSDL data to be written, NOTE: the stream is not closed after the operation,
* it is the responsibility of the caller to close the stream after usage.
* @param serviceURL The fist element of this array i.e. serviceURL[0] is taken in retrieving the target service.
*/
private void getWSDL(OutputStream out, String[] serviceURL)
throws AxisFault {
// Retrieve WSDL using the same data retrieval path for GetMetadata
// request.
DataRetrievalRequest request = new DataRetrievalRequest();
request.putDialect(DRConstants.SPEC.DIALECT_TYPE_WSDL);
request.putOutputForm(OutputForm.INLINE_FORM);
MessageContext context = new MessageContext();
context.setAxisService(this);
context.setTo(new EndpointReference(serviceURL[0]));
Data[] result = getData(request, context);
OMElement wsdlElement;
if (result != null && result.length > 0) {
wsdlElement = (OMElement) (result[0].getData());
try {
XMLPrettyPrinter.prettify(wsdlElement, out);
out.flush();
} catch (Exception e) {
throw AxisFault.makeFault(e);
}
}
}
示例4: createMockMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static MessageContext createMockMessageContext(String payload) throws AxisFault {
MessageContext inMC = new MessageContext();
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
omDoc.addChild(envelope);
envelope.getBody().addChild(TestUtils.createOMElement(payload));
inMC.setEnvelope(envelope);
AxisConfiguration axisConfig = new AxisConfiguration();
AxisService as = new AxisService();
as.setName("ScriptService");
AxisServiceGroup asg = new AxisServiceGroup(axisConfig);
asg.addService(as);
as.addParameter(new Parameter("script.js",
"function invoke(inMC, outMC) { outMC.setPayloadXML(" +
payload + ")}"));
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
ServiceGroupContext sgc = cfgCtx.createServiceGroupContext(asg);
inMC.setAxisService(as);
inMC.setServiceContext(sgc.getServiceContext(as));
return inMC;
}
示例5: testMessageWithOmittedMessageIDInOutMEP
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testMessageWithOmittedMessageIDInOutMEP() throws Exception {
MessageContext messageContext = testMessageWithOmittedHeaders("noMessageID");
String messageID = messageContext.getOptions().getMessageId();
assertNull("The message id is not null.", messageID);
AxisOperation axisOperation = new InOutAxisOperation();
messageContext.setAxisOperation(axisOperation);
AxisService axisService = new AxisService();
messageContext.setAxisService(axisService);
try {
validationHandler.invoke(messageContext);
fail("An AxisFault should have been thrown due to the absence of a message id.");
}
catch (AxisFault af) {
//Test passed.
}
}
示例6: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public MessageContext createMessageContext() throws AxisFault {
MessageContext msgContext = listener.createMessageContext();
if (service != null) {
msgContext.setAxisService(service);
// find the operation for the message, or default to one
Parameter operationParam = service.getParameter(BaseConstants.OPERATION_PARAM);
QName operationQName = (
operationParam != null ?
BaseUtils.getQNameFromString(operationParam.getValue()) :
BaseConstants.DEFAULT_OPERATION);
AxisOperation operation = service.getOperation(operationQName);
if (operation != null) {
msgContext.setAxisOperation(operation);
msgContext.setAxisMessage(
operation.getMessage(WSDL2Constants.MESSAGE_LABEL_IN));
msgContext.setSoapAction("urn:" + operation.getName().getLocalPart());
}
}
return msgContext;
}
示例7: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* @param msgctx
* @throws org.apache.axis2.AxisFault
*/
public InvocationResponse invoke(MessageContext msgctx) throws AxisFault {
AxisService axisService = msgctx.getAxisService();
if (axisService == null) {
axisService = findService(msgctx);
if (axisService != null) {
if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
log.debug(msgctx.getLogIDString() + " " + Messages.getMessage("servicefound",
axisService.getName()));
}
msgctx.setAxisService(axisService);
}
}
return InvocationResponse.CONTINUE;
}
示例8: setSynapseContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void setSynapseContext(MessageContext messageContext, AxisService originalAxisService) throws AxisFault {
AxisService axisService = synapseDispatcher.findService(messageContext);
if (log.isDebugEnabled()) {
log.debug("AxisService is changing from " + originalAxisService.getName() + " to " +
axisService.getName());
}
messageContext.setAxisService(axisService);
messageContext.setAxisOperation(synapseDispatcher.findOperation(messageContext.getAxisService(),
messageContext));
}
示例9: setup
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
UserRegistry userRegistry = mock(UserRegistry.class);
when(userRegistry.getUserName()).thenReturn("admin");
RegistryRealm registryRealm = PowerMockito.mock(RegistryRealm.class);
UserStoreManager userStoreManager = PowerMockito.mock(UserStoreManager.class);
when(userStoreManager.getRoleListOfUser("admin"))
.thenReturn(new String[]{"admin", "internal/everyone", "internal/publisher"});
when(registryRealm.getUserStoreManager()).thenReturn(userStoreManager);
RealmConfiguration realmConfiguration = new RealmConfiguration();
realmConfiguration.setAdminRoleName("admin");
when(registryRealm.getRealmConfiguration()).thenReturn(realmConfiguration);
when(userRegistry.getUserRealm()).thenReturn(registryRealm);
doReturn(true).when(userRegistry).resourceExists(anyString());
LogEntry[] resultEntries = TestUtils.readLogEntries("add-log-entry.csv");
doReturn(resultEntries).when(userRegistry).getLogs(anyString(), eq(0),
anyString(), (Date)anyObject(), (Date)anyObject(), anyBoolean());
MessageContext messageContext = new MessageContext();
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
HttpSession session = mock(HttpSession.class);
when(session.getAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE)).thenReturn(userRegistry);
when(servletRequest.getSession()).thenReturn(session);
messageContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, servletRequest);
AxisService axisService = new AxisService();
axisService.addParameter(new Parameter(CarbonConstants.ADMIN_SERVICE_PARAM_NAME, "true"));
messageContext.setAxisService(axisService);
MessageContext.setCurrentMessageContext(messageContext);
}
示例10: testInvokeBusinessLogic
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testInvokeBusinessLogic() throws AxisFault {
ScriptReceiver scriptReceiver = new ScriptReceiver();
MessageContext inMC = TestUtils.createMockMessageContext("<a>petra</a>");
AxisService axisService = inMC.getAxisService();
axisService.addParameter(new Parameter(ScriptReceiver.SCRIPT_ATTR, "foo.js"));
axisService.addParameter(new Parameter(ScriptReceiver.SCRIPT_SRC_PROP,
"function invoke(inMC,outMC) " +
"{outMC.setPayloadXML(<a>petra</a>) }"));
inMC.setAxisService(axisService);
scriptReceiver.invokeBusinessLogic(inMC, inMC);
Iterator iterator = inMC.getEnvelope().getChildElements();
iterator.next();
assertEquals("<a>petra</a>", ((OMElement) iterator.next()).getFirstElement().toString());
}
示例11: testFromScript
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testFromScript() throws Exception {
ScriptReceiver mediator = new ScriptReceiver();
MessageContext inMC = TestUtils.createMockMessageContext(XML);
AxisService axisServce = new AxisService();
axisServce.setParent(new AxisServiceGroup(new AxisConfiguration()));
axisServce.addParameter(new Parameter(ScriptReceiver.SCRIPT_ATTR, "foo.js"));
axisServce.addParameter(new Parameter(ScriptReceiver.SCRIPT_SRC_PROP, "function invoke(inMC,outMC) { outMC.setPayloadXML(<a><b>petra</b></a>) }"));
inMC.setAxisService(axisServce);
mediator.invokeBusinessLogic(inMC, inMC);
Iterator iterator = inMC.getEnvelope().getChildElements();
iterator.next();
assertEquals(XML, ((OMElement) iterator.next()).getFirstElement().toString());
}
示例12: setUp
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
messageContext = new MessageContext();
axisConfiguration = new AxisConfiguration();
configurationContext = new ConfigurationContext(axisConfiguration);
axisService = new AxisService("Dummy Service");
message = new AxisMessage();
axisOperation = AxisOperationFactory.getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_OUT);
jsonMessageHandler = new JSONMessageHandler();
String fileName = "test-resources/custom_schema/testSchema_2.xsd";
InputStream is = new FileInputStream(fileName);
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
QName elementQName = new QName("http://test.json.axis2.apache.org" ,"echoPerson");
message.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
message.setElementQName(elementQName);
message.setParent(axisOperation);
axisOperation.addMessage(message, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
axisService.addSchema(schema);
axisService.addOperation(axisOperation);
SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
messageContext.setConfigurationContext(configurationContext);
messageContext.setAxisService(axisService);
messageContext.setAxisOperation(axisOperation);
messageContext.setEnvelope(soapEnvelope);
}
示例13: testMessageWithOmittedMessageIDInOnlyMEP
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testMessageWithOmittedMessageIDInOnlyMEP() throws Exception {
MessageContext messageContext = testMessageWithOmittedHeaders("noMessageID");
String messageID = messageContext.getOptions().getMessageId();
assertNull("The message id is not null.", messageID);
AxisOperation axisOperation = new InOnlyAxisOperation();
messageContext.setAxisOperation(axisOperation);
AxisService axisService = new AxisService();
messageContext.setAxisService(axisService);
validationHandler.invoke(messageContext);
}
示例14: testMessageWithMessageIDInOutMEP
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testMessageWithMessageIDInOutMEP() throws Exception {
MessageContext messageContext = testMessageWithOmittedHeaders("noFrom");
String messageID = messageContext.getOptions().getMessageId();
assertNotNull("The message id is null.", messageID);
AxisOperation axisOperation = new InOutAxisOperation();
messageContext.setAxisOperation(axisOperation);
AxisService axisService = new AxisService();
messageContext.setAxisService(axisService);
validationHandler.invoke(messageContext);
}
示例15: testFindOperation
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testFindOperation() throws AxisFault {
MessageContext messageContext;
AxisService as1 = new AxisService("Service1");
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
as1.addOperation(operation1);
as1.addOperation(operation2);
ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
AxisConfiguration ac = cc.getAxisConfiguration();
ac.addService(as1);
messageContext = cc.createMessageContext();
messageContext.setAxisService(as1);
SOAPEnvelope se = OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope();
SOAPBody sb = OMAbstractFactory.getSOAP11Factory().createSOAPBody(se);
sb.addChild(OMAbstractFactory.getSOAP11Factory().createOMElement("operation2",
"http://test", "pfx"));
messageContext.setEnvelope(se);
SOAPMessageBodyBasedOperationDispatcher ruisd =
new SOAPMessageBodyBasedOperationDispatcher();
ruisd.invoke(messageContext);
assertEquals(operation2, messageContext.getAxisOperation());
}