Search in sources :

Example 46 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class SOAP12Factory method getDefaultFaultEnvelope.

@Override
public final SOAPEnvelope getDefaultFaultEnvelope() {
    SOAPEnvelope defaultEnvelope = getDefaultEnvelope();
    SOAPFault fault = createSOAPFault(defaultEnvelope.getBody());
    SOAPFaultCode faultCode = createSOAPFaultCode(fault);
    createSOAPFaultValue(faultCode);
    SOAPFaultReason reason = createSOAPFaultReason(fault);
    createSOAPFaultText(reason);
    createSOAPFaultDetail(fault);
    return defaultEnvelope;
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) SOAPFaultReason(org.apache.axiom.soap.SOAPFaultReason) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 47 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class SOAPFactoryImpl method createDefaultSOAPMessage.

@Override
public final SOAPMessage createDefaultSOAPMessage() {
    SOAPMessage message = createSOAPMessage();
    SOAPEnvelope env = createSOAPEnvelope();
    message.addChild(env);
    createSOAPBody(env);
    return message;
}
Also used : SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPMessage(org.apache.axiom.soap.SOAPMessage) AxiomSOAPMessage(org.apache.axiom.soap.impl.intf.AxiomSOAPMessage)

Example 48 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.

the class TestDataHandlerSerializationWithoutMTOM method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFactory factory = metaFactory.getSOAP11Factory();
    JAXBContext context = JAXBContext.newInstance(DocumentBean.class);
    // Construct the original message
    DocumentBean orgObject = new DocumentBean();
    orgObject.setId("123456");
    orgObject.setContent(new DataHandler("some content", "text/plain; charset=utf-8"));
    SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
    OMSourcedElement element = factory.createOMElement(new JAXBOMDataSource(context, orgObject));
    orgEnvelope.getBody().addChild(element);
    // Serialize the message
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    orgEnvelope.serialize(out);
    assertFalse(element.isExpanded());
    SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(new ByteArrayInputStream(out.toByteArray()), null).getSOAPEnvelope();
    DocumentBean object = (DocumentBean) context.createUnmarshaller().unmarshal(envelope.getBody().getFirstElement().getXMLStreamReader(false));
    assertEquals("some content", IOUtils.toString(object.getContent().getInputStream(), "utf-8"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DocumentBean(org.apache.axiom.ts.jaxb.beans.DocumentBean) JAXBContext(javax.xml.bind.JAXBContext) DataHandler(javax.activation.DataHandler) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SOAPFactory(org.apache.axiom.soap.SOAPFactory) JAXBOMDataSource(org.apache.axiom.om.ds.jaxb.JAXBOMDataSource)

Example 49 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project wso2-axis2-transports by wso2.

the class TCPWorker method run.

public void run() {
    MessageContext msgContext = null;
    try {
        msgContext = endpoint.createMessageContext();
        msgContext.setIncomingTransportName(Constants.TRANSPORT_TCP);
        TCPOutTransportInfo outInfo = new TCPOutTransportInfo();
        outInfo.setSocket(socket);
        outInfo.setClientResponseRequired(endpoint.isClientResponseRequired());
        outInfo.setContentType(endpoint.getContentType());
        String delimiter = endpoint.getRecordDelimiter();
        int recordLength = endpoint.getRecordLength();
        String inputType = endpoint.getInputType();
        String delimiterType = endpoint.getRecordDelimiterType();
        outInfo.setDelimiter(delimiter);
        outInfo.setDelimiterType(delimiterType);
        msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
        // create the SOAP Envelope
        InputStream input = socket.getInputStream();
        boolean handled = false;
        if (recordLength > -1) {
            this.handleRecordLength(msgContext, input, recordLength);
            handled = true;
        }
        if (!delimiter.isEmpty() && !handled) {
            if (inputType != null) {
                if (TCPConstants.STRING_INPUT_TYPE.equalsIgnoreCase(inputType)) {
                    if (TCPConstants.BYTE_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
                        int delimiterVal = Integer.parseInt(delimiter.split("0x")[1], 16);
                        this.handleCharacterRecordDelimiterStringStream(msgContext, input, delimiterVal);
                    } else if (TCPConstants.STRING_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
                        this.handleStringRecordDelimiterStringStream(msgContext, input, delimiter);
                    } else {
                        this.handleCharacterRecordDelimiterStringStream(msgContext, input, delimiter.charAt(0));
                    }
                } else {
                    if (TCPConstants.BYTE_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
                        int delimiterVal = Integer.parseInt(delimiter.split("0x")[1], 16);
                        this.handleCharacterRecordDelimiterBinaryStream(msgContext, input, delimiterVal);
                    } else if (TCPConstants.STRING_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
                        this.handleStringRecordDelimiterBinaryStream(msgContext, input, delimiter);
                    } else {
                        this.handleCharacterRecordDelimiterBinaryStream(msgContext, input, delimiter.charAt(0));
                    }
                }
            }
            handled = true;
        }
        if (!handled) {
            SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, input, endpoint.getContentType());
            msgContext.setEnvelope(envelope);
            AxisEngine.receive(msgContext);
        }
    } catch (Exception e) {
        sendFault(msgContext, e);
    } finally {
        if (!endpoint.isClientResponseRequired()) {
            try {
                socket.close();
            } catch (IOException e) {
                log.error("Error while closing a TCP socket", e);
            }
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MessageContext(org.apache.axis2.context.MessageContext) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) IOException(java.io.IOException) IOException(java.io.IOException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 50 with SOAPEnvelope

use of org.apache.axiom.soap.SOAPEnvelope in project wso2-axis2-transports by wso2.

the class TCPWorker method handleEnvelope.

private void handleEnvelope(MessageContext msgContext, byte[] value) throws AxisFault {
    ByteArrayInputStream bais = null;
    try {
        bais = new ByteArrayInputStream(value);
        SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, bais, endpoint.getContentType());
        msgContext.setEnvelope(envelope);
        AxisEngine.receive(msgContext);
    } catch (IOException e) {
        sendFault(msgContext, e);
    } catch (XMLStreamException e) {
        sendFault(msgContext, e);
    } finally {
        if (bais != null) {
            try {
                bais.close();
            } catch (IOException e) {
                sendFault(msgContext, e);
            }
        }
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ByteArrayInputStream(java.io.ByteArrayInputStream) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) IOException(java.io.IOException)

Aggregations

SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)105 OMElement (org.apache.axiom.om.OMElement)32 SOAPBody (org.apache.axiom.soap.SOAPBody)24 OMNamespace (org.apache.axiom.om.OMNamespace)22 SOAPHeader (org.apache.axiom.soap.SOAPHeader)20 SOAPFactory (org.apache.axiom.soap.SOAPFactory)18 QName (javax.xml.namespace.QName)16 SOAPFault (org.apache.axiom.soap.SOAPFault)14 ByteArrayInputStream (java.io.ByteArrayInputStream)12 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)12 OMNode (org.apache.axiom.om.OMNode)11 SOAPModelBuilder (org.apache.axiom.soap.SOAPModelBuilder)11 MessageContext (org.apache.axis2.context.MessageContext)10 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)8 InputStream (java.io.InputStream)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 StringReader (java.io.StringReader)6 DataHandler (javax.activation.DataHandler)6 OMException (org.apache.axiom.om.OMException)6