Package org.apache.axis2.jaxws.handler

Examples of org.apache.axis2.jaxws.handler.SOAPHeadersAdapter


        acoh1ContentList.add(acoh1);
       
        List<String> acoh2ContentList = new ArrayList<String>();
        acoh2ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        adapter.put(ACOH2_HEADER_QNAME, acoh2ContentList);
        adapter.remove(ACOH1_HEADER_QNAME);
       
        // testing "keySet()" method
        Set<QName> keyset = adapter.keySet();
        assertTrue(!keyset.contains(ACOH1_HEADER_QNAME));
        assertTrue(keyset.contains(ACOH2_HEADER_QNAME));

        // re-check to make sure nothing got corrupted
        assertTrue(adapter.get(ACOH2_HEADER_QNAME).get(0).equals(acoh2));
  }
View Full Code Here


      acoh1ContentList.add(acoh1);

      List<String> acoh2ContentList = new ArrayList<String>();
      acoh2ContentList.add(acoh2);

      SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);

      Map<QName, List<String>> hm1 = new HashMap<QName, List<String>>();
        hm1.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        Map<QName, List<String>> hm2 = new HashMap<QName, List<String>>();
        hm2.put(ACOH2_HEADER_QNAME, acoh2ContentList);
     
      adapter.putAll(hm1);
      adapter.putAll(hm2);

      // testing "entrySet()" method
      Set<Map.Entry<QName, List<String>>> entryset = adapter.entrySet();
     
        int checkCounter = 0;
      for (Iterator it = entryset.iterator();it.hasNext();) {
          Map.Entry<QName, List<String>> entry = (Map.Entry<QName, List<String>>)it.next();
          // we cannot assume that the order the maps went into
          // the adapter will be the order they come out:
          if (entry.getKey().equals(ACOH1_HEADER_QNAME)) {
              assertTrue(entry.getKey().equals(ACOH1_HEADER_QNAME));
              assertTrue(entry.getValue().equals(acoh1ContentList));
              checkCounter++;
          } else if (entry.getKey().equals(ACOH2_HEADER_QNAME)) {
              assertTrue(entry.getKey().equals(ACOH2_HEADER_QNAME));
              assertTrue(entry.getValue().equals(acoh2ContentList));
              checkCounter += 2;
          }
      }
        assertTrue("Expected entrySet was not returned from SOAPHeadersAdapter.entrySet().", checkCounter == 3);

      // re-check to make sure nothing got corrupted
      assertTrue(adapter.get(ACOH1_HEADER_QNAME).get(0).equals(acoh1));
      assertTrue(adapter.get(ACOH2_HEADER_QNAME).get(0).equals(acoh2));
  }
View Full Code Here

       
        Map<QName, List<String>> requestHeaders = new HashMap<QName, List<String>>();
        requestHeaders.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        requestHeaders.put(ACOH2_HEADER_QNAME, acoh2ContentList);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);

        adapter.putAll(requestHeaders);
       
        // testing "keySet()" method
        Set<QName> keyset = adapter.keySet();
        assertTrue(keyset.contains(ACOH1_HEADER_QNAME));
        assertTrue(keyset.contains(ACOH2_HEADER_QNAME));

        // check the data too
        assertTrue(adapter.get(ACOH1_HEADER_QNAME).get(0).equals(acoh1));
        assertTrue(adapter.get(ACOH2_HEADER_QNAME).get(0).equals(acoh2));
  }
View Full Code Here

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
       
        // get message object and convert to SOAPMessage
        SOAPMessage soapMessage = messageContext.getMessage().getAsSOAPMessage();
       
        // confirm headers are there
        SOAPHeader soapHeader = soapMessage.getSOAPHeader();
        Iterator<SOAPHeaderElement> it = soapHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        SOAPHeaderElement headerElem1 = it.next();
        SOAPHeaderElement headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
       
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
       
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
       
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detachNode();
       
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
       
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));
       
  }
View Full Code Here

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
       
        // get message object and convert to SOAPEnvelope
        SOAPEnvelope soapEnvelope = messageContext.getMessage().getAsSOAPEnvelope();
       
        // confirm headers are there
        SOAPHeader soapHeader = soapEnvelope.getHeader();
        Iterator<SOAPHeaderElement> it = soapHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        SOAPHeaderElement headerElem1 = it.next();
        SOAPHeaderElement headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
       
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
       
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
       
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detachNode();
       
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
       
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));
       
  }
View Full Code Here

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
       
        // get message object and convert to SOAPEnvelope
        OMElement omEnvelope = messageContext.getMessage().getAsOMElement();
       
        // confirm headers are there.  I can cast here only because I know the implementation.  :)
        SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next();

        Iterator<OMSourcedElementImpl> it = omHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        OMSourcedElementImpl headerElem1 = it.next();
        OMSourcedElementImpl headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
       
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
       
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
       
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detach();
       
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
       
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));

  }
View Full Code Here

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
       
        // get message object and convert to SOAPEnvelope
        OMElement omEnvelope = messageContext.getMessage().getAsOMElement();
       
        // confirm headers are there.  I can cast here only because I know the implementation.  :)
        SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next();

        Iterator<OMSourcedElementImpl> it = omHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        OMSourcedElementImpl headerElem1 = it.next();
        OMSourcedElementImpl headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
       
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
       
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
       
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detach();
       
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
       
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));

  }
View Full Code Here

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
       
        List<String> headersList = adapter.get(ACOH1_HEADER_QNAME);
        headersList.get(0).toString()// trigger some underlying OM implementation parsing
       
        // use the LogicalMessageImpl to get the message payload
        MyLogicalMessageImpl logicalMessageImpl = new MyLogicalMessageImpl(messageContext);
        Source payload = logicalMessageImpl.getPayload();
        payload.toString();
       
        // get message object and convert to SOAPEnvelope
        OMElement omEnvelope = messageContext.getMessage().getAsOMElement();
       
        // confirm headers are there.  I can cast here only because I know the implementation.  :)
        SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next();

        Iterator<OMSourcedElementImpl> it = omHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        OMSourcedElementImpl headerElem1 = it.next();
        OMSourcedElementImpl headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
       
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
       
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
       
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detach();
       
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
       
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));

  }
View Full Code Here

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        adapter.put(ACOH2_HEADER_QNAME, acoh1ContentList);
        adapter.remove(ACOH1_HEADER_QNAME);
       
        assertTrue("Adapter should have one item, but has " + adapter.size(), adapter.size() == 1);

  }
View Full Code Here

        acoh1ContentList.add(acoh1);
       
        List<String> acoh2ContentList = new ArrayList<String>();
        acoh2ContentList.add(acoh2);
       
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
       
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        adapter.put(ACOH2_HEADER_QNAME, acoh2ContentList);
        adapter.remove(ACOH1_HEADER_QNAME);
        adapter.remove(ACOH2_HEADER_QNAME);
       
        // testing isEmpty() method
        assertTrue("Adapter should have no items, but has " + adapter.size(), adapter.isEmpty());
       
        // double-check
        assertTrue("isEmpty() reported 'true' but we found an item", adapter.get(ACOH1_HEADER_QNAME) == null);
        assertTrue("isEmpty() reported 'true' but we found an item", adapter.get(ACOH2_HEADER_QNAME) == null);

  }
View Full Code Here

TOP

Related Classes of org.apache.axis2.jaxws.handler.SOAPHeadersAdapter

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.