Package javax.xml.soap

Examples of javax.xml.soap.SOAPHeaderElement


    public void testHeaderElements() throws Exception {
        SOAPEnvelope envelope = getSOAPEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPHeader hdr = envelope.getHeader();

        SOAPHeaderElement she1 = hdr.addHeaderElement(envelope.createName("foo1", "f1", "foo1-URI"));
        she1.setActor("actor-URI");
        java.util.Iterator iterator = hdr.extractHeaderElements("actor-URI");
        int cnt = 0;
        while (iterator.hasNext()) {
            cnt++;
            SOAPHeaderElement she = (SOAPHeaderElement) iterator.next();
            assertTrue(she.equals(she1));
        }
        assertTrue(cnt == 1);
        iterator = hdr.extractHeaderElements("actor-URI");
        assertTrue(!iterator.hasNext());
    }
View Full Code Here


        // Create an example SOAP envelope
        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        SOAPHeader h = env.getHeader();
        SOAPBody b = env.getBody();
        Name heName = env.createName("localName", "prefix", "http://uri");
        SOAPHeaderElement he = h.addHeaderElement(heName);
        he.setActor("actor");

        // Serialize the SOAP envelope
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream os = new ObjectOutputStream(bos);
        os.writeObject(env);

        // Deserializet the SOAP envelope
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream is = new ObjectInputStream(bis);
        SOAPEnvelope env2 = (SOAPEnvelope)is.readObject();

        // Check that the SOAP envelope survived the round trip
        SOAPHeader h2 = env2.getHeader();
        SOAPHeaderElement he2 = (SOAPHeaderElement)h2.
            examineHeaderElements("actor").next();
        Name heName2 = he2.getElementName();
        assertEquals("Local name did not survive java ser+deser",
                     heName.getLocalName(), heName2.getLocalName());
        assertEquals("Prefix did not survive java ser+deser",
                     heName.getPrefix(), heName2.getPrefix());
        assertEquals("URI did not survive java ser+deser",
View Full Code Here

        SOAPHeader header = ((SaajSoapMessage) message).getSaajMessage().getSOAPHeader();
        Iterator<?> iterator = header.getChildElements(new QName(
                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security"));
        assertTrue("No security header", iterator.hasNext());
        SOAPHeaderElement securityHeader = (SOAPHeaderElement) iterator.next();
        iterator = securityHeader.getChildElements(new QName("http://www.w3.org/2000/09/xmldsig#", "Signature"));
        assertTrue("No signature header", iterator.hasNext());

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        message.writeTo(bos);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersUnderstoodSoap11() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header =
                request.getSOAPHeader().addHeaderElement(new QName("http://www.springframework.org", "Header"));
        header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT);
        header.setMustUnderstand(true);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);

        replay(interceptorMock);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersUnderstoodSoap12() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header =
                request.getSOAPHeader().addHeaderElement(new QName("http://www.springframework.org", "Header"));
        header.setMustUnderstand(true);
        header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);

        replay(interceptorMock);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersNotUnderstoodSoap11() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header = request.getSOAPHeader()
                .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws"));
        header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT);
        header.setMustUnderstand(true);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(false);

        replay(interceptorMock);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersNotUnderstoodSoap12() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header = request.getSOAPHeader()
                .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws"));
        header.setMustUnderstand(true);
        header.setRole(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(false);

        replay(interceptorMock);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersForActorSoap11() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header = request.getSOAPHeader()
                .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws"));
        String headerActor = "http://www/springframework.org/role";
        header.setActor(headerActor);
        header.setMustUnderstand(true);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);

        replay(interceptorMock);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersForRoleSoap12() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header = request.getSOAPHeader()
                .addHeaderElement(new QName("http://www.springframework.org", "Header", "spring-ws"));
        String headerRole = "http://www/springframework.org/role";
        header.setRole(headerRole);
        header.setMustUnderstand(true);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        expect(interceptorMock.understands(isA(SoapHeaderElement.class))).andReturn(true);

        replay(interceptorMock);
View Full Code Here

    @Test
    public void testProcessMustUnderstandHeadersNoInterceptors() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage request = messageFactory.createMessage();
        SOAPHeaderElement header =
                request.getSOAPHeader().addHeaderElement(new QName("http://www.springframework.org", "Header"));
        header.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT);
        header.setMustUnderstand(true);
        SoapMessageFactory factory = new SaajSoapMessageFactory(messageFactory);
        MessageContext context = new DefaultMessageContext(new SaajSoapMessage(request), factory);
        replay(interceptorMock);

        SoapEndpointInvocationChain chain = new SoapEndpointInvocationChain(new Object(), null);
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPHeaderElement

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.