当前位置: 首页>>代码示例>>Java>>正文


Java SOAPEnvelope.getHeader方法代码示例

本文整理汇总了Java中org.apache.axiom.soap.SOAPEnvelope.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope.getHeader方法的具体用法?Java SOAPEnvelope.getHeader怎么用?Java SOAPEnvelope.getHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axiom.soap.SOAPEnvelope的用法示例。


在下文中一共展示了SOAPEnvelope.getHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeSOAPHeader

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private void removeSOAPHeader(MessageDataSource messageDataSource) throws SOAPException {

        SOAPEnvelope soapEnvelope = (SOAPEnvelope) messageDataSource.getDataObject();
        SOAPHeader soapHeader = soapEnvelope.getHeader();
        if (soapHeader != null) {
            for (Iterator iter = soapHeader.examineAllHeaderBlocks(); iter.hasNext(); ) {
                Object o = iter.next();
                if (o instanceof SOAPHeaderBlock) {
                    SOAPHeaderBlock headerBlk = (SOAPHeaderBlock) o;
                    if (name.equals(headerBlk.getLocalName())) {
                        headerBlk.detach();
                    }
                } else if (o instanceof OMElement) {
                    OMElement headerElem = (OMElement) o;
                    if (name.equals(headerElem.getLocalName())) {
                        headerElem.detach();
                    }
                }
            }
        }
    }
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:22,代码来源:HeaderMediator.java

示例2: checkSOAP12

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
protected void checkSOAP12() throws XdsWSException {
	
	if (MessageContext.getCurrentMessageContext().isSOAP11()) {
		throwFault("SOAP 1.1 not supported");
	}
	SOAPEnvelope env = MessageContext.getCurrentMessageContext().getEnvelope();
	if (env == null)
		throwFault("No SOAP envelope found");
	SOAPHeader hdr = env.getHeader();
	if (hdr == null)
		throwFault("No SOAP header found");
	if ( !hdr.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing","Action")).hasNext()) {
		throwFault("WS-Action required in header");
	}

}
 
开发者ID:jembi,项目名称:openxds,代码行数:17,代码来源:AppendixV.java

示例3: testCustomBuilder

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void testCustomBuilder(){
    try{
        SOAPEnvelope env = getMockEnvelope();
        SOAPHeader header = env.getHeader();
        SOAPBody body = env.getBody();
        ParserInputStreamCustomBuilder customBuilder = new ParserInputStreamCustomBuilder("UTF-8");
        InputStream payload = new ByteArrayInputStream(mockPayload.getBytes());
        OMElement om= customBuilder.create("urn:sample", "invokeOp",(OMContainer) body, parser, OMAbstractFactory.getOMFactory(), payload);
        assertTrue(om!=null);
        assertTrue(om instanceof OMSourcedElement);
        OMSourcedElement ose = (OMSourcedElement)om;
        assertNotNull(ose.getDataSource());
        assertTrue((ose.getDataSource()) instanceof ParserInputStreamDataSource);
    }catch(Exception e){
        fail(e.getMessage());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:ParserInputStreamCustomBuilderTests.java

示例4: invoke

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
    if (msgContext == null) {
        return InvocationResponse.CONTINUE;
    } 
            
    SOAPEnvelope envelope = msgContext.getEnvelope();
    if (envelope.getHeader() == null) {
        return InvocationResponse.CONTINUE;          
    }
    
    // Passing in null will get headers targeted for NEXT and ULTIMATE RECEIVER
    Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
    while (headerBlocks.hasNext()) {
        SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
        headerBlock.setProcessed();            
    }
    return InvocationResponse.CONTINUE;        
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:UnderstandAllHeadersHandler.java

示例5: getBSTHeader

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private String getBSTHeader(Request request) throws IOException, XMLStreamException {
    org.apache.coyote.Request coyoteReq = request.getCoyoteRequest();
    InputBuffer buf = coyoteReq.getInputBuffer();
    ByteChunk bc = new ByteChunk();

    buf.doRead(bc, coyoteReq);
    try (InputStream is = new ByteArrayInputStream(getUTF8Bytes(bc.toString()))) {
        XMLStreamReader reader = StAXUtils.createXMLStreamReader(is);
        StAXBuilder builder = new StAXSOAPModelBuilder(reader);
        SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
        envelope.build();

        SOAPHeader header = envelope.getHeader();
        Iterator headerEls = header.getChildrenWithLocalName("Security");
        if (!headerEls.hasNext()) {
            return null;
        }
        OMElement securityHeader = (OMElement) headerEls.next();
        Iterator securityHeaderEls = securityHeader.getChildrenWithLocalName("BinarySecurityToken");
        if (!securityHeaderEls.hasNext()) {
            return null;
        }
        OMElement bstHeader = (OMElement) securityHeaderEls.next();
        bstHeader.build();
        return bstHeader.getText();
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:BSTAuthenticator.java

示例6: testCreateElement

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
@Test
public void testCreateElement() throws Exception {
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    Messaging.createElement(env);

    // Check if header contains Messaging header block with mustUnderstand=true
    SOAPHeader header = env.getHeader();
    ArrayList blocks = header.getHeaderBlocksWithNSURI(EbMSConstants.EBMS3_NS_URI);
    assertTrue(blocks.size()>0);
    assertTrue(((SOAPHeaderBlock) blocks.get(0)).getMustUnderstand());
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:14,代码来源:MessagingTest.java

示例7: populateSOAPHeaders

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private static void populateSOAPHeaders(
        org.apache.ode.bpel.iapi.Message messageFromOde,
        SOAPEnvelope soapEnvelope,
        SOAPFactory soapFactory,
        List<javax.wsdl.extensions.soap.SOAPHeader> soapHaderDefinitions,
        Operation operation
) throws BPELFault {
    if (messageFromOde.getHeaderParts().size() > 0
            || soapHaderDefinitions.size() > 0) {
        for (javax.wsdl.extensions.soap.SOAPHeader soapHeaderDefinition : soapHaderDefinitions) {
            handleSOAPHeaderElementsInBindingOperation(
                    soapEnvelope,
                    soapFactory,
                    messageFromOde,
                    operation,
                    soapHeaderDefinition);
        }

        org.apache.axiom.soap.SOAPHeader soapHeader = soapEnvelope.getHeader();
        if (soapHeader == null) {
            soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
        }

        for (Node headerNode : messageFromOde.getHeaderParts().values()) {
            if (headerNode.getNodeType() == Node.ELEMENT_NODE) {
                addSOAPHeaderBock(soapHeader, headerNode, soapFactory);
            } else {
                throw new BPELFault("SOAP Header Must be an Element");
            }
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:33,代码来源:SOAPUtils.java

示例8: checkMustUnderstand

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private boolean checkMustUnderstand(MessageContext msgContext) throws AxisFault {
    boolean checksPass = true;

    SOAPEnvelope envelope = msgContext.getEnvelope();
    if (envelope.getHeader() == null) {
        return checksPass;
    }
    
    // First mark all the headers JAXWS would understand to make sure we don't throw
    // a mustUnderstand fault inappropriately for those.
    MustUnderstandUtils.markUnderstoodHeaderParameters(msgContext);

    // Now check all the headers and throw the mustUnderstandFault if any not understood.
    // REVIEW: Note that QoSes that would run after the dispatch phase will not have marked
    // their headers yet.

    Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
    while (headerBlocks.hasNext()) {
        SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
        if (headerBlock.isProcessed() || !headerBlock.getMustUnderstand()) {
            continue;
        }

        QName faultQName = headerBlock.getVersion().getMustUnderstandFaultCode();
        throw new AxisFault(Messages.getMessage("mustunderstandfailed",
                                                headerBlock.getNamespace().getNamespaceURI(),
                                                headerBlock.getLocalName()), faultQName);
    }
    return checksPass;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:31,代码来源:MustUnderstandValidationDispatcher.java

示例9: shouldInvoke

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public boolean shouldInvoke(MessageContext msgContext) throws AxisFault {
    if (msgContext == null) {
        return false;
    }
    SOAPEnvelope envelope = msgContext.getEnvelope();
    return envelope.getHeader() != null;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:8,代码来源:MustUnderstandChecker.java

示例10: markUnderstoodHeaderParameters

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Mark all headers for JAXWS SEI method paramaters as understood.  Note that per the JAXWS
 * 2.0 specification, a header is considered understood if it used by as a parameter for 
 * any method on the SEI, not just the method corresponding to the incoming operation.  
 * See Section 10.2.1 item 3.a which specifically says "mapped to method parameters
 * in the service endpoint interface".
 * 
 * @param msgContext
 */
public static void markUnderstoodHeaderParameters(MessageContext msgContext) {
    if (msgContext == null) {
        return;
    }
    
    SOAPEnvelope envelope = msgContext.getEnvelope();
    if (envelope.getHeader() == null) {
        return;
    }
    
    ArrayList understoodHeaderQNames = MustUnderstandUtils.getHeaderParamaterList(msgContext);
    if (understoodHeaderQNames == null || understoodHeaderQNames.isEmpty()) {
        return;
    }
    
    // Passing in null will get headers targeted for NEXT and ULTIMATE RECEIVER
    Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
    while (headerBlocks.hasNext()) {
        SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
        QName headerQN = headerBlock.getQName();
        if (understoodHeaderQNames.contains(headerQN)) {
            headerBlock.setProcessed();
            if (log.isDebugEnabled()) {
                log.debug("Header marked as processed by JAXWS MustUnderstandChecker: " 
                          + headerQN);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:39,代码来源:MustUnderstandUtils.java

示例11: invoke

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
        // Get the list of headers for the roles we're acting in, then mark any we understand
        // as processed.
        SOAPEnvelope envelope = msgContext.getEnvelope();
        if (envelope.getHeader() == null) {
            return InvocationResponse.CONTINUE;
        }
        // These are the headers the test expects to be understood
        String ns1 = "http://ws.apache.org/axis2";
        String clientLocalName = "muclientunderstood";
        String serverLocalName = "muserverunderstood";

        QName clientQN = new QName(ns1, clientLocalName);
        QName serverQN = new QName(ns1, serverLocalName);

        Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
        while (headerBlocks.hasNext()) {
            SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
            QName headerQN = headerBlock.getQName();
            if (clientQN.equals(headerQN)) {
//                System.out.println("Marking as processed CLIENT QN: " + clientQN);
                headerBlock.setProcessed();
            } else if (serverQN.equals(headerQN)) {
//                System.out.println("Marking as processed SERVER QN: " + serverQN);
                headerBlock.setProcessed();
            }
        }

        return InvocationResponse.CONTINUE;
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:31,代码来源:SoapMessageMUProviderChecker.java

示例12: testCustomBuilderSOAPENVNamespace

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void testCustomBuilderSOAPENVNamespace(){
    try{
        SOAPEnvelope env = getMockEnvelope();
        SOAPHeader header = env.getHeader();
        SOAPBody body = env.getBody();
        ParserInputStreamCustomBuilder customBuilder = new ParserInputStreamCustomBuilder("UTF-8");
        InputStream payload = new ByteArrayInputStream(mockPayload.getBytes());

        // If there is no namespace, the customer building should not occur.
        OMElement om= customBuilder.create("http://www.w3.org/2003/05/soap-envelope", "Fault",(OMContainer) body, parser, OMAbstractFactory.getOMFactory(), payload);
        assertTrue(om==null);
    }catch(Exception e){
        fail(e.getMessage());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:16,代码来源:ParserInputStreamCustomBuilderTests.java

示例13: addHeadersToEnvelope

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Add all configured headers to a SOAP envelope.
 *
 * @param envelope the SOAPEnvelope in which to write the headers
 */
public void addHeadersToEnvelope(SOAPEnvelope envelope) {
    if (headers != null) {
        SOAPHeader soapHeader = envelope.getHeader();
        for (Object header : headers) {
            soapHeader.addChild((OMElement)header);
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:ServiceClient.java

示例14: isHandle

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
@Override
public boolean isHandle(MessageContext msgCxt) {
    boolean canHandle = false;

    if (!isDisabled()) {

        if (!authenticatorInitialized) {
            init();
            if (!authenticatorInitialized) {
                return canHandle;
            }
        }

        HttpServletRequest request = (HttpServletRequest) msgCxt.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
        String authorizationHeader = request.getHeader(HTTPConstants.HEADER_AUTHORIZATION);
        // This authenticator should kickin only if authorization headers are null
        if (authorizationHeader == null) {
            Object certObject = request.getAttribute(JAVAX_SERVLET_REQUEST_CERTIFICATE);
            if (certObject != null) {
                SOAPEnvelope envelope = msgCxt.getEnvelope();
                SOAPHeader header = envelope.getHeader();
                boolean validHeader = false;

                if (header != null) {
                    List<SOAPHeaderBlock> headers = header.getHeaderBlocksWithNSURI(MUTUAL_SSL_URL);
                    if (headers != null) {
                        for (SOAPHeaderBlock soapHeaderBlock : headers) {
                            if (usernameHeaderName.equals(soapHeaderBlock.getLocalName())) {
                                //Username can be in SOAP Header
                                canHandle = true;
                                validHeader = true;
                                break;
                            }
                        }
                    }
                }

                if (!canHandle && StringUtils.isNotEmpty(request.getHeader(usernameHeaderName))) {
                    validHeader = true;
                    // Username is received in HTTP Header
                    canHandle = true;
                }

                if (!validHeader && log.isDebugEnabled()) {
                    log.debug("'" + usernameHeaderName + "'" + " header is not received in HTTP or SOAP header");
                }

            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Server is not picking up the client certificate. Mutual SSL authentication is not" +
                            "done");
                }
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("MutualSSLAuthenticator is Disabled.");
        }
    }
    return canHandle;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:62,代码来源:MutualSSLAuthenticator.java

示例15: toSubscription

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * create request for unsubscribe request
 * (01) <s12:Envelope
 * (02)     xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
 * (03)     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
 * (04)     xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing"
 * (05)     xmlns:ow="http://www.example.org/oceanwatch" >
 * (06)   <s12:Header>
 * (07)     <wsa:Action>
 * (08)       http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe
 * (09)     </wsa:Action>
 * (10)     <wsa:MessageID>
 * (11)       uuid:2653f89f-25bc-4c2a-a7c4-620504f6b216
 * (12)     </wsa:MessageID>
 * (13)     <wsa:ReplyTo>
 * (14)      <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>
 * (15)     </wsa:ReplyTo>
 * (16)     <wsa:To>
 * (17)       http://www.example.org/oceanwatch/SubscriptionManager
 * (18)     </wsa:To>
 * (19)     <wse:Identifier>
 * (20)       uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa
 * (21)     </wse:Identifier>
 * (22)   </s12:Header>
 * (23)   <s12:Body>
 * (24)     <wse:Unsubscribe />
 * (25)   </s12:Body>
 * (26) </s12:Envelope>
 *
 * @param envelope The soap envelope containing the unsubscribe request
 * @return The subscription to remove
 * @throws InvalidMessageException
 */
public Subscription toSubscription(SOAPEnvelope envelope) throws InvalidMessageException {
    if (envelope == null) {
        log.error("No SOAP envelope was provided.");
        throw new BuilderException("No SOAP envelope was provided.");
    }
    Subscription subscription = new Subscription();
    OMElement elem = null;
    if (envelope.getHeader() != null) {
        elem = envelope.getHeader().getFirstChildWithName(IDENTIFIER);
    }
    if (elem == null) {
        log.error(
                "Subscription Identifier is required as a header of the subscription message.");
        throw new InvalidMessageException(
                "Subscription Identifier is required as a header of the subscription message.");
    }
    String id = elem.getText().trim();
    subscription.setId(id);
    
    return subscription;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:55,代码来源:UnSubscribeCommandBuilder.java


注:本文中的org.apache.axiom.soap.SOAPEnvelope.getHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。