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


Java MimeHeaders.addHeader方法代碼示例

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


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

示例1: createSOAPRequestMessage

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
 * createSOAPRequestMessage - create a SOAP message from an object
 *
 * @param webServiceKey
 *            key to locate the web service
 * @param request
 *            - request body content
 * @param action
 *            - SOAP Action string
 * @return SOAPMessage
 * @throws SOAPException
 *             - if there was an error creating the SOAP Connection
 * @throws JAXBException
 *             - if there was an error marshalling the SOAP Message
 */
private SOAPMessage createSOAPRequestMessage(String webServiceKey, Object request, String action) throws SOAPException, JAXBException {
    WebService service = getWebService(webServiceKey);

    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();

    // SOAP Envelope
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("example", service.getNamespaceURI());

    if (action != null) {
        MimeHeaders headers = message.getMimeHeaders();
        headers.addHeader("SOAPAction", service.getNamespaceURI() + "VerifyEmail");
    }

    // SOAP Body
    SOAPBody body = message.getSOAPBody();

    marshallObject(webServiceKey, request, body);

    message.saveChanges();
    return message;
}
 
開發者ID:AgileTestingFramework,項目名稱:atf-toolbox-java,代碼行數:40,代碼來源:WebServiceAutomationManager.java

示例2: getHeaders

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
 * Fetches MIME header information from HTTP request object.
 *
 * @param req HTTP request object
 * @return MimeHeaders that were extracted from the HTTP request
 */
public static MimeHeaders getHeaders(HttpServletRequest req) {
    Enumeration enumeration = req.getHeaderNames();
    MimeHeaders headers = new MimeHeaders();

    while (enumeration.hasMoreElements()) {
        String name = (String) enumeration.nextElement();
        String value = req.getHeader(name);

        StringTokenizer values = new StringTokenizer(value, ",");
        while (values.hasMoreTokens()) {
            headers.addHeader(name, values.nextToken().trim());
        }
    }
    return headers;
}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:22,代碼來源:AdapterUtils.java

示例3: create

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public static SOAPMessage create() throws SOAPException {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage message = messageFactory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("codecentric", "https://www.codecentric.de");

    SOAPBody envelopeBody = envelope.getBody();
    SOAPElement soapBodyElem = envelopeBody.addChildElement("location", "codecentric");

    SOAPElement place = soapBodyElem.addChildElement("place", "codecentric");
    place.addTextNode("Berlin");

    MimeHeaders headers = message.getMimeHeaders();
    headers.addHeader("SOAPAction", "https://www.codecentric.de/location");

    message.saveChanges();
    return message;
}
 
開發者ID:hill-daniel,項目名稱:soap-wrapper-lambda,代碼行數:21,代碼來源:ExampleSoapMessage.java

示例4: parseMessage

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
 * Creates a {@link SOAPMessage} object from the specified byte array.
 *
 * @param content     the raw message to parse the <code>SOAPMessage</code> from
 * @param contentType the HTTP Content-Type value that corresponds to the message. Required in order to determine if
 *                    the message should be parsed as a standard XML message or a multipart message with attachments.
 * @return the SOAPMessage object parsed from the given byte array
 * @throws SOAPException if the message is not a valid SOAP message
 */
public static SOAPMessage parseMessage(byte[] content, String contentType) throws SOAPException {
  ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
  try {
    MessageFactory messageFactory = MessageFactory.newInstance();
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader(HttpUtil.HEADER_CONTENT_TYPE, contentType);
    return messageFactory.createMessage(headers, inputStream);
  } catch (IOException e) {
    /* Should never happen - ByteArrayInputStream in this case is always readable and if its contents are invalid,
     * SOAPException will be thrown instead. */
    throw ExceptionUtil.toUnchecked(e);
  } finally {
    IOUtil.close(inputStream);
  }
}
 
開發者ID:e-gov,項目名稱:AJ,代碼行數:25,代碼來源:SoapUtil.java

