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


Java SOAPBody.addChildElement方法代码示例

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


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

示例1: testAddElementToNullNsQName

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Test
public void testAddElementToNullNsQName() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName(null, "global-child"));
    childGlobalNS.addNamespaceDeclaration("", "");
    SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SaajEmptyNamespaceTest.java

示例2: testAddElementToGlobalNs

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Test
public void testAddElementToGlobalNs() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", "");
    childGlobalNS.addNamespaceDeclaration("", "");
    SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SaajEmptyNamespaceTest.java

示例3: testAddElementToNullNs

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Test
public void testAddElementToNullNs() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null);
    childGlobalNS.addNamespaceDeclaration("", null);
    SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
    Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SaajEmptyNamespaceTest.java

示例4: testAddElementToGlobalNsQName

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Test
public void testAddElementToGlobalNsQName() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName("", "global-child"));
    childGlobalNS.addNamespaceDeclaration("", "");
    SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(),TEST_NS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SaajEmptyNamespaceTest.java

示例5: OSCARFAXSOAPMessage

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
public OSCARFAXSOAPMessage(MessageFactory mf)
    throws SOAPException
{
    this.mf = mf;
    msg = mf.createMessage();
    soapPart = msg.getSOAPPart();
    envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPElement ele = body.addChildElement(envelope.createName("OscarFax", "jaxm", "http://oscarhome.org/jaxm/oscarFax/"));
    sendingProvider = ele.addChildElement("sendingProvider");
    locationId = ele.addChildElement("locationId");
    identifier = ele.addChildElement("identifier");
    faxType = ele.addChildElement("faxType");
    coverSheet = ele.addChildElement("coverSheet");
    from = ele.addChildElement("from");
    comments = ele.addChildElement("comments");
    sendersFax = ele.addChildElement("sendersFax");
    sendersPhone = ele.addChildElement("sendersPhone");
    dateOfSending = ele.addChildElement("dateOfSending");
    recipient = ele.addChildElement("recipient");
    recipientFaxNumber = ele.addChildElement("recipientFaxNumber");
    payLoad = ele.addChildElement(envelope.createName("OscarFaxPayLoad", "jaxm", "http://oscarhome.org/jaxm/oscarFax/"));
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:24,代码来源:OSCARFAXSOAPMessage.java

示例6: addRequestElementText

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
 * Add SOAP element to body with name and value.
 * 
 * @param tagName	The tag name of element to be retrieved.
 * @param tagValue	The value of the element to be added.
 * @param nsPrefix	The namespace Prefix
 * @param nsURI		The namespace URI.
 * @return			true if the creation and addition is successfully.
 * @throws SOAPException
 */
public boolean addRequestElementText(String tagName
									,String tagValue
									,String nsPrefix
									,String nsURI) throws SOAPException{
	if (this.request == null)
		return false;		
				
	SOAPBody soapBody = request.getSOAPPart().getEnvelope().getBody();
	
	if (soapBody == null)
		return false;
	
	// 	Create new element.
	SOAPElement newElement = SOAPUtilities.createElement(tagName, tagValue, nsPrefix, nsURI);
	soapBody.addChildElement(newElement);
	return true;
}
 
开发者ID:cecid,项目名称:hermes,代码行数:28,代码来源:SOAPSender.java

示例7: invoke

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
 * Very simple operation.
 * If there are no attachments, an exception is thrown.
 * Otherwise the message is echoed.
 */
public SOAPMessage invoke(SOAPMessage soapMessage)  {
    System.out.println(">> SoapMessageCheckMTOMProvider: Request received.");


    int numAttachments = soapMessage.countAttachments();
    if (numAttachments == 0) {
        System.out.println(">> SoapMessageCheckMTOMProvider: No Attachments.");
        throw new WebServiceException("No Attachments are detected");
    }
    SOAPMessage response = null;
    try {
        MessageFactory factory = MessageFactory.newInstance();
        response = factory.createMessage();
        SOAPPart soapPart = response.getSOAPPart();
        SOAPBody soapBody = soapPart.getEnvelope().getBody();
        soapBody.addChildElement((SOAPBodyElement) 
                                 soapMessage.
                                 getSOAPBody().getChildElements().next());
        response.addAttachmentPart((AttachmentPart) soapMessage.getAttachments().next());
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
    System.out.println(">> SoapMessageCheckMTOMProvider: Returning.");
    return response;  // echo back the same message
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:31,代码来源:SoapMessageCheckMTOMProvider.java

示例8: testNonCommentText

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testNonCommentText() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPElement se = body.addChildElement("Child");
    se.addTextNode("This is text");
    Iterator iterator = se.getChildElements();
    Object o = null;
    while (iterator.hasNext()) {
        o = iterator.next();
        if (o instanceof Text) {
            break;
        }
    }
    assertTrue(o instanceof Text);
    Text t = (Text)o;
    assertTrue(!t.isComment());
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:SOAPEnvelopeTest.java

示例9: testGetChildElements2

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testGetChildElements2() throws Exception {
    MessageFactory fact = MessageFactory.newInstance();
    SOAPMessage message = fact.createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
    SOAPBody soapBody = soapEnvelope.getBody();

    Name name = soapEnvelope.createName("MyChild1");
    SOAPElement se = soapBody.addChildElement(name);
    Iterator childElementsCount = soapBody.getChildElements();
    Iterator childElements = soapBody.getChildElements();

    int childCount = 0;
    while (childElementsCount.hasNext()) {
        Node node = (Node)childElementsCount.next();
        childCount++;
    }
    assertEquals(childCount, 1);
    SOAPElement se2 = (SOAPElement)childElements.next();
    if (!se.equals(se2)) {
        fail();
    } else {
        System.out.println("SOAPElement se = se2 (expected)");
    }

    Name n = se.getElementName();
    assertEquals(n, name);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:30,代码来源:SOAPElementTest.java

示例10: testGetChildElements3

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testGetChildElements3() throws Exception {
    MessageFactory fact = MessageFactory.newInstance();
    SOAPMessage message = fact.createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
    SOAPBody soapBody = soapEnvelope.getBody();

    //Name name = soapEnvelope.createName("MyChild1");
    QName name = new QName("MyChild1");
    SOAPElement se = soapBody.addChildElement(name);
    Iterator childElementsCount = soapBody.getChildElements();
    Iterator childElements = soapBody.getChildElements();

    int childCount = 0;
    while (childElementsCount.hasNext()) {
        Node node = (Node)childElementsCount.next();
        childCount++;
    }
    assertEquals(childCount, 1);
    SOAPElement se2 = (SOAPElement)childElements.next();
    assertEquals(se, se2);

    QName n = se.getElementQName();
    assertEquals(n, name);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:SOAPElementTest.java

示例11: testSetElementQName

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testSetElementQName() throws Exception {
    MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage message = factory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();

    QName qname1 = new QName("http://fooURI.com", "fooElement", "foo");
    QName qname2 = new QName("http://foo2URI.com", "fooElement2", "foo2");
    SOAPElement se = body.addChildElement(qname1);
    QName qname = se.getElementQName();
    se = se.setElementQName(qname2);
    qname = se.getElementQName();

    if (!qname.getNamespaceURI().equals(qname2.getNamespaceURI()) ||
            !qname.getLocalPart().equals(qname2.getLocalPart()) ||
            !qname.getPrefix().equals(qname2.getPrefix())) {
        System.out.println("setElementQName() did not reset " +
                "element qname\nexpected: <URI=" + qname2.getNamespaceURI() +
                ", prefix=" + qname2.getPrefix() + ", localpart=" + qname2.getLocalPart() +
                ">\ngot:      <URI=" + qname.getNamespaceURI() + ", prefix=" +
                qname.getPrefix() +
                ", localpart=" + qname.getLocalPart() + ">");
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:SOAPElementTest.java

示例12: testAddSource2

import javax.xml.soap.SOAPBody; //导入方法依赖的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

示例13: createProbeXML

import javax.xml.soap.SOAPBody; //导入方法依赖的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

示例14: testAddElementToNullNsNoDeclarations

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Test
public void testAddElementToNullNsNoDeclarations() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null);
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:SaajEmptyNamespaceTest.java

示例15: testAddElementToGlobalNsNoDeclarations

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Test
public void testAddElementToGlobalNsNoDeclarations() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", "");
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:SaajEmptyNamespaceTest.java


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