本文整理匯總了Java中javax.xml.soap.SOAPBody.getFirstChild方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPBody.getFirstChild方法的具體用法?Java SOAPBody.getFirstChild怎麽用?Java SOAPBody.getFirstChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.SOAPBody
的用法示例。
在下文中一共展示了SOAPBody.getFirstChild方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleMessage
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
public boolean handleMessage(SOAPMessageContext messagecontext) {
Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
try {
SOAPMessage soapMessage = messagecontext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
Node firstChild = soapBody.getFirstChild();
String timeStamp = getTimestamp();
String signature = getSignature(firstChild.getLocalName(), timeStamp, secretBytes);
appendTextElement(firstChild, "Signature", signature);
appendTextElement(firstChild, "Timestamp", timeStamp);
} catch(SOAPException se) {
throw new RuntimeException("SOAPException was thrown.", se);
}
}
return true;
}
示例2: invokeSoapMessage
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
public SOAPMessage invokeSoapMessage(SOAPMessage request) {
SOAPMessage response = null;
try {
SOAPBody body = request.getSOAPBody();
Node n = body.getFirstChild();
while (n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getNextSibling();
}
if (n.getLocalName().equals(sayHi.getLocalPart())) {
response = sayHiResponse;
} else if (n.getLocalName().equals(greetMe.getLocalPart())) {
response = greetMeResponse;
}
} catch (Exception ex) {
ex.printStackTrace();
}
return response;
}
示例3: getBodyElementQNameFromDispatchMessage
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
/**
* Given a JAXWS Message Context which contains an outbound service-requester Message for a Dispatch client,
* determine the QName of the first body element contained in that message.
*
* @param requestMessageCtx requestMessageCtx JAXWS Message Context containing the outbound Dispatch message
* @return the QName of the first body element contained in the outbound Dispatch message, or null if it
* can not be determined.
*/
QName getBodyElementQNameFromDispatchMessage(MessageContext requestMessageCtx) {
QName bodyElementQName = null;
Message dispatchMessage = requestMessageCtx.getMessage();
SOAPMessage soapMessage = dispatchMessage.getAsSOAPMessage();
try {
SOAPBody soapBody = soapMessage.getSOAPBody();
Node firstElement = soapBody.getFirstChild();
// A Doc/Lit/Bare message may not have a firsElement. The soap:Body element may be empty if there
// are no arguments to the operation.
if (firstElement != null) {
String ns = firstElement.getNamespaceURI();
String lp= firstElement.getLocalName();
// A Doc/Lit/Bare message may not have a localPart on the element. That can happen if the first element
// is the argument value and there is no wrapper element surrounding it.
if (lp != null) {
bodyElementQName = new QName(ns, lp);
}
}
} catch (SOAPException e) {
if (log.isDebugEnabled()) {
log.debug("Unabled to get the first body element from the outbound dispatch message", e);
}
}
return bodyElementQName;
}
示例4: assertResponseXML
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
/**
* Common assertion checking of the response
* @param msg
* @param expectedText
* @return SOAPElement representing the data element
*/
private SOAPElement assertResponseXML(SOAPMessage msg, String expectedText) throws Exception {
assertTrue(msg != null);
SOAPBody body = msg.getSOAPBody();
assertTrue(body != null);
Node invokeElement = (Node) body.getFirstChild();
assertTrue(invokeElement instanceof SOAPElement);
assertEquals(SoapMessageProvider.RESPONSE_NAME, invokeElement.getLocalName());
Node dataElement = (Node) invokeElement.getFirstChild();
assertTrue(dataElement instanceof SOAPElement);
assertEquals(SoapMessageProvider.RESPONSE_DATA_NAME, dataElement.getLocalName());
// TODO AXIS2 SAAJ should (but does not) support the getTextContent();
// String text = dataElement.getTextContent();
String text = dataElement.getValue();
assertEquals("Found ("+ text + ") but expected (" + expectedText + ")", expectedText, text);
return (SOAPElement) dataElement;
}
示例5: assertRequestXML
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
/**
* Common assertion checking of the request
* @param msg
* @return SOAPElement representing the data element
*/
private SOAPElement assertRequestXML(SOAPMessage msg) throws Exception {
assertTrue(msg != null);
SOAPBody body = msg.getSOAPBody();
assertTrue(body != null);
Node invokeElement = (Node) body.getFirstChild();
assertTrue(invokeElement instanceof SOAPElement);
assertTrue(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
Node discElement = (Node) invokeElement.getFirstChild();
assertTrue(discElement instanceof SOAPElement);
assertTrue(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
String text = discElement.getValue();
assertTrue(text != null);
assertTrue(text.length() > 0);
System.out.println("Request Message Type is:" + text);
return (SOAPElement) discElement;
}
示例6: assertResponseXML
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
/**
* Common assertion checking of the response
* @param msg
* @param expectedText
* @return SOAPElement representing the data element
*/
private SOAPElement assertResponseXML(SOAPMessage msg, String expectedText) throws Exception {
assertTrue(msg != null);
SOAPBody body = msg.getSOAPBody();
assertTrue(body != null);
Node invokeElement = (Node) body.getFirstChild();
assertTrue(invokeElement instanceof SOAPElement);
assertEquals(SoapMessageProvider.RESPONSE_NAME, invokeElement.getLocalName());
Node dataElement = (Node) invokeElement.getFirstChild();
assertTrue(dataElement instanceof SOAPElement);
assertEquals(SoapMessageProvider.RESPONSE_DATA_NAME, dataElement.getLocalName());
// TODO AXIS2 SAAJ should (but does not) support the getTextContent();
// String text = dataElement.getTextContent();
String text = dataElement.getValue();
assertEquals("Found ("+ text + ") but expected (" + expectedText + ")", expectedText, text);
return (SOAPElement) dataElement;
}
示例7: assertRequestXML
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
/**
* Common assertion checking of the request
* @param msg
* @return SOAPElement representing the data element
*/
private SOAPElement assertRequestXML(SOAPMessage msg) throws Exception {
assertTrue(msg != null);
SOAPBody body = msg.getSOAPBody();
assertTrue(body != null);
Node invokeElement = (Node) body.getFirstChild();
assertTrue(invokeElement instanceof SOAPElement);
assertTrue(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
Node discElement = (Node) invokeElement.getFirstChild();
assertTrue(discElement instanceof SOAPElement);
assertTrue(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
String text = discElement.getValue();
assertTrue(text != null);
assertTrue(text.length() > 0);
TestLogger.logger.debug("Request Message Type is:" + text);
return (SOAPElement) discElement;
}
示例8: assertResponseXML
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
private SOAPElement assertResponseXML(SOAPMessage msg, String expectedText) throws Exception {
assertTrue(msg != null);
SOAPBody body = msg.getSOAPBody();
assertTrue(body != null);
Node invokeElement = (Node) body.getFirstChild();
assertTrue(invokeElement instanceof SOAPElement);
assertEquals("outMessage", invokeElement.getLocalName());
String text = invokeElement.getValue();
System.out.println("Received: " + text);
assertEquals("Found ("+ text + ") but expected (" + expectedText + ")", expectedText, text);
return (SOAPElement) invokeElement;
}
示例9: testComment
import javax.xml.soap.SOAPBody; //導入方法依賴的package包/類
@Validated @Test
public void testComment() throws SOAPException, IOException {
String xmlString = "<?xml version='1.0' encoding='utf-8'?> " +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soapenv:Header></soapenv:Header>" +
"<soapenv:Body>" +
"<Node:abc xmlns:Node=\"http://www.simpletest.org\">" +
"This is some text" +
"<!--This is comment-->This is other text" +
"<!--This is another comment-->This is some other text" +
"</Node:abc>" +
"</soapenv:Body>" +
"</soapenv:Envelope>";
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message =
mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
SOAPBody body = message.getSOAPBody();
Node bodyElement = body.getFirstChild();
NodeList textNodes = bodyElement.getChildNodes();
assertEquals(5, textNodes.getLength());
for (int i = 0; i < textNodes.getLength(); i++) {
Node node = textNodes.item(i);
boolean isComment;
isComment = ((Text)node).isComment();
if (i == 1 || i == 3) {
assertEquals(true, isComment);
assertTrue(node instanceof Comment);
} else {
assertEquals(false, isComment);
assertFalse(node instanceof Comment);
}
}
}