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


Java SOAPPart.setContent方法代碼示例

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


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

示例1: substitute

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * Substitutes all occurences of some given string inside the given {@link WebServiceMessage} with another value.
 *
 * @param message message to substitute in
 * @param from the value to substitute
 * @param to the value to substitute with
 * @throws TransformerException
 */
public static void substitute(WebServiceMessage message, String from, String to) throws TransformerException {
  SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
  SOAPPart soapPart = saajSoapMessage.getSaajMessage().getSOAPPart();

  Source source = new DOMSource(soapPart);
  StringResult stringResult = new StringResult();

  TransformerFactory.newInstance().newTransformer().transform(source, stringResult);

  String content = stringResult.toString().replaceAll(from, to);

  try {
    soapPart.setContent(new StringSource(content));
  } catch (SOAPException e) {
    throw new TransformerException(e);
  }
}
 
開發者ID:nortal,項目名稱:j-road,代碼行數:26,代碼來源:SOAPUtil.java

示例2: testAddSource2

import javax.xml.soap.SOAPPart; //導入方法依賴的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

示例3: testAddSource3

import javax.xml.soap.SOAPPart; //導入方法依賴的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

示例4: _testInputEncoding

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public void _testInputEncoding() throws Exception {
        DOMSource domSource;
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document document = builder.parse(new File(System.getProperty("basedir", ".") +
                "/test-resources" + File.separator + "soap-part.xml"));
        domSource = new DOMSource(document);

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

        // Get the SOAP part and set its content to domSource
        SOAPPart soapPart = message.getSOAPPart();
        soapPart.setContent(domSource);
        message.saveChanges();

        SOAPPart sp = message.getSOAPPart();

//            String inputEncoding = sp.getInputEncoding();
//            assertNotNull(inputEncoding);
    }
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SOAPPartTest.java

示例5: readFrom

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public SOAPMessage readFrom(Class<SOAPMessage> soapEnvelopeClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        StreamSource messageSource = new StreamSource(inputStream);
        SOAPMessage message = messageFactory.createMessage();
        SOAPPart soapPart = message.getSOAPPart();
        soapPart.setContent(messageSource);
        return message;
    } catch (SOAPException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:fod-dev,項目名稱:FoDBugTrackerUtility,代碼行數:14,代碼來源:ArcherBasicRestConnection.java

示例6: modifyMessage

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
protected SOAPMessage modifyMessage( String soapProtocol, InputStream inputStream ) throws SOAPException
{
    MessageFactory messageFactory = MessageFactory.newInstance( soapProtocol );
    StreamSource messageSource = new StreamSource( inputStream );
    SOAPMessage message = messageFactory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    soapPart.setContent( messageSource );
    message.saveChanges();
    return message;
}
 
開發者ID:factoryfx,項目名稱:factoryfx,代碼行數:11,代碼來源:AbstractSoapProvider.java

示例7: toMessage

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
private static final SOAPMessage toMessage(final Document jdomDocument)
        throws IOException, SOAPException {
    final SOAPMessage message = MessageFactory.newInstance()
            .createMessage();
    final SOAPPart sp = message.getSOAPPart();
    sp.setContent(new DOMSource(jdomDocument.getFirstChild()));

    return message;
}
 
開發者ID:Bernardo-MG,項目名稱:spring-ws-security-soap-example,代碼行數:10,代碼來源:SecureSoapMessages.java

示例8: testAddSource

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
@Validated @Test
public void testAddSource() throws Exception {
    /*
    FileReader testFile = new FileReader(new File(System.getProperty("basedir",".")+"/test-resources" + File.separator + "soap-part.xml"));
    StAXOMBuilder stAXOMBuilder =
            OMXMLBuilderFactory.createStAXOMBuilder(
                    OMAbstractFactory.getSOAP11Factory(),
                    XMLInputFactory.newInstance().createXMLStreamReader(
                            testFile));
    */

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder builder = dbf.newDocumentBuilder();
    Document document = builder.parse(TestUtils.getTestFileURI("soap-part.xml"));
    DOMSource domSource = new DOMSource(document);

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

    // Get the SOAP part and set its content to domSource
    SOAPPart soapPart = message.getSOAPPart();
    soapPart.setContent(domSource);
    message.saveChanges();

    SOAPHeader header = message.getSOAPHeader();
    if (header != null) {
        Iterator iter1 = header.getChildElements();
        getContents(iter1, "");
    }

    SOAPBody body = message.getSOAPBody();
    Iterator iter2 = body.getChildElements();
    getContents(iter2, "");
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:35,代碼來源:SOAPPartTest.java

示例9: getSOAPMessageFromStream

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public SOAPMessage getSOAPMessageFromStream(InputStream inputStream) throws Exception {
    SOAPMessage message = factory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    soapPart.setContent(getDOMSourceFromStream(inputStream));
    return message;
}
 
開發者ID:OlegNyr,項目名稱:GisGMP,代碼行數:7,代碼來源:SOAPUtility.java


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