private org.apache.axiom.soap.SOAPEnvelope toEnvelope(final org.apache.axiom.soap.SOAPFactory factory, final CadConsultaCadastro4Stub.NfeDadosMsg param, final boolean optimizeContent, final javax.xml.namespace.QName elementQName) throws org.apache.axis2.AxisFault { try { final org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); emptyEnvelope.getBody().addChild(param.getOMElement(CadConsultaCadastro4Stub.NfeDadosMsg.MY_QNAME, factory)); return emptyEnvelope; } catch (final org.apache.axis2.databinding.ADBException e) { throw org.apache.axis2.AxisFault.makeFault(e); } }
private DataHandler getDataHandler(MessageContext messageContext) { OMElement firstChild = messageContext.getEnvelope().getBody().getFirstElement(); if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) { OMNode omNode = firstChild.getFirstOMChild(); if (omNode != null && omNode instanceof OMText) { Object dh = ((OMText)omNode).getDataHandler(); if (dh != null && dh instanceof DataHandler) { return (DataHandler)dh; } } } return null; }
public void onFault(org.apache.axis2.context.MessageContext messageContext) { System.out.println("Fault received to the callback : " + messageContext.getEnvelope(). getBody().getFault()); }
/** * Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code> object. * * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code> object */ public SOAPFault getFault() { if (omTarget.hasFault()) { return (SOAPFault)toSAAJNode((org.w3c.dom.Node)omTarget.getFault()); } return null; }
protected void handleFault(MessageContext msgContext, OutputStream out, AxisFault e) throws AxisFault { msgContext.setProperty(MessageContext.TRANSPORT_OUT, out); MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext, e); // SOAP 1.2 specification mentions that we should send HTTP code 400 in a fault if the // fault code Sender HttpServletResponse response = (HttpServletResponse) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE); if (response != null) { //TODO : Check for SOAP 1.2! SOAPFaultCode code = faultContext.getEnvelope().getBody().getFault().getCode(); OMElement valueElement = null; if (code != null) { valueElement = code.getFirstChildWithName(new QName( SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)); } if (valueElement != null) { if (SOAP12Constants.FAULT_CODE_SENDER.equals(valueElement.getTextAsQName().getLocalPart()) && !msgContext.isDoingREST()) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } } AxisEngine.sendFault(faultContext); }
public void toSOAPEnvelope(SOAPEnvelope envelope) { SOAPBody body = envelope.getBody(); //detach if already exist. OMElement elem = body.getFirstChildWithName(new QName(namespaceValue, Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE)); if (elem!=null) elem.detach(); toOMElement(body); }
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(new StringReader(payload)).getSOAPEnvelope(); SOAPBody soapBody = envelope.getBody(); OMElement messageNode = soapBody.getFirstChildWithName(new QName( FIX_MSG)); Iterator<?> messageElements = (Iterator<?>) messageNode .getChildElements(); while (messageElements.hasNext()) { OMElement node = (OMElement) messageElements.next(); if (node.getQName().getLocalPart().equals(FIX_MSG_BODY)) { Iterator<?> bodyElements = (Iterator<?>) node.getChildElements(); while (bodyElements.hasNext()) { OMElement bodyNode = (OMElement) bodyElements.next(); String tag = bodyNode .getAttributeValue(new QName(FIX_MSG_ID)); String value = bodyNode.getText(); if (tag.equals(FIX_MSG_SYMBOL)) {
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault { try { //Fix for https://wso2.org/jira/browse/CARBON-7256 messageContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType); //We will create a SOAP message, which holds the input message as a blob SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); if (inputStream != null) { OMNamespace ns = factory.createOMNamespace( RelayConstants.BINARY_CONTENT_QNAME.getNamespaceURI(), "ns"); OMElement omEle = factory.createOMElement( RelayConstants.BINARY_CONTENT_QNAME.getLocalPart(), ns); StreamingOnRequestDataSource ds = new StreamingOnRequestDataSource(inputStream); DataHandler dataHandler = new DataHandler(ds); //create an OMText node with the above DataHandler and set optimized to true OMText textData = factory.createOMText(dataHandler, true); omEle.addChild(textData); env.getBody().addChild(omEle); } return env; } catch (SOAPProcessingException e) { throw AxisFault.makeFault(e); } catch (OMException e) { throw AxisFault.makeFault(e); } }
/** * Reads the SOAP body of a message and attempts to retreive the session identifier string * * @param msgCtx Axis2 MessageContext * @return a String uniquely identifying a session or null */ public static String getSourceSession(MessageContext msgCtx) { String srcSession; SOAPBody body = msgCtx.getEnvelope().getBody(); OMNamespace ns = getNamespaceOfFIXPayload(body); if (ns == null) { OMElement messageNode = body.getFirstChildWithName(new QName(FIXConstants.FIX_MESSAGE)); srcSession = messageNode.getAttributeValue(new QName( FIXConstants.FIX_MESSAGE_INCOMING_SESSION)); } else { srcSession = getSourceSession(body, ns); } return srcSession; }
public static void convertSOAPFaultToPOX(MessageContext msgCtx) { SOAPBody body = msgCtx.getEnvelope().getBody(); SOAPFault fault = body.getFault(); if (fault != null) { OMFactory fac = msgCtx.getEnvelope().getOMFactory(); OMElement faultPayload = fac.createOMElement(new QName("Exception")); faultPayload.addChild(om); + faultReasonValue + " as athe POX Fault"); faultPayload.setText(faultReasonValue); if (body.getFirstElement() != null) { body.getFirstElement().detach(); msgCtx.setProcessingFault(true); body.addChild(faultPayload);
public void onMessage(MessageContext arg0) { SOAPBody body = arg0.getEnvelope().getBody(); OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse)); if (echoStringResponseElem==null) { System.out.println("Error: SOAPBody does not have a 'echoStringResponse' child"); return; } OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn)); if (echoStringReturnElem==null) { System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child"); return; } String resultStr = echoStringReturnElem.getText(); System.out.println("Callback '" + name + "' got result:" + resultStr); } }
try { OMElement info; if((info = requestMessageContext.getEnvelope().getBody(). getFirstElement().getFirstChildWithName(new QName(namespace, "info"))) != null){ content = AXIOMUtil.stringToOM(info.getText());
public OMElement processDocument(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault { // first process the input stream SOAPEnvelope soapEnv = (SOAPEnvelope) processDocumentWrapper(inputStream, s, messageContext); // when this is a POST request, if the body of the soap envelope is empty and the parameter // map is there, build a dummy soap body which contains all the parameters coming in. SOAPBody body = soapEnv.getBody(); String httpMethod = (String) messageContext.getProperty(HTTPConstants.HTTP_METHOD); if (body.getFirstElement() == null && HTTPConstants.HTTP_METHOD_POST.equals(httpMethod) && messageContext.getProperty(Constants.REQUEST_PARAMETER_MAP) != null) { MultipleEntryHashMap map = (MultipleEntryHashMap) messageContext .getProperty(Constants.REQUEST_PARAMETER_MAP); SOAPFactory soapFactory = getSOAPFactory(messageContext); OMElement bodyFirstChild = soapFactory .createOMElement(XFORM_FIRST_ELEMENT, body); createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild, map); } else if (body.getFirstElement() != null && "mediate".equals(body.getFirstElement().getLocalName())) { body.getFirstElement().setLocalName(XFORM_FIRST_ELEMENT.getLocalPart()); } return soapEnv; }
private BuildElementHelper buildElement(MessageContext msgCtx) throws XKMSException { SOAPEnvelope env = msgCtx.getEnvelope(); OMElement llomElement = env.getBody().getFirstElement(); XKMSUtil.DOOMElementMetadata doomMetadata = XKMSUtil .getDOOMElement(llomElement); OMElement xkmsElement = doomMetadata.getElement(); QName qName = xkmsElement.getQName(); ElementBuilder builder = FindBuilder.find(qName.getLocalPart()); XKMSElement xkmsObj = builder.buildElement(xkmsElement); return new BuildElementHelper(qName, xkmsObj, builder); }
/** * Reads the SOAP body of a message and attempts to retreive the session identifier string * with a namesapce * * @param body Body of the SOAP message * @param ns Namespace * @return a String uniquely identifying a session or null */ private static String getSourceSession(SOAPBody body, OMNamespace ns) { OMElement messageNode = body.getFirstChildWithName(new QName(ns.getNamespaceURI(), FIXConstants.FIX_MESSAGE, ns.getPrefix())); return messageNode.getAttributeValue(new QName(ns.getNamespaceURI(), FIXConstants.FIX_MESSAGE_INCOMING_SESSION, ns.getPrefix())); }
public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { OMElement textElt = messageContext.getEnvelope().getBody().getFirstElement(); if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(textElt.getQName())) { try { Writer out = new OutputStreamWriter(outputStream, format.getCharSetEncoding()); textElt.writeTextTo(out, preserve); out.flush(); } catch (IOException e) { throw new AxisFault("Error writing text message to stream", e); } } }
.getFirstChildWithName(new QName(rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE)); if (createSeqResponsePart == null) throw new OMException(SandeshaMessageHelper.getMessage( OMElement identifierPart = createSeqResponsePart.getFirstChildWithName(new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.IDENTIFIER)); if(identifierPart != null){ identifier.fromOMElement(identifierPart); OMElement expiresPart = createSeqResponsePart.getFirstChildWithName( new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.EXPIRES)); if (expiresPart != null) { OMElement acceptPart = createSeqResponsePart.getFirstChildWithName( new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACCEPT));
AxisOperation opDesc = msgContext.getAxisOperation(); Method method = findOperation(opDesc, implClass); throw new AxisFault(Messages.getMessage("methodDoesNotExistInOut", opDesc.getName().toString())); obj, new Object[]{msgContext.getEnvelope().getBody().getFirstElement()}); SOAPFactory fac = getSOAPFactory(msgContext); SOAPEnvelope envelope = fac.getDefaultEnvelope(); envelope.getBody().addChild(result); newmsgContext.setEnvelope(envelope); } catch (Exception e) { throw AxisFault.makeFault(e);
@Override public void onMessage(final org.apache.axis2.context.MessageContext resultContext) { try { final org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); final java.lang.Object object = CteRecepcaoOSStub.this.fromOM(resultEnv.getBody().getFirstElement(), com.fincatto.documentofiscal.cte300.webservices.recepcaoOS.CteRecepcaoOSStub.CteRecepcaoOSResult.class, CteRecepcaoOSStub.this.getEnvelopeNamespaces(resultEnv)); callback.receiveResultcteRecepcaoOS((com.fincatto.documentofiscal.cte300.webservices.recepcaoOS.CteRecepcaoOSStub.CteRecepcaoOSResult) object); } catch (final org.apache.axis2.AxisFault e) { callback.receiveErrorcteRecepcaoOS(e); } }
public void onMessage(org.apache.axis2.context.MessageContext messageContext) { System.out.println("Response received to the callback"); OMElement result = messageContext.getEnvelope().getBody().getFirstElement(); // Detach the result to make sure that the element we return to the sample client // is completely built result.detach(); StockQuoteClient.InnerStruct.RESULT = result; }