示例5: testSoap12Request

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public void testSoap12Request(){
	try{
		System.out.println("---------------------------------------");
		System.out.println("test: " + getName());
		
		Dispatch<SOAPMessage> dispatch=getDispatch();
		String soapMessage = getSOAP12Message();
		System.out.println("soap message ="+soapMessage);
		MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
		MimeHeaders header = new MimeHeaders();
		header.addHeader("Content-Type", "application/soap+xml");
		SOAPMessage message = factory.createMessage(header, new ByteArrayInputStream(soapMessage.getBytes()));
		Object obj = dispatch.invoke(message);
		assertTrue(obj!=null && obj instanceof SOAPMessage);
		assertTrue(getVersionURI(message).equals(SOAP12_NS_URI));
		System.out.println("Provider endpoint was able to receive both SOAP 11 and SOAP 12 request");
	}catch(Exception e){
		System.out.println("Expecting that endpoint will be able to receive soap 12 and soap 11 request");
		System.out.println(e.getMessage());
		fail();
		
	}
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:SOAPBindingProviderTests.java

示例6: testSendReceive_ISO88591_EncodedSOAPMessage

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Validated @Test
public void testSendReceive_ISO88591_EncodedSOAPMessage() throws Exception {
	MimeHeaders mimeHeaders = new MimeHeaders();
    mimeHeaders.addHeader("Content-Type", "text/xml; charset=iso-8859-1");
    
    InputStream inputStream = TestUtils.getTestFile("soap-part-iso-8859-1.xml");
    SOAPMessage requestMessage = MessageFactory.newInstance().createMessage(mimeHeaders, inputStream);
    

    SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = sCon.call(requestMessage, getAddress());
    assertFalse(response.getAttachments().hasNext());
    assertEquals(0, response.countAttachments());

    printSOAPMessage(requestMessage);
    String responseStr = printSOAPMessage(response);
    assertEquals("This is some text.Here are some special chars : \u00F6\u00C6\u00DA\u00AE\u00A4",
                 response.getSOAPBody().getElementsByTagName("something").item(0).getTextContent());
    assertTrue(responseStr.indexOf("echo") != -1);
    sCon.close();
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:22,代碼來源:IntegrationTest.java

示例7: testCallMTOM

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Validated @Test
public void testCallMTOM() throws Exception {
    MessageFactory mf = MessageFactory.newInstance();
    
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type", TestUtils.MTOM_TEST_MESSAGE_CONTENT_TYPE);
    InputStream in = TestUtils.getTestFile(TestUtils.MTOM_TEST_MESSAGE_FILE);
    SOAPMessage request = mf.createMessage(headers, in);
    SOAPEnvelope envelope = request.getSOAPPart().getEnvelope();
    
    // Remove the headers since they have mustunderstand=1 
    envelope.getHeader().removeContents();
    // Change the name of the body content so that the request is routed to the echo service
    ((SOAPElement)envelope.getBody().getChildElements().next()).setElementQName(new QName("echo"));
    
    SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = sCon.call(request, getAddress());
    sCon.close();
    
    SOAPPart soapPart = response.getSOAPPart();
    SOAPElement textElement =
            (SOAPElement)soapPart.getEnvelope().getElementsByTagName("text").item(0);
    AttachmentPart ap = response.getAttachment((SOAPElement)textElement.getChildNodes().item(0));
    assertNotNull(ap);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:26,代碼來源:IntegrationTest.java

示例8: testNewInstane

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Validated @Test
public void testNewInstane() {
    try {
        MessageFactory mf = MessageFactory.newInstance();
        assertNotNull(mf);
        ByteArrayOutputStream baos1 = new ByteArrayOutputStream();

        SOAPMessage msg1 = mf.createMessage();
        msg1.writeTo(baos1);

        MimeHeaders headers = new MimeHeaders();
        headers.addHeader("Content-Type", "text/xml");

    } catch (Exception e) {
        fail("Exception: " + e);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:18,代碼來源:MessageFactoryTest.java

示例9: testParseSwAMessage

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Validated @Test
public void testParseSwAMessage() throws Exception {
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type",
            "multipart/related; " +
            "boundary=MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616; " +
            "type=\"text/xml\"; " +
            "start=\"<0.urn:uuid:E3F7CE4554928DA89B1231[email protected]>\"");
    InputStream in = TestUtils.getTestFile("SwAmessage.bin");
    SOAPMessage message = mf.createMessage(headers, in);
    SOAPPart soapPart = message.getSOAPPart();
    assertEquals("<0.urn:uuid:[email protected]>",
            soapPart.getContentId());
    Iterator attachments = message.getAttachments();
    assertTrue(attachments.hasNext());
    AttachmentPart ap = (AttachmentPart)attachments.next();
    assertEquals("<urn:uuid:E3F7CE4554928DA89B1231365678347>",
            ap.getContentId());
    assertFalse(attachments.hasNext());
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:MessageFactoryTest.java

示例10: createGetKlantenRequest

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
 * Constructed SOAP Request Message:
 *
 * <pre>
 * &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://surfnet.nl/webservices/"&gt;
 *   &lt;soapenv:Header/&gt;
 *   &lt;soapenv:Body&gt;
 *     &lt;web:getKlanten/&gt;
 *   &lt;/soapenv:Body&gt;
 * &lt;/soapenv:Envelope&gt;
 * </pre>
 *
 * @throws SOAPException
 */
public static SOAPMessage createGetKlantenRequest(String username, String password) throws SOAPException {
  MessageFactory messageFactory = MessageFactory.newInstance();
  SOAPMessage soapMessage = messageFactory.createMessage();
  SOAPPart soapPart = soapMessage.getSOAPPart();

  // SOAP Envelope
  SOAPEnvelope envelope = soapPart.getEnvelope();
  envelope.addNamespaceDeclaration(KIS_NAMESPACE_PREFIX, KIS_NAMESPACE_URI);

  // SOAP Body
  SOAPBody soapBody = envelope.getBody();
  soapBody.addChildElement("getKlanten", KIS_NAMESPACE_PREFIX);

  String authorization = Base64.getEncoder().encodeToString((username + ":" + password).getBytes(Charset.forName("UTF-8")));
  MimeHeaders headers = soapMessage.getMimeHeaders();
  headers.addHeader("Authorization", "Basic " + authorization);
  headers.addHeader("SOAPAction", KIS_NAMESPACE_URI + "IgetKlant/getKlanten");

  soapMessage.saveChanges();

  return soapMessage;
}
 
開發者ID:BandwidthOnDemand,項目名稱:bandwidth-on-demand,代碼行數:37,代碼來源:KisOnlineClient.java

示例11: unmarshal

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
 * Converts a SOAPMessage into a org.wc3.Document
 *
 * Using a custom message header you can which SOAP Version the message is in
 *
 * @param exchange
 * @param stream
 * @return
 * @throws Exception
 */
@Override
public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
    InputStream body = exchange.getContext().getTypeConverter().convertTo(InputStream.class,exchange.getIn().getBody());
    String soapVersion = exchange.getIn().getHeader(EbmsConstants.SOAP_VERSION, SOAPConstants.SOAP_1_2_PROTOCOL, String.class);
    MessageFactory messageFactory = MessageFactory.newInstance(soapVersion);
    MimeHeaders mimeHeaders = new MimeHeaders();
    mimeHeaders.addHeader(Exchange.CONTENT_TYPE, exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class));
    SOAPMessage message = messageFactory.createMessage(mimeHeaders, body);
    SOAPHeader soapHeader = message.getSOAPPart().getEnvelope().getHeader();

    if(message.countAttachments() > 0) {
        addAttachments(message, exchange);
    }

    return soapHeader.getOwnerDocument();
}
 
開發者ID:jentrata,項目名稱:jentrata,代碼行數:27,代碼來源:SoapMessageDataFormat.java

示例12: createBinaryStateRequest

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
private SOAPMessage createBinaryStateRequest() throws Exception {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage soapMessage = messageFactory.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    String serverURI = "urn:Belkin:service:basicevent:1";

    // SOAP Envelope
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("u", serverURI);

    SOAPBody soapBody = envelope.getBody();
    soapBody.addChildElement("GetBinaryState", "u");

    MimeHeaders headers = soapMessage.getMimeHeaders();
    headers.addHeader("SOAPAction", "\"urn:Belkin:service:basicevent:1#GetBinaryState\"");

    soapMessage.saveChanges();

    return soapMessage;
}
 
開發者ID:lawrie,項目名稱:HouseControl,代碼行數:22,代碼來源:WemoControl.java

示例13: createInsightParamsRequest

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
private SOAPMessage createInsightParamsRequest() throws Exception {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage soapMessage = messageFactory.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    String serverURI = "urn:Belkin:service:insight:1";

    // SOAP Envelope
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("u", serverURI);

    SOAPBody soapBody = envelope.getBody();
    soapBody.addChildElement("GetInsightParams", "u");

    MimeHeaders headers = soapMessage.getMimeHeaders();
    headers.addHeader("SOAPAction", "\"urn:Belkin:service:insight:1#GetInsightParams\"");

    soapMessage.saveChanges();

    return soapMessage;
}
 
開發者ID:lawrie,項目名稱:HouseControl,代碼行數:22,代碼來源:WemoControl.java

示例14: addSOAPMimeHeaders

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) {
    for(Map.Entry<String, List<String>> e : headers.entrySet()) {
        if (!e.getKey().equalsIgnoreCase("Content-Type")) {
            for(String value : e.getValue()) {
                mh.addHeader(e.getKey(), value);
            }
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:Message.java

示例15: copy

import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public static MimeHeaders copy(MimeHeaders headers) {
    MimeHeaders newHeaders = new MimeHeaders();
    Iterator eachHeader = headers.getAllHeaders();
    while (eachHeader.hasNext()) {
        MimeHeader currentHeader = (MimeHeader) eachHeader.next();

        newHeaders.addHeader(
            currentHeader.getName(),
            currentHeader.getValue());
    }
    return newHeaders;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:MimeHeadersUtil.java


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