public void setTo(EndpointReference reference) { axis2MessageContext.setTo(reference); }
public void setTo(EndpointReference reference) { axis2MessageContext.setTo(reference); }
public void setTo(EndpointReference epr) { msgContext.setTo(epr); }
" setDefaults: Setting WS-Addressing default value for the To property."); messageContext.setTo(new EndpointReference(Final.WSA_ANONYMOUS_URL));
@Override protected void invokeBusinessLogic(MessageContext inMsgContext) throws AxisFault { String operationName = getOperationName(inMsgContext); MessageContext outMsgContext = process(inMsgContext, operationName); if (outMsgContext != null) { outMsgContext.setTo(null); super.replicateState(inMsgContext); AxisEngine.send(outMsgContext); } }
/** * Processes the HTTP GET request and builds the SOAP info-set of the REST message * * @param msgContext The MessageContext of the Request Message * @param out The output stream of the response * @param soapAction SoapAction of the request * @param requestURI The URL that the request came to * @throws AxisFault - Thrown in case a fault occurs */ public static void processURLRequest(MessageContext msgContext, OutputStream out, String soapAction, String requestURI) throws AxisFault { if ((soapAction != null) && soapAction.startsWith("\"") && soapAction.endsWith("\"")) { soapAction = soapAction.substring(1, soapAction.length() - 1); } msgContext.setSoapAction(soapAction); msgContext.setTo(new EndpointReference(requestURI)); msgContext.setProperty(MessageContext.TRANSPORT_OUT, out); msgContext.setServerSide(true); msgContext.setDoingREST(true); msgContext.setEnvelope(new SOAP11Factory().getDefaultEnvelope()); msgContext.setProperty(NhttpConstants.NO_ENTITY_BODY, Boolean.TRUE); AxisEngine.receive(msgContext); }
@Override protected void invokeBusinessLogic(MessageContext inMsgContext) throws AxisFault { String operationName = getOperationName(inMsgContext); MessageContext outMsgContext = process(inMsgContext, operationName); if (outMsgContext != null) { outMsgContext.setTo(null); super.replicateState(inMsgContext); AxisEngine.send(outMsgContext); } }
public void processNonEntityEnclosingRESTHandler(SOAPEnvelope soapEnvelope, MessageContext msgContext, boolean injectToAxis2Engine) { String soapAction = request.getHeaders().get(SOAP_ACTION_HEADER); if ((soapAction != null) && soapAction.startsWith("\"") && soapAction.endsWith("\"")) { soapAction = soapAction.substring(1, soapAction.length() - 1); } msgContext.setSoapAction(soapAction); msgContext.setTo(new EndpointReference(request.getUri())); msgContext.setServerSide(true); msgContext.setDoingREST(true); if (!(request.isEntityEnclosing())) { msgContext.setProperty(PassThroughConstants.NO_ENTITY_BODY, Boolean.TRUE); } try { if(soapEnvelope == null){ msgContext.setEnvelope(new SOAP11Factory().getDefaultEnvelope()); }else{ msgContext.setEnvelope(soapEnvelope); } if (injectToAxis2Engine) { AxisEngine.receive(msgContext); } } catch (AxisFault axisFault) { handleException("Error processing " + request.getMethod() + " request for : " + request.getUri(), axisFault); } catch (Exception e) { String encodedURL = StringEscapeUtils.escapeHtml(request.getUri()); handleException("Error processing " + request.getMethod() + " request for : " + encodedURL + ". ", e); } }
/** * 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); } } }
/** * 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); } } }
public void sendCreateSequenceResponseMessage() throws AxisFault, RMMessageBuildingException { // TODO: set the correct mercury and soap namesapce if (this.createSequenceMessageContext != null) { // the create Sequence Message Context is not null only for the sequences started with the // create sequence reqest // note that the persistence storage sequences start straight away with the // message received state. therefore the createSequence responses don't have to send CreateSequenceResponseMessage createSequenceResponseMessage = new CreateSequenceResponseMessage(); createSequenceResponseMessage.setIdentifier(sequenceID); createSequenceResponseMessage.setSoapNamesapce( this.createSequenceMessageContext.getEnvelope().getNamespace().getNamespaceURI()); // Set the accept header if a sequence has occured if (this.selfAcksToEPR != null){ Accept accept = new Accept(); accept.setAcceptERP(this.selfAcksToEPR); accept.setAddressingNamespace(this.axis2Info.getAddressingNamespaceURI()); createSequenceResponseMessage.setAccept(accept); } MessageContext messageContext = MessageContextBuilder.createOutMessageContext(this.createSequenceMessageContext); messageContext.setProperty(MercuryConstants.PROCESS_RM_CONTROL_MESSAGE, Constants.VALUE_TRUE); messageContext.setEnvelope(createSequenceResponseMessage.toSOAPEnvelope()); messageContext.setTo(this.acksTo); messageContext.getOptions().setAction(MercuryConstants.CREATE_SEQUENCE_RESPONSE_ACTION); //use message worker to send this message. sendMessage(messageContext, false); } }
public void testSubscriptionMessageBuilderScenarioThree() { String addressUrl = "http://synapse.test.com/eventing/subscriptions"; Date date = new Date(System.currentTimeMillis() + 3600000); Calendar cal = Calendar.getInstance(); cal.setTime(date); String message = "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" + " <wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>\n" + "</wse:Renew>"; try { MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null). getAxis2MessageContext(); msgCtx.setTo(new EndpointReference(addressUrl)); String id = addIdentifierHeader(msgCtx); SubscriptionMessageBuilder.resetErrorInfo(); SynapseSubscription sub = SubscriptionMessageBuilder. createRenewSubscribeMessage(msgCtx); assertEquals(id, sub.getId()); assertEquals(addressUrl, sub.getAddressUrl()); assertEquals(date, sub.getExpires().getTime()); assertNull(SubscriptionMessageBuilder.getErrorCode()); assertNull(SubscriptionMessageBuilder.getErrorReason()); assertNull(SubscriptionMessageBuilder.getErrorSubCode()); } catch (Exception e) { e.printStackTrace(); fail("Error while constructing the sample subscription request: " + e.getMessage()); } }
public void testSubscriptionMessageBuilderScenarioTwo() { String addressUrl = "http://synapse.test.com/eventing/subscriptions"; String message = "<wse:Unsubscribe xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>"; try { MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null). getAxis2MessageContext(); msgCtx.setTo(new EndpointReference(addressUrl)); String id = addIdentifierHeader(msgCtx); SubscriptionMessageBuilder.resetErrorInfo(); SynapseSubscription sub = SubscriptionMessageBuilder.createUnSubscribeMessage(msgCtx); assertEquals(id, sub.getId()); assertEquals(addressUrl, sub.getAddressUrl()); assertNull(SubscriptionMessageBuilder.getErrorCode()); assertNull(SubscriptionMessageBuilder.getErrorReason()); assertNull(SubscriptionMessageBuilder.getErrorSubCode()); } catch (Exception e) { e.printStackTrace(); fail("Error while constructing the sample subscription request: " + e.getMessage()); } }
public void testSubscriptionMessageBuilderScenarioFour() { String addressUrl = "http://synapse.test.com/eventing/subscriptions"; String message = "<wse:GetStatus xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>"; try { MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null). getAxis2MessageContext(); msgCtx.setTo(new EndpointReference(addressUrl)); String id = addIdentifierHeader(msgCtx); SubscriptionMessageBuilder.resetErrorInfo(); SynapseSubscription sub = SubscriptionMessageBuilder.createGetStatusMessage(msgCtx); assertEquals(id, sub.getId()); assertEquals(addressUrl, sub.getAddressUrl()); assertNull(SubscriptionMessageBuilder.getErrorCode()); assertNull(SubscriptionMessageBuilder.getErrorReason()); assertNull(SubscriptionMessageBuilder.getErrorSubCode()); } catch (Exception e) { e.printStackTrace(); fail("Error while constructing the sample subscription request: " + e.getMessage()); } }
responseMsgCtx.setAxisMessage(outMsgCtx.getOperationContext().getAxisOperation(). getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE)); responseMsgCtx.setTo(null);
responseMsgCtx.setAxisMessage(outMsgCtx.getOperationContext().getAxisOperation(). getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE)); responseMsgCtx.setTo(null);
public void testSubscriptionMessageBuilderScenarioFive() { String addressUrl = "http://synapse.test.com/eventing/subscriptions"; String message = "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" + " <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>\n" + "</wse:Renew>"; try { MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null). getAxis2MessageContext(); msgCtx.setTo(new EndpointReference(addressUrl)); String id = addIdentifierHeader(msgCtx); SubscriptionMessageBuilder.resetErrorInfo(); SynapseSubscription sub = SubscriptionMessageBuilder. createRenewSubscribeMessage(msgCtx); assertNull(id, sub.getId()); assertEquals(addressUrl, sub.getAddressUrl()); assertNotNull(SubscriptionMessageBuilder.getErrorCode()); assertNotNull(SubscriptionMessageBuilder.getErrorReason()); assertNotNull(SubscriptionMessageBuilder.getErrorSubCode()); } catch (Exception e) { e.printStackTrace(); fail("Error while constructing the sample subscription request: " + e.getMessage()); } }
private MessageContext createMessageContext(String payload, String action) { try { SynapseConfiguration synapseConfig = new SynapseConfiguration(); AxisConfiguration axisConfig = new AxisConfiguration(); synapseConfig.setAxisConfiguration(axisConfig); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig); SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, synapseConfig); axisConfig.addParameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfig); axisConfig.addParameter(SynapseConstants.SYNAPSE_ENV, env); MessageContext msgCtx = TestUtils.getAxis2MessageContext(payload, null). getAxis2MessageContext(); msgCtx.setConfigurationContext(cfgCtx); msgCtx.setTo(new EndpointReference(SUB_MAN_URL)); msgCtx.setWSAAction(action); return msgCtx; } catch (Exception e) { fail(); } return null; } }
newMC.setTo(ori.getTo()); newMC.setSoapAction(ori.getSoapAction());
/** * Create a empty message context * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); axis2MC.setTransportIn(new TransportInDescription("http")); axis2MC.setTo(new EndpointReference("http://localhost:9000/services/SimpleStockQuoteService")); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; } }