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


Java SOAPBody类代码示例

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


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

示例1: createXPath

import javax.xml.soap.SOAPBody; //导入依赖的package包/类
/**
 * Constructs XPath query over the SOAP message
 * 
 * @param query XPath query
 * @param response SOAP message
 * @return XPath query
 * @throws SOAPException in case of SOAP issue
 * @throws JaxenException XPath problem
 */
public final XPath createXPath(final String query, final SOAPMessage response) throws SOAPException, JaxenException {

  /* Uses DOM to XPath mapping */
  final XPath xpath = new DOMXPath(query);

  /* Define a namespaces used in response */
  final SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
  final SOAPPart sp = response.getSOAPPart();
  final SOAPEnvelope env = sp.getEnvelope();
  final SOAPBody bdy = env.getBody();

  /* Add namespaces from SOAP envelope */
  addNamespaces(nsContext, env);

  /* Add namespaces of top body element */
  final Iterator<?> bodyElements = bdy.getChildElements();
  while (bodyElements.hasNext()) {
    SOAPElement element = (SOAPElement) bodyElements.next();
    addNamespaces(nsContext, element);
  }
  xpath.setNamespaceContext(nsContext);
  return xpath;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:33,代码来源:SOAPExecutor.java

示例2: createSOAPRequestMessage

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

示例3: createSimpleSOAPPart

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

示例4: deserializeSOAPFault

import javax.xml.soap.SOAPBody; //导入依赖的package包/类
/**
 * Tries to deserialize standard SOAP error message. If a standard error
 * message is found true is returned. Otherwise false is returned.
 *
 * @param response ServiceResponse that holds the SOAPMessage
 * @return true if and only if a standard SOAP fault is found; otherwise
 * false
 * @throws SOAPException if there's a SOAP error
 */
private boolean deserializeSOAPFault(final ServiceResponse response) throws SOAPException {
    LOGGER.debug("Deserialize SOAP fault.");
    Map<String, String> fault;
    SOAPBody body = response.getSoapMessage().getSOAPBody();
    NodeList list = body.getElementsByTagNameNS("*", "Fault");
    if (list.getLength() == 1) {
        fault = SOAPHelper.nodesToMap(list.item(0).getChildNodes(), true);
        String faultCode = fault.get("FAULTCODE");
        String faultString = fault.get("FAULTSTRING");
        String faultActor = fault.get("FAULTACTOR");
        Object detail = this.deserializeFaultDetail(SOAPHelper.getNode((Node) list.item(0), "detail"));
        response.setErrorMessage(new ErrorMessage(faultCode, faultString, faultActor, detail));
        LOGGER.info("SOAP fault was succesfully deserialized.");
        return true;
    }
    LOGGER.debug("SOAP fault was not found.");
    return false;
}
 
开发者ID:vrk-kpa,项目名称:xrd4j,代码行数:28,代码来源:AbstractResponseDeserializer.java

示例5: testSendReceiveMessageWithEmptyNSPrefix

import javax.xml.soap.SOAPBody; //导入依赖的package包/类
@Validated @Test
public void testSendReceiveMessageWithEmptyNSPrefix() throws Exception {
    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage request = mf.createMessage();

    SOAPPart sPart = request.getSOAPPart();
    SOAPEnvelope env = sPart.getEnvelope();
    SOAPBody body = env.getBody();

    //Namespace prefix is empty
    body.addBodyElement(new QName("http://fakeNamespace2.org","echo"))
    							.addTextNode("This is some text");

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

    String requestStr = printSOAPMessage(request);
    String responseStr = printSOAPMessage(response);
    assertTrue(responseStr.indexOf("echo") > -1);
    sCon.close();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:IntegrationTest.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: create

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

示例12: handleMessage

import javax.xml.soap.SOAPBody; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
	Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (!isRequest) { // only incoming messages
		try {
			SOAPMessage soapMsg = context.getMessage();
			SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
			SOAPBody soapBody = soapEnv.getBody();
			if (soapBody != null) {
				// Should have a SOAPBody and a listall response...
				NodeList nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_LIST_ALL_RESPONSE);
				if (nodeList.getLength() > 0) { // check for listAllResponse
												// tag first!
					nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_ELEMENT);
					recursiveRenamespace(nodeList); // renamespace...
					soapMsg.saveChanges();
				}
			}
		} catch (Exception e) {
			catchMessages(e);
		}
	}
	return true;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:25,代码来源:EventDefListAllHandler.java

示例13: handleMessage

import javax.xml.soap.SOAPBody; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
	Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (!isRequest) { // only incoming messages
		try {
			SOAPMessage soapMsg = context.getMessage();
			SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
			SOAPBody soapBody = soapEnv.getBody();
			if (soapBody != null) {
				// Should have a SOAPBody and a listall response...
				NodeList nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDY_LIST_ALL_RESPONSE);
				if (nodeList.getLength() > 0) { // check for listAllResponse
												// tag first!
					nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDIES_ELEMENT);
					recursiveRenamespace(nodeList); // renamespace...
					soapMsg.saveChanges();
				}
			}
		} catch (Exception e) {
			catchMessages(e);
		}
	}
	return true;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:25,代码来源:StudyListAllHandler.java

示例14: addFault

import javax.xml.soap.SOAPBody; //导入依赖的package包/类
/**
 * Adds a SOAP fault to the SOAP message of this response.
 * 
 * @param code the fault code.
 * @param actor the fault actor.
 * @param desc the fault description.
 * @return the SOAP fault which has been added to the SOAP message. null if
 *         there is no SOAP message in this response or the fault has
 *         already been added.
 * @throws SOAPException a SOAP error occurred when adding the the fault.
 */
public SOAPFault addFault(String code, String actor, String desc)
        throws SOAPException {
    SOAPMessage msg = getMessage();
    if (msg != null) {
        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
        SOAPBody body = env.getBody();
        if (body != null && !body.hasFault()) {
            SOAPFault fault = body.addFault();
            if (code != null) {
                fault.setFaultCode(env.getElementName().getPrefix() + ":"
                        + code);
            }
            if (actor != null) {
                fault.setFaultActor(actor);
            }
            if (desc != null) {
                fault.setFaultString(desc);
            }
            return fault;
        }
    }
    return null;
}
 
开发者ID:cecid,项目名称:hermes,代码行数:35,代码来源:SOAPResponse.java

示例15: 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


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