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


Java SOAPBody.addAttribute方法代码示例

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


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

示例1: testRemoveAttribute2

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

    QName name = new QName("MyAttr1");
    String value = "MyValue1";
    body.addAttribute(name, value);
    boolean b = body.removeAttribute(name);
    assertTrue(b);

    b = body.removeAttribute(name);
    if (b) {
        //removeAttribute() did not return false
        fail();
    }
    //getAttributeValue should return null
    assertNull(body.getAttributeValue(name));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:21,代码来源:SOAPElementTest.java

示例2: testRemoveAttributeName

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

    Name name = envelope.createName("MyAttr1");
    String value = "MyValue1";
    body.addAttribute(name, value);
    boolean b = body.removeAttribute(name);
    assertTrue(b);

    b = body.removeAttribute(name);
    assertTrue(!b);

    String s = body.getAttributeValue(name);
    assertNull(s);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:SOAPElementTest.java

示例3: _testRemoveAttributeQName

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
public void _testRemoveAttributeQName() throws Exception {
    SOAPMessage msg =
            MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
    SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
    SOAPBody body = envelope.getBody();

    QName name = new QName("MyAttr1");
    String value = "MyValue1";
    body.addAttribute(name, value);
    boolean b = body.removeAttribute(name);
    assertTrue(b);
    b = body.removeAttribute(name);
    assertTrue(!b);

    assertNull(body.getAttributeValue(name));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:SOAPElementTest.java

示例4: testAttributes

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testAttributes() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPBody body = envelope.getBody();

    Name name1 = envelope.createName("MyAttr1");
    String value1 = "MyValue1";

    Name name2 = envelope.createName("MyAttr2");
    String value2 = "MyValue2";

    Name name3 = envelope.createName("MyAttr3");
    String value3 = "MyValue3";

    body.addAttribute(name1, value1);
    body.addAttribute(name2, value2);
    body.addAttribute(name3, value3);

    Iterator iterator = body.getAllAttributes();
    assertTrue(getIteratorCount(iterator) == 3);
    iterator = body.getAllAttributes();

    boolean foundName1 = false;
    boolean foundName2 = false;
    boolean foundName3 = false;
    while (iterator.hasNext()) {
        Name name = (Name)iterator.next();
        if (name.equals(name1)) {
            foundName1 = true;
            assertEquals(value1, body.getAttributeValue(name));
        } else if (name.equals(name2)) {
            foundName2 = true;
            assertEquals(value2, body.getAttributeValue(name));
        } else if (name.equals(name3)) {
            foundName3 = true;
            assertEquals(value3, body.getAttributeValue(name));
        }
    }
    assertTrue(foundName1 && foundName2 && foundName3);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:41,代码来源:SOAPEnvelopeTest.java

示例5: testAttributes2

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testAttributes2() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPBody body = envelope.getBody();

    Name name1 = envelope.createName("MyAttr1", "att", "http://test.com/Attr");
    String value1 = "MyValue1";

    Name name2 = envelope.createName("MyAttr2");
    String value2 = "MyValue2";

    Name name3 = envelope.createName("MyAttr3");
    String value3 = "MyValue3";

    body.addAttribute(name1, value1);
    body.addAttribute(name2, value2);
    body.addAttribute(name3, value3);

    Iterator iterator = body.getAllAttributes();
    assertTrue(getIteratorCount(iterator) == 3);
    iterator = body.getAllAttributes();

    boolean foundName1 = false;
    boolean foundName2 = false;
    boolean foundName3 = false;
    while (iterator.hasNext()) {
        Name name = (Name)iterator.next();
        if (name.equals(name1)) {
            foundName1 = true;
            assertEquals(value1, body.getAttributeValue(name));
        } else if (name.equals(name2)) {
            foundName2 = true;
            assertEquals(value2, body.getAttributeValue(name));
        } else if (name.equals(name3)) {
            foundName3 = true;
            assertEquals(value3, body.getAttributeValue(name));
        }
    }
    assertTrue(foundName1 && foundName2 && foundName3);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:41,代码来源:SOAPEnvelopeTest.java

示例6: testAttributes3

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testAttributes3() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPBody body = envelope.getBody();

    Name name1 = envelope.createName("MyAttr1", "att", "http://test.com/Attr");
    String value1 = "MyValue1";

    Name name2 = envelope.createName("MyAttr2", "att", "http://test.com/Attr");
    String value2 = "MyValue2";

    Name name3 = envelope.createName("MyAttr3", "att", "http://test.com/Attr");
    String value3 = "MyValue3";

    body.addAttribute(name1, value1);
    body.addAttribute(name2, value2);
    body.addAttribute(name3, value3);

    Iterator iterator = body.getAllAttributes();
    assertTrue(getIteratorCount(iterator) == 3);
    iterator = body.getAllAttributes();

    boolean foundName1 = false;
    boolean foundName2 = false;
    boolean foundName3 = false;
    while (iterator.hasNext()) {
        Name name = (Name)iterator.next();
        if (name.equals(name1)) {
            foundName1 = true;
            assertEquals(value1, body.getAttributeValue(name));
        } else if (name.equals(name2)) {
            foundName2 = true;
            assertEquals(value2, body.getAttributeValue(name));
        } else if (name.equals(name3)) {
            foundName3 = true;
            assertEquals(value3, body.getAttributeValue(name));
        }
    }
    assertTrue(foundName1 && foundName2 && foundName3);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:41,代码来源:SOAPEnvelopeTest.java

示例7: testRemoveAttribute

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testRemoveAttribute() throws Exception {
    SOAPMessage msg = MessageFactory.newInstance().createMessage();
    SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
    SOAPBody body = envelope.getBody();
    Name name = envelope.createName("MyAttr1");
    String value = "MyValue1";
    body.addAttribute(name, value);
    boolean b = body.removeAttribute(name);
    assertTrue("removeAttribute() did not return true", b);
    b = body.removeAttribute(name);
    assertFalse("removeAttribute() did not return false", b);
    assertNull(body.getAttributeValue(name));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:15,代码来源:SOAPElementTest.java

示例8: testAddAttribute

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testAddAttribute() {
    try {
        MessageFactory fact = MessageFactory.newInstance();
        SOAPMessage message = fact.createMessage();
        SOAPBody soapBody = message.getSOAPBody();
        QName qname = new QName("http://test.apache.org/", "Child1", "ch");
        String value = "MyValue1";
        soapBody.addAttribute(qname, value);
        message.saveChanges();

    } catch (Exception e) {
        fail("Unexpected Exception : " + e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:16,代码来源:SOAPBodyTest.java

示例9: testAddAttribute2

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testAddAttribute2() {
    try {
        MessageFactory fact = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SOAPMessage message = fact.createMessage();
        SOAPBody soapBody = message.getSOAPBody();
        QName qname = new QName("http://test.apache.org/", "Child1", "ch");
        String value = "MyValue1";
        soapBody.addAttribute(qname, value);
        message.saveChanges();
    } catch (Exception e) {
        fail("Unexpected Exception : " + e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:15,代码来源:SOAPBodyTest.java


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