protected String getOperationName(MessageContext inMsg) throws AxisFault { AxisOperation op = inMsg.getOperationContext().getAxisOperation(); if (op == null) { throw new AxisFault( "Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider"); } String operationName = null; if ((op.getName() == null) || ((operationName = JavaUtils.xmlNameToJava(op.getName().getLocalPart())) == null)) { throw new AxisFault("invalid operation found"); } return operationName; }
@Override protected AxisOperation createOperation() { AxisOperation operation = new InOnlyAxisOperation(new QName("in")); operation.setMessageReceiver(messageReceiver); return operation; }
private boolean handle202(MessageContext requestMsgContext) throws AxisFault { if (requestMsgContext.isPropertyTrue(NhttpConstants.IGNORE_SC_ACCEPTED)) { // We should not further process this 202 response - Ignore it return true; } MessageReceiver mr = requestMsgContext.getAxisOperation().getMessageReceiver(); MessageContext responseMsgCtx = requestMsgContext.getOperationContext(). getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN); if (responseMsgCtx == null || requestMsgContext.getOptions().isUseSeparateListener()) { // Most probably a response from a dual channel invocation // Inject directly into the SynapseCallbackReceiver requestMsgContext.setProperty(NhttpConstants.HTTP_202_RECEIVED, "true"); mr.receive(requestMsgContext); return true; } return false; }
/** * Return the fault messages only if it's not an in-only operation. * For WSDL11 generation, the fault messages must be not present in the operation, * as mentioned in <link>http://www.w3.org/TR/wsdl#_one-way</link>. */ private ArrayList<AxisMessage> extractWSDL11FaultMessages(AxisOperation axisOperation) { String mepURI = axisOperation.getMessageExchangePattern(); if (this.isWSDL11FaultyMessagesValidForMEP(mepURI)) { return axisOperation.getFaultMessages(); } else { return new ArrayList<AxisMessage>(); } }
private InvocationResponse invokeMessageReceiver(MessageContext messageContext, AxisOperation operation) throws AxisFault { messageContext.getConfigurationContext(). fillServiceContextAndServiceGroupContext(messageContext); OperationContext opContext = operation.findOperationContext(messageContext, messageContext.getServiceContext()); messageContext.setOperationContext(opContext); operation.getMessageReceiver().receive(messageContext); return InvocationResponse.ABORT; }
private void setDefaultMessageReceivers() { Iterator operations = service.getPublishedOperations().iterator(); while (operations.hasNext()) { AxisOperation operation = (AxisOperation) operations.next(); if (operation.getMessageReceiver() == null) { MessageReceiver messageReceiver = loadDefaultMessageReceiver( operation.getMessageExchangePattern(), service); if (messageReceiver == null && // we assume that if the MEP is ROBUST_IN_ONLY then the in-out // MR can handle that WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(operation .getMessageExchangePattern())) { messageReceiver = loadDefaultMessageReceiver( WSDL2Constants.MEP_URI_IN_OUT, service); } operation.setMessageReceiver(messageReceiver); } } }
public NFeDistDFeInteresseResponse nfeDistDFeInteresse(final NFeDistDFeInteresse nfeDistDFeInteresse) throws java.rmi.RemoteException { org.apache.axis2.context.MessageContext _messageContext = null; try { final org.apache.axis2.client.OperationClient _operationClient = this._serviceClient.createClient(this._operations[0].getName()); _operationClient.getOptions().setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); this.addPropertyToOperationClient(_operationClient, org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, "&"); _messageContext = new org.apache.axis2.context.MessageContext(); env = this.toEnvelope(Stub.getFactory(_operationClient.getOptions().getSoapVersionURI()), nfeDistDFeInteresse, this.optimizeContent(new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe", "nfeDistDFeInteresse"))); this._serviceClient.addHeadersToEnvelope(env); _messageContext.setEnvelope(env); final java.lang.String exceptionClassName = (java.lang.String) this.faultExceptionClassNameMap.get(faultElt.getQName()); final java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); final java.lang.Exception ex = (java.lang.Exception) exceptionClass.newInstance(); final java.lang.String messageClassName = (java.lang.String) this.faultMessageMap.get(faultElt.getQName()); final java.lang.Class messageClass = java.lang.Class.forName(messageClassName); final java.lang.Object messageObject = this.fromOM(faultElt, messageClass, null);
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("urn:deleteEmployee"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); _messageContext = new org.apache.axis2.context.MessageContext(); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), deleteEmployee9, optimizeContent(new javax.xml.namespace.QName("http://ws.wso2.org/dataservice/samples/batch_request_sample", "deleteEmployee")),new javax.xml.namespace.QName("http://ws.wso2.org/dataservice/samples/batch_request_sample", "deleteEmployee")); _serviceClient.addHeadersToEnvelope(env); _messageContext.setEnvelope(env); if (_messageContext.getTransportOut() != null) { _messageContext.getTransportOut().getSender().cleanup(_messageContext);
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("urn:applySecurity"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), applySecurity18, optimizeContent(new javax.xml.namespace.QName("http://service.config.security.carbon.wso2.org", "applySecurity")), new javax.xml.namespace.QName("http://service.config.security.carbon.wso2.org", "applySecurity")); _serviceClient.addHeadersToEnvelope(env); _messageContext.setEnvelope(env); if ( _operations[0].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); _operations[0].setMessageReceiver( _callbackReceiver);
private void populateAxisService() { this._service = new org.apache.axis2.description.AxisService("NFeDistribuicaoDFe" + NFeDistribuicaoDFeSoapStub.getUniqueSuffix()); this.addAnonymousOperations(); // creating the operations org.apache.axis2.description.AxisOperation __operation; this._operations = new org.apache.axis2.description.AxisOperation[1]; __operation = new org.apache.axis2.description.OutInAxisOperation(); __operation.setName(new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe", "nfeDistDFeInteresse")); this._service.addOperation(__operation); this._operations[0] = __operation; }
public static AxisService createSimpleInOnlyService(QName serviceName, MessageReceiver messageReceiver, QName opName) throws AxisFault { AxisService service = new AxisService(serviceName.getLocalPart()); service.setClassLoader(getContextClassLoader_DoPriv()); AxisOperation axisOp = new InOnlyAxisOperation(opName); axisOp.setMessageReceiver(messageReceiver); axisOp.setStyle(WSDLConstants.STYLE_RPC); service.addOperation(axisOp); service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/" + opName.getLocalPart(), axisOp); return service; }
private void populateAxisService() throws org.apache.axis2.AxisFault { //creating the Service with a unique name _service = new org.apache.axis2.description.AxisService("ServicoConsultarLoteEventos" + getUniqueSuffix()); addAnonymousOperations(); //creating the operations org.apache.axis2.description.AxisOperation __operation; _operations = new org.apache.axis2.description.AxisOperation[1]; __operation = new org.apache.axis2.description.OutInAxisOperation(); __operation.setName(new javax.xml.namespace.QName("http://www.esocial.gov.br/servicos/empregador/lote/eventos/envio/consulta/retornoProcessamento/v1_1_0", "consultarLoteEventos")); _service.addOperation(__operation); (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicySubject().attachPolicy(getPolicy("<wsp:Policy wsu:Id=\"Servicos.Empregador_ServicoConsultarLoteEventos_policy\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><wsp:ExactlyOne><wsp:All><sp:TransportBinding xmlns:sp=\"http://schemas.xmlsoap.org/ws/2005/07/securitypolicy\"><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:TransportToken><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:HttpsToken RequireClientCertificate=\"true\"></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:Basic256 /></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:Strict /></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:ExactlyOne></wsp:Policy>")); (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE).getPolicySubject().attachPolicy(getPolicy("<wsp:Policy wsu:Id=\"Servicos.Empregador_ServicoConsultarLoteEventos_policy\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><wsp:ExactlyOne><wsp:All><sp:TransportBinding xmlns:sp=\"http://schemas.xmlsoap.org/ws/2005/07/securitypolicy\"><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:TransportToken><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:HttpsToken RequireClientCertificate=\"true\"></sp:HttpsToken></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:Basic256 /></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><sp:Strict /></wsp:Policy></sp:Layout></wsp:Policy></sp:TransportBinding></wsp:All></wsp:ExactlyOne></wsp:Policy>")); _operations[0]=__operation; }
private org.apache.axis2.context.MessageContext sendReceive(org.apache.axis2.context.MessageContext axisOutMsgCtx, Options clientOptions, AxisService anonymousService, ServiceContext serviceCtx) throws AxisFault { AxisOperation axisAnonymousOperation = anonymousService.getOperation( new QName(AnonymousServiceFactory.OUT_IN_OPERATION)); OperationClient operationClient = axisAnonymousOperation.createClient( serviceCtx, clientOptions); operationClient.addMessageContext(axisOutMsgCtx); axisOutMsgCtx.setAxisMessage(axisAnonymousOperation.getMessage( WSDLConstants.MESSAGE_LABEL_OUT_VALUE)); operationClient.execute(true); org.apache.axis2.context.MessageContext resultMsgCtx = operationClient.getMessageContext( WSDLConstants.MESSAGE_LABEL_IN_VALUE); org.apache.axis2.context.MessageContext returnMsgCtx = new org.apache.axis2.context.MessageContext(); returnMsgCtx.setEnvelope(MessageHelper.cloneSOAPEnvelope(resultMsgCtx.getEnvelope())); returnMsgCtx.setProperty(SynapseConstants.HTTP_SENDER_STATUSCODE, resultMsgCtx.getProperty(SynapseConstants.HTTP_SENDER_STATUSCODE)); axisOutMsgCtx.getTransportOut().getSender().cleanup(axisOutMsgCtx); return returnMsgCtx; }
public static boolean isDuplicateInOutMessage(MessageContext msgContext) { AxisOperation operation = msgContext.getAxisOperation(); String localName = operation.getName().getLocalPart(); if(localName.equals(Sandesha2Constants.RM_DUPLICATE_IN_OUT_OPERATION.getLocalPart())){ return true; } return false; }
private void sendRobust(org.apache.axis2.context.MessageContext axisOutMsgCtx, Options clientOptions, AxisService anonymousService, ServiceContext serviceCtx) throws AxisFault { AxisOperation axisAnonymousOperation = anonymousService.getOperation( new QName(AnonymousServiceFactory.OUT_ONLY_OPERATION)); OperationClient operationClient = axisAnonymousOperation.createClient( serviceCtx, clientOptions); operationClient.addMessageContext(axisOutMsgCtx); axisOutMsgCtx.setAxisMessage(axisAnonymousOperation.getMessage( WSDLConstants.MESSAGE_LABEL_OUT_VALUE)); operationClient.execute(true); axisOutMsgCtx.getTransportOut().getSender().cleanup(axisOutMsgCtx); }
/** * @param msgctx * @throws org.apache.axis2.AxisFault */ public InvocationResponse invoke(MessageContext msgctx) throws AxisFault { if ((msgctx.getAxisService() != null) && (msgctx.getAxisOperation() == null)) { AxisOperation axisOperation = findOperation(msgctx.getAxisService(), msgctx); if (axisOperation != null) { if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug(msgctx.getLogIDString() + " " + Messages.getMessage("operationfound", axisOperation .getName().getLocalPart())); } msgctx.setAxisOperation(axisOperation); //setting axisMessage into messageContext msgctx.setAxisMessage(axisOperation.getMessage( WSDLConstants.MESSAGE_LABEL_IN_VALUE)); } } return InvocationResponse.CONTINUE; } }
try { String operation = requestMessageContext. getOperationContext().getAxisOperation().getName().getLocalPart(); expression = new AXIOMXPath("//ns:" + operation + "/ns:artifactId"); expression.addNamespace("ns", namespace); artifactId = ((OMElement) expression. selectNodes(requestMessageContext.getEnvelope().getBody()).get(0)).getText().trim(); } catch (JaxenException e) { String msg = "Error occured while reading the content of the SOAP message"; log.error(msg); throw new AxisFault(msg, e); } catch (IndexOutOfBoundsException e) { String msg = "Content of the resource should be in correct format"; log.error(msg); throw new AxisFault(msg, e); String msg = e.getMessage(); log.error(msg); throw new AxisFault(msg, e);
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; } }
private AxisOperation getAxisOperation(AxisService axisService, String opName) { AxisOperation axisOperation = new OutInAxisOperation();//Default if(axisService != null) { for (Iterator<?> i = axisService.getOperations(); i.hasNext();) { AxisOperation axisOp = (AxisOperation) i.next(); if(axisOp.getName().getLocalPart().equals(opName)) { axisOperation = axisOp; break; } } } return axisOperation; }
private void setMessageReceivers(Wire wire, AxisService axisService) throws Exception { Map<String, InvocationChain> interceptors = new HashMap<String, InvocationChain>(); for (InvocationChain chain : wire.getInvocationChains()) { interceptors.put(chain.getPhysicalOperation().getName(), chain); } Utils.fillAxisService(axisService, configurationContext.getAxisConfiguration(), null, null); for (Iterator<?> i = axisService.getOperations(); i.hasNext();) { AxisOperation axisOp = (AxisOperation) i.next(); InvocationChain invocationChain = interceptors.get(axisOp.getName().getLocalPart()); MessageReceiver messageReceiver = null; if (WSDL2Constants.MEP_URI_IN_ONLY.equals(axisOp.getMessageExchangePattern()) || WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(axisOp.getMessageExchangePattern())) { messageReceiver = new InOnlyServiceProxyHandler(invocationChain); } else {//Default MEP is IN-OUT for backward compatibility messageReceiver = new InOutServiceProxyHandler(invocationChain); } axisOp.setMessageReceiver(messageReceiver); } }