Package javax.xml.soap

Examples of javax.xml.soap.SOAPFactory


     * @throws SOAPException
     *         error navigating through the SOAP stack.
     */
    protected static SOAPElement importW3CNodeAsChild(SOAPElement parent,
            org.w3c.dom.Node imported) throws SOAPException {
        SOAPFactory factory = SOAPFactory.newInstance();
       
        SOAPElement newChild = parent.addChildElement(imported.getLocalName(),
                imported.getPrefix(), imported.getNamespaceURI());
       
        org.w3c.dom.NamedNodeMap attributes = imported.getAttributes();
        for(int i=0; i<attributes.getLength(); i++) {
            org.w3c.dom.Node attribute = attributes.item(i);
            Name newName = factory.createName(attribute.getLocalName(),
                    attribute.getPrefix(), attribute.getNamespaceURI());
            newChild.addAttribute(newName, attribute.getNodeValue());
        }
       
        org.w3c.dom.NodeList children = imported.getChildNodes();
View Full Code Here


           
            // Create the request headers
            Map<String, Object> requestContext = dispatch.getRequestContext();
            Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
           
            SOAPFactory sf = SOAPFactory.newInstance();
            SOAPElement e = sf.createElement(SoapMessageProvider.FOO_HEADER_QNAME);
            e.addTextNode(SoapMessageProvider.FOO_HEADER_CONTENT);
            String fooHeader = e.toString();
            TestLogger.logger.debug("Foo Header:" + fooHeader);
            List<String> list = new ArrayList<String>();
            list.add(fooHeader);
            requestHeaders.put(SoapMessageProvider.FOO_HEADER_QNAME, list);
           
            list = new ArrayList<String>();
            e = sf.createElement(SoapMessageProvider.BAR_HEADER_QNAME);
            e.addTextNode(SoapMessageProvider.BAR_HEADER_CONTENT1);
            String barHeader = e.toString();
           
            TestLogger.logger.debug("Bar Header:" + barHeader);
            list.add(barHeader);
            e = sf.createElement(SoapMessageProvider.BAR_HEADER_QNAME);
            e.addTextNode(SoapMessageProvider.BAR_HEADER_CONTENT2);
            barHeader = e.toString();
           
            TestLogger.logger.debug("Bar Header:" + barHeader);
            list.add(barHeader);
View Full Code Here

           
            // Create the request headers
            Map<String, Object> requestContext = dispatch.getRequestContext();
            Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
           
            SOAPFactory sf = SOAPFactory.newInstance();
            SOAPElement e = sf.createElement(SoapMessageProvider.FOO_HEADER_QNAME);
            e.addTextNode(SoapMessageProvider.FOO_HEADER_CONTENT);
            String fooHeader = e.toString();
            TestLogger.logger.debug("Foo Header:" + fooHeader);
            List<String> list = new ArrayList<String>();
            list.add(fooHeader);
            requestHeaders.put(SoapMessageProvider.FOO_HEADER_QNAME, list);
           
            list = new ArrayList<String>();
            e = sf.createElement(SoapMessageProvider.BAR_HEADER_QNAME);
            e.addTextNode(SoapMessageProvider.BAR_HEADER_CONTENT1);
            String barHeader = e.toString();
           
            TestLogger.logger.debug("Bar Header:" + barHeader);
            list.add(barHeader);
            e = sf.createElement(SoapMessageProvider.BAR_HEADER_QNAME);
            e.addTextNode(SoapMessageProvider.BAR_HEADER_CONTENT2);
            barHeader = e.toString();
           
            TestLogger.logger.debug("Bar Header:" + barHeader);
            list.add(barHeader);
View Full Code Here

    public void testHeaders() {
        try {
            // Create message factory and SOAP factory
            MessageFactory messageFactory = MessageFactory.newInstance();
            SOAPFactory soapFactory = SOAPFactory.newInstance();

            // Create a message
            SOAPMessage message = messageFactory.createMessage();

            // Get the SOAP header from the message and
            //  add headers to it
            SOAPHeader header = message.getSOAPHeader();

            String nameSpace = "ns";
            String nameSpaceURI = "http://gizmos.com/NSURI";

            Name order =
                    soapFactory.createName("orderDesk", nameSpace, nameSpaceURI);
            SOAPHeaderElement orderHeader = header.addHeaderElement(order);
            orderHeader.setActor("http://gizmos.com/orders");

            Name shipping =
                    soapFactory.createName("shippingDesk", nameSpace, nameSpaceURI);
            SOAPHeaderElement shippingHeader =
                    header.addHeaderElement(shipping);
            shippingHeader.setActor("http://gizmos.com/shipping");

            Name confirmation =
                    soapFactory.createName("confirmationDesk", nameSpace,
                                           nameSpaceURI);
            SOAPHeaderElement confirmationHeader =
                    header.addHeaderElement(confirmation);
            confirmationHeader.setActor("http://gizmos.com/confirmations");

            Name billing =
                    soapFactory.createName("billingDesk", nameSpace, nameSpaceURI);
            SOAPHeaderElement billingHeader = header.addHeaderElement(billing);
            billingHeader.setActor("http://gizmos.com/billing");

            // Add header with mustUnderstand attribute
            Name tName =
                    soapFactory.createName("Transaction", "t",
                                           "http://gizmos.com/orders");

            SOAPHeaderElement transaction = header.addHeaderElement(tName);
            transaction.setMustUnderstand(true);
            transaction.addTextNode("5");
View Full Code Here

    }
   
    private void throwSOAPFaultException() throws SOAPFaultException {
        try {
            MessageFactory mf = MessageFactory.newInstance();
            SOAPFactory sf = SOAPFactory.newInstance();
           
            SOAPMessage m = mf.createMessage();
            SOAPBody body = m.getSOAPBody();
            SOAPFault fault = body.addFault();
            QName faultCode = new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
            fault.setFaultCode(faultCode);
            fault.setFaultString("sample fault");
            Detail detail = fault.addDetail();
            Name deName = sf.createName("detailEntry");
            SOAPElement detailEntry = detail.addDetailEntry(deName);
            detailEntry.addTextNode("sample detail");
            fault.setFaultActor("sample actor");
           
            SOAPFaultException sfe = new SOAPFaultException(fault);
View Full Code Here

public class SOAPFactoryTest extends TestCase {
    private static final Log log = LogFactory.getLog(SOAPFactoryTest.class);

    public void testCreateDetail() {
        try {
            SOAPFactory sf = SOAPFactory.newInstance();
            if (sf == null) {
                fail("SOAPFactory was null");
            }
            Detail d = sf.createDetail();
            if (d == null) {
                fail("Detail was null");
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

    }

    public void testCreateElement() {
        try {
            //SOAPFactory sf = SOAPFactory.newInstance();
            SOAPFactory sf = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
            if (sf == null) {
                fail("createElementTest4() could not create SOAPFactory object");
            }
            //Create QName object with localName=MyName1,prefix=MyPrefix1, uri=MyUri1
            QName name = new QName("MyUri1", "MyName1", "MyPrefix1");
            SOAPElement se = sf.createElement(name);
            assertNotNull(se);
            name = se.getElementQName();
            String localName = name.getLocalPart();
            String prefix = name.getPrefix();
            String uri = name.getNamespaceURI();
View Full Code Here

    }


    public void testCreateElement2() {
        try {
            SOAPFactory sf = SOAPFactory.newInstance();
            //SOAPFactory sf = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
            if (sf == null) {
                fail("could not create SOAPFactory object");
            }
            log.info("Create a DOMElement");
            DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = dbfactory.newDocumentBuilder();
            Document document = builder.newDocument();
            Element de = document.createElementNS("http://MyNamespace.org/", "MyTag");
            //Calling SOAPFactory.createElement(org.w3c.dom.Element)
            SOAPElement se = sf.createElement(de);
            if (!de.getNodeName().equals(se.getNodeName()) || !de.getNamespaceURI().equals(
                    se.getNamespaceURI())) {
                //Node names are not equal
                fail("Got: <URI=" + se.getNamespaceURI() + ", PREFIX=" +
                        se.getPrefix() + ", NAME=" + se.getNodeName() + ">" +
View Full Code Here

        }
    }

    public void testCreateElement3() {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            if (factory == null) {
                fail("createFaultTest1() could not create SOAPFactory object");
            }
            SOAPFault sf = factory.createFault();
            if (sf == null) {
                fail("createFault() returned null");
            } else if (!(sf instanceof SOAPFault)) {
                fail("createFault() did not create a SOAPFault object");
            }
View Full Code Here

        }
    }

    public void testCreateElement4() {
        try {
            SOAPFactory sf = SOAPFactory.newInstance();
            if (sf == null) {
                fail("createElementTest6() could not create SOAPFactory object");
            }
            QName qname = new QName("http://MyNamespace.org/", "MyTag");
            SOAPElement se1 = sf.createElement(qname);
            //Create second SOAPElement from first SOAPElement
            SOAPElement se2 = sf.createElement(se1);
            //commented to support jdk 1.4 build
            //        if(!se1.isEqualNode(se2) && !se1.isSameNode(se2)) {
            //          fail("The SOAPElement's are not equal and not the same (unexpected)");
            //        }
            if (!se1.getNodeName().equals(se2.getNodeName()) || !se1.getNamespaceURI().equals(
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPFactory

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.