Package org.apache.ws.commons.om

Examples of org.apache.ws.commons.om.OMText


public class interopService {
    public OMElement mtomSample(OMElement element) throws Exception {
        if (element.getLocalName().equalsIgnoreCase("Data")
                && element.getNamespace().getName().equalsIgnoreCase(
                        "http://example.org/mtom/data")) {
                OMText binaryNode = (OMText)element.getFirstOMChild();
                binaryNode.setOptimize(!binaryNode.isOptimized());
            }
         else if (element.getLocalName().equalsIgnoreCase("EchoTest") && element.getNamespace().getName().equalsIgnoreCase("http://example.org/mtom/data")) {
            Iterator childrenIterator = element.getChildren();
            while (childrenIterator.hasNext()) {
                OMElement dataElement = (OMElement) childrenIterator.next();
                OMText binaryNode = (OMText)dataElement.getFirstOMChild();
                binaryNode.setOptimize(!binaryNode.isOptimized());
            }
        }
        return element;
    }
View Full Code Here


        OMElement data = fac.createOMElement("Data", omNs);

        File dataFile = new File(fileName);
        FileDataSource dataSource = new FileDataSource(dataFile);
        expectedDH = new DataHandler(dataSource);
        OMText textData = fac.createText(expectedDH, true);
        data.addChild(textData);
        return data;
    }
View Full Code Here

public class MTOMService {
    public OMElement mtomSample(OMElement element) throws Exception {
     
        OMElement imageEle = element.getFirstElement();
        OMElement imageName = (OMElement) imageEle.getNextOMSibling();
        OMText binaryNode = (OMText) imageEle.getFirstOMChild();
        String fileName = imageName.getText();
        //Extracting the data and saving
        DataHandler actualDH;
        actualDH = (DataHandler)binaryNode.getDataHandler();
        Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
                .getInputStream());
        FileOutputStream imageOutStream = new FileOutputStream(fileName);
        new ImageIO().saveImage("image/jpeg", actualObject, imageOutStream);
        //setting response
View Full Code Here

        OMElement element = factory.createOMElement(
                new QName("MyFirstBodyElement"), soapEnvelope.getBody());
        OMElement element11 = factory.createOMElement(
                new QName("MyFirstBodyElement"), element);
        OMText optimizedText = factory.createText("Hi", "text/plain", true);
        element11.addChild(optimizedText);
        assertTrue(
                "optmization check has not performed correctly in SOAPEnvelope",
                HTTPTransportUtils.checkEnvelopeForOptimise(soapEnvelope));
    }
View Full Code Here

        OMElement element = factory.createOMElement(
                new QName("MyFirstBodyElement"), soapEnvelope.getBody());
        OMElement element11 = factory.createOMElement(
                new QName("MyFirstBodyElement"), element);
        OMText optimizedText = factory.createText("Hi", "text/plain", false);
        element11.addChild(optimizedText);
        assertFalse(
                "optmization check has not performed correctly in SOAPEnvelope",
                HTTPTransportUtils.checkEnvelopeForOptimise(soapEnvelope));
    }
View Full Code Here

                .loadImage(new FileInputStream(inputFile));

        ImageDataSource dataSource = new ImageDataSource("test.jpg",
                expectedImage);
        expectedDH = new DataHandler(dataSource);
        OMText textData = fac.createText(expectedDH, true);
        image.addChild(textData);

        OMElement imageName = fac.createOMElement("fileName", omNs);
        if (fileName != null) {
            imageName.setText(fileName);
View Full Code Here

    private void processText(XMLStreamReader parser, OMElement value) {
        try {
            int token = parser.next();
            while (token != XMLStreamReader.END_ELEMENT) {
                if (token == XMLStreamReader.CHARACTERS) {
                    OMText text = factory.createText(value, parser.getText());
                    value.addChild(text);
                } else {
                    throw new SOAPProcessingException(
                            "Only Characters are allowed here");
                }
View Full Code Here

                        new FileInputStream(
                                getTestResourceFile(imageInFileName)));
        ImageDataSource dataSource = new ImageDataSource("WaterLilies.jpg",
                expectedImage);
        expectedDH = new DataHandler(dataSource);
        OMText binaryNode = new OMTextImpl(expectedDH, true, fac);

        envelope.addChild(body);
        body.addChild(data);
        data.addChild(binaryNode);
View Full Code Here

                .getSOAPPartInputStream())));
        builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper, null);
        OMElement root = builder.getDocumentElement();
        OMElement body = (OMElement) root.getFirstOMChild();
        OMElement data = (OMElement) body.getFirstOMChild();
        OMText blob = (OMText) data.getFirstOMChild();
        /*
         * Following is the procedure the user has to follow to read objects in
         * OBBlob User has to know the object type & whether it is serializable.
         * If it is not he has to use a Custom Defined DataSource to get the
         * Object.
         */

        DataHandler actualDH;
        actualDH = (DataHandler)blob.getDataHandler();
        Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
                .getInputStream());
        FileOutputStream imageOutStream = new FileOutputStream(
                new File(imageOutFileName));
        new ImageIO().saveImage("image/jpeg", actualObject, imageOutStream);
View Full Code Here

    }

    //SOAP 1.1 Fault Detail Test (With Parser)
    public void testSOAP11GetAllDetailEntriesWithParser() {
        Iterator iterator = soap11FaultDetailWithParser.getAllDetailEntries();
        OMText textEntry = (OMText) iterator.next();
        assertFalse(
                "SOAP 1.1 Fault Detail Test With Parser : - getAllDetailEntries method returns empty iterator",
                textEntry == null);
        assertTrue(
                "SOAP 1.1 Fault Detail Test With Parser : - text value mismatch",
                textEntry.getText().trim().equals("Details of error"));
        OMElement detailEntry1 = (OMElement) iterator.next();
        assertFalse(
                "SOAP 1.1 Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator without detail entries",
                detailEntry1 == null);
        assertTrue(
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.om.OMText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.