當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPEnvelope.getHeader方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPEnvelope.getHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPEnvelope.getHeader方法的具體用法?Java SOAPEnvelope.getHeader怎麽用?Java SOAPEnvelope.getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPEnvelope的用法示例。


在下文中一共展示了SOAPEnvelope.getHeader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Override
public boolean handleMessage(SOAPMessageContext context) {
	Boolean request = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (!request) {
		try {
			SOAPMessage msg = context.getMessage();
			SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
			SOAPHeader header = env.getHeader();
			if (header == null) {
				header = env.addHeader();
				return false;
			}
			Node node = (Node) header.getElementsByTagName("token").item(0);
			String token = node.getChildNodes().item(0).getNodeValue();
			if (token != null && token.equals("Kalango Lab")) {
				System.out.println("Token válido");
				return true;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	return true;
}
 
開發者ID:kalangolab,項目名稱:programacaoweb,代碼行數:27,代碼來源:UsuarioHandlerMessage.java

示例2: createSimpleSOAPPart

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private void createSimpleSOAPPart(SOAPMessage message) throws SOAPException {
    SOAPPart sPart = message.getSOAPPart();
    SOAPEnvelope env = sPart.getEnvelope();
    SOAPBody body = env.getBody();
    SOAPHeader header = env.getHeader();
    header.addHeaderElement(env.createName("Header1",
                                           "pref",
                                           "http://test.apach.org/test"))
            .addTextNode("This is header1");

    Name ns = env.createName("echo", "swa2", "http://fakeNamespace2.org");
    final SOAPBodyElement bodyElement = body.addBodyElement(ns);
    Name ns2 = env.createName("something");
    final SOAPElement ele1 = bodyElement.addChildElement(ns2);
    ele1.addTextNode("This is some text");

    Name ns3 = env.createName("ping", "swa3", "http://fakeNamespace3.org");
    final SOAPBodyElement bodyElement2 = body.addBodyElement(ns3);
    Name ns4 = env.createName("another");
    final SOAPElement ele2 = bodyElement2.addChildElement(ns4);
    ele2.addTextNode("This is another text");
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:23,代碼來源:IntegrationTest.java

示例3: testProviderDispatch

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
   Dispatch<SOAPMessage> dispatch = createDispatch("ProviderEndpoint");
   SOAPMessage reqMsg = getRequestMessage();

   SOAPMessage resMsg = dispatch.invoke(reqMsg);
   SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
   
   SOAPHeader soapHeader = resEnv.getHeader();
   if (soapHeader != null)
      soapHeader.detachNode();
   
   assertEquals(DOMUtils.parse(msgString), resEnv);
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:17,代碼來源:ProviderMessageTestCase.java

示例4: testProviderMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Test
@RunAsClient
public void testProviderMessage() throws Exception
{
   SOAPMessage reqMsg = getRequestMessage();
   SOAPEnvelope reqEnv = reqMsg.getSOAPPart().getEnvelope();

   URL epURL = baseURL;
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();

   SOAPHeader soapHeader = resEnv.getHeader();
   if (soapHeader != null)
      soapHeader.detachNode();
   
   assertEquals(reqEnv, resEnv);
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:19,代碼來源:ProviderMessageTestCase.java

示例5: getSecurityHeader

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private SOAPHeaderElement getSecurityHeader(SOAPEnvelope envelope) throws SOAPException {
    if (envelope != null) {
        SOAPHeader header = envelope.getHeader();
        if (header != null) {
            Iterator<?> iter = header.getChildElements(WSSE_QNAME);
            if (iter.hasNext()) {
                return (SOAPHeaderElement)iter.next();
            }
            iter = header.getChildElements(WSSE_2_QNAME);
            if (iter.hasNext()) {
                return (SOAPHeaderElement)iter.next();
            }
            iter = header.getChildElements(WSSE_11_QNAME);
            if (iter.hasNext()) {
                return (SOAPHeaderElement)iter.next();
            }
        }
    }
    return null;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:21,代碼來源:SOAPMessageCredentialExtractor.java

示例6: addXTeeHeaderElements

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Override
public void addXTeeHeaderElements(SOAPEnvelope env, XRoadServiceConfiguration conf) throws SOAPException {
  SOAPHeader header = env.getHeader();
  if(StringUtils.isNotBlank(conf.getIdCode())) {
    SOAPElement userId = header.addChildElement("userId", protocol.getNamespacePrefix());
    userId.addTextNode(conf.getIdCode());
  }
  SOAPElement id = header.addChildElement("id", protocol.getNamespacePrefix());
  id.addTextNode(generateUniqueMessageId(conf));
  if (StringUtils.isNotBlank(conf.getFile())) {
    SOAPElement issue = header.addChildElement("issue", protocol.getNamespacePrefix());
    issue.addTextNode(conf.getFile());
  }
  SOAPElement protocolVersion = header.addChildElement("protocolVersion", protocol.getNamespacePrefix());
  protocolVersion.addTextNode(protocol.getCode());

  addClientElements(env, conf, header);
  addServiceElements(env, conf, header);
}
 
開發者ID:nortal,項目名稱:j-road,代碼行數:20,代碼來源:XRoadProtocolNamespaceStrategyV4.java

示例7: testHeaderElements

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testHeaderElements() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPHeader header = envelope.getHeader();

    SOAPHeaderElement headerEle = header.addHeaderElement(envelope.createName("foo1",
                                                                              "f1",
                                                                              "foo1-URI"));
    headerEle.setActor("actor-URI");
    headerEle.setMustUnderstand(true);

    Iterator iterator = header.extractHeaderElements("actor-URI");
    int cnt = 0;
    while (iterator.hasNext()) {
        cnt++;
        SOAPHeaderElement resultHeaderEle = (SOAPHeaderElement)iterator.next();

        assertEquals(headerEle.getActor(), resultHeaderEle.getActor());
        assertEquals(resultHeaderEle.getMustUnderstand(), headerEle.getMustUnderstand());
    }
    assertTrue(cnt == 1);
    iterator = header.extractHeaderElements("actor-URI");
    assertTrue(!iterator.hasNext());
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:25,代碼來源:SOAPEnvelopeTest.java

示例8: testAddSource2

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testAddSource2() throws Exception {
    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
    SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
    SOAPHeader header = soapEnv.getHeader();
    SOAPBody body = soapEnv.getBody();

    assertTrue(header.addChildElement("ebxmlms1", "ch2",
                                      "http://test.apache.org") instanceof SOAPHeaderElement);
    assertTrue(header.addHeaderElement(
            soapEnv.createName("ebxmlms2", "ch3", "http://test2.apache.org")) != null);
    assertTrue(header.addHeaderElement(
            new PrefixedQName("http://test3.apache.org", "ebxmlms3", "ch5")) != null);

    body.addChildElement("bodyEle1", "ele1", "http://ws.apache.org");
    soapMessage.saveChanges();

    SOAPMessage soapMessage2 = MessageFactory.newInstance().createMessage();
    SOAPPart soapPart = soapMessage2.getSOAPPart();
    soapPart.setContent(soapMessage.getSOAPPart().getContent());
    soapMessage2.saveChanges();
    assertNotNull(soapMessage2);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:SOAPPartTest.java

示例9: testAddSource3

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testAddSource3() throws Exception {
    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
    SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
    SOAPHeader header = soapEnv.getHeader();
    SOAPBody body = soapEnv.getBody();

    assertTrue(header.addChildElement("ebxmlms1", "ch2",
                                      "http://test.apache.org") instanceof SOAPHeaderElement);
    assertTrue(header.addHeaderElement(
            soapEnv.createName("ebxmlms2", "ch3", "http://test2.apache.org")) != null);
    assertTrue(header.addHeaderElement(
            new PrefixedQName("http://test3.apache.org", "ebxmlms3", "ch5")) != null);

    body.addChildElement("bodyEle1", "ele1", "http://ws.apache.org");
    soapMessage.saveChanges();

    SOAPMessage soapMessage2 = MessageFactory.newInstance().createMessage();
    SOAPPart soapPart = soapMessage2.getSOAPPart();
    soapPart.setContent(soapMessage.getSOAPPart().getContent());
    soapMessage2.saveChanges();
    assertNotNull(soapMessage2);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:SOAPPartTest.java

示例10: handleMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Override
public boolean handleMessage(final SOAPMessageContext msgCtx) {

    // Indicator telling us which direction this message is going in
    final Boolean outInd = (Boolean) msgCtx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    // Handler must only add security headers to outbound messages
    if (outInd.booleanValue()) {
        try {
            // Get the SOAP Envelope
            final SOAPEnvelope envelope = msgCtx.getMessage().getSOAPPart().getEnvelope();

            // Header may or may not exist yet
            SOAPHeader header = envelope.getHeader();
            if (header == null)
                header = envelope.addHeader();

            // Add WSS Usertoken Element Tree 
            final SOAPElement security = header.addChildElement("Security", "wsse",
                    "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
            final SOAPElement userToken = security.addChildElement("UsernameToken", "wsse");
            userToken.addChildElement("Username", "wsse").addTextNode(userId);
            userToken.addChildElement("Password", "wsse").addAttribute(new QName("Type"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText").addTextNode(password);

        } catch (final Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:32,代碼來源:SOAPSecurityHandler.java

示例11: handleMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
 * The method is invoked for normal processing of outbound messages.
 * 
 * @param context
 *            the message context.
 * @return An indication of whether handler processing should continue for
 *         the current message. Return <code>true</code> to continue
 *         processing.
 * 
 * @throws Exception
 *             Causes the JAX-WS runtime to cease fault message processing.
 **/
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request_p = (Boolean) context
            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (request_p.booleanValue()) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader hdr = env.getHeader();
            if (hdr == null) {
                hdr = env.addHeader();
            }
            QName qname_user = new QName("http://com/auth/", "auth");
            SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
            helem_user.setActor(VERSION);
            if (version != null && version.trim().length() != 0) {
                helem_user.addTextNode(version);
            }

            msg.saveChanges();
            message = soapMessage2String(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return true;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:41,代碼來源:VersionHandlerCtmg.java

示例12: handleMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
 * The method is invoked for normal processing of outbound messages.
 * 
 * @param context
 *            the message context.
 * @return An indication of whether handler processing should continue for
 *         the current message. Return <code>true</code> to continue
 *         processing.
 * 
 * @throws Exception
 *             Causes the JAX-WS runtime to cease fault message processing.
 **/
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request_p = (Boolean) context
            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (request_p.booleanValue()) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader hdr = env.getHeader();
            if (hdr == null) {
                hdr = env.addHeader();
            }
            QName qname_user = new QName("http://com/auth/", "auth");
            SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
            helem_user.setActor(VERSION);
            if (version == null || version.trim().length() == 0) {
                helem_user.addTextNode(apiVersionInfo.getProperty(VERSION));
            } else {
                helem_user.addTextNode(version);
            }

            msg.saveChanges();
            message = soapMessage2String(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return true;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:43,代碼來源:VersionHandler.java

示例13: parseApiVersion

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
public static String parseApiVersion(SOAPMessageContext context)
        throws SOAPException {

    SOAPMessage soapMessage = context.getMessage();

    SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
    SOAPHeader soapHeader = soapEnvelope.getHeader();
    if (soapHeader == null) {
        return "";
    }

    Iterator<?> it = null;
    Iterator<?> itCm = soapHeader.extractHeaderElements(VERSION_CM);
    if (itCm == null || !itCm.hasNext()) {
        Iterator<?> itCtmg = soapHeader.extractHeaderElements(VERSION_CTMG);
        if (itCtmg == null || !itCtmg.hasNext()) {
            return "";
        } else {
            it = itCtmg;
        }
    } else {
        it = itCm;
    }

    Node node = (Node) it.next();
    String value = node == null ? null : node.getValue();

    return value;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:30,代碼來源:SoapRequestParser.java

示例14: createProbeXML

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private byte[] createProbeXML() throws SOAPException, IOException {
	MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
	SOAPMessage message = messageFactory.createMessage();
	SOAPPart part = message.getSOAPPart();
	SOAPEnvelope envelope = part.getEnvelope();
	envelope.addNamespaceDeclaration("wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
	envelope.addNamespaceDeclaration("tns", "http://schemas.xmlsoap.org/ws/2005/04/discovery");
	envelope.addNamespaceDeclaration("nns", "http://www.onvif.org/ver10/network/wsdl");
	QName action = envelope.createQName("Action", "wsa");
	QName mid = envelope.createQName("MessageID", "wsa");
	QName to = envelope.createQName("To", "wsa");
	QName probe = envelope.createQName("Probe", "tns");
	QName types = envelope.createQName("Types", "tns");
	QName tramsmitter=envelope.createQName("NetworkVideoTransmitter", "nns");
	SOAPHeader header = envelope.getHeader();
	SOAPElement actionEl = header.addChildElement(action);
	actionEl.setTextContent("http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe");
	SOAPElement messIsEl = header.addChildElement(mid);
	messIsEl.setTextContent("urn:uuid:" + UUID.randomUUID().toString());
	SOAPElement toEl = header.addChildElement(to);
	toEl.setTextContent("urn:schemas-xmlsoap-org:ws:2005:04:discovery");
	SOAPBody body = envelope.getBody();
	SOAPElement probeEl = body.addChildElement(probe);
	SOAPElement typesEl=probeEl.addChildElement(types);
	typesEl.setTextContent("nns:NetworkVideoTransmitter");
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	message.writeTo(out);
	return out.toByteArray();
}
 
開發者ID:D2Edev,項目名稱:onvifjava,代碼行數:30,代碼來源:CameraDiscovery.java

示例15: getStockQuote

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
public String getStockQuote(String tickerSymbol) throws Exception {
    SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection con = scFactory.createConnection();

    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();

    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();

    SOAPHeader header = envelope.getHeader();
    SOAPBody body = envelope.getBody();

    header.detachNode();

    Name bodyName = envelope.createName("getQuote", "n", "urn:xmethods-delayed-quotes");
    SOAPBodyElement gltp = body.addBodyElement(bodyName);

    Name name = envelope.createName("symbol");
    SOAPElement symbol = gltp.addChildElement(name);
    symbol.addTextNode(tickerSymbol);

    URLEndpoint endpoint = new URLEndpoint("http://64.124.140.30/soap");
    SOAPMessage response = con.call(message, endpoint);
    con.close();

    SOAPPart sp = response.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    SOAPBody sb = se.getBody();
    Iterator it = sb.getChildElements();
    while (it.hasNext()) {
        SOAPBodyElement bodyElement = (SOAPBodyElement) it.next();
        Iterator it2 = bodyElement.getChildElements();
        while (it2.hasNext()) {
            SOAPElement element2 = (SOAPElement) it2.next();
            return element2.getValue();
        }
    }
    return null;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:41,代碼來源:DelayedStockQuote.java


注:本文中的javax.xml.soap.SOAPEnvelope.getHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。