本文整理汇总了Java中javax.xml.soap.SOAPBody.getElementsByTagNameNS方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPBody.getElementsByTagNameNS方法的具体用法?Java SOAPBody.getElementsByTagNameNS怎么用?Java SOAPBody.getElementsByTagNameNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPBody
的用法示例。
在下文中一共展示了SOAPBody.getElementsByTagNameNS方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: getElement
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
* Get a SOAP Element from the SOAPMessage (SOAPbody inside).
*
* @param message The SOAP message to be searched with.
* @param tagname The tag name of element to be retrieved.
* @param nsURI The namespace URI.
* @param whichOne The nth child element to be returned.
*
* @return The element in the tagname specified.
*/
public static SOAPElement getElement(SOAPMessage message
,String tagname
,String nsURI
,int whichOne) throws SOAPException{
if (message == null) // return null if the message is null.
return null;
// Get the soap body from the response.
SOAPBody elementBody = message.getSOAPPart().getEnvelope().getBody();
if (elementBody == null) // return null if the body is null.
return null;
// Find all the child with the childname.
NodeList nl = elementBody.getElementsByTagNameNS(nsURI, tagname);
if (nl.getLength() <= whichOne){
return null;
}
return (SOAPElement) nl.item(whichOne);
}
示例5: getElementList
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
* Get a SOAP Element list from the SOAPMessage (SOAPbody inside).
*
* @param message The SOAP message to be searched with.
* @param tagname The tag name of element to be retrieved.
* @param nsURI The namespace URI.
* @return list of SOAP element
* @throws SOAPException
*/
public static List getElementList(SOAPMessage message
,String tagname
,String nsURI) throws SOAPException{
if (message == null) // return null if the message is null.
return null;
// Get the soap body from the response.
SOAPBody elementBody = message.getSOAPPart().getEnvelope().getBody();
if (elementBody == null) // return null if the body is null.
return null;
NodeList nl = elementBody.getElementsByTagNameNS(nsURI, tagname);
List list = new Vector();
for (int i = 0; i < nl.getLength(); i++){
if (nl.item(i) instanceof SOAPElement){
list.add((SOAPElement)nl.item(i));
}
}
return list;
}
示例6: countElement
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
* Count how many element with <code>tagname</code> and <code>nsURI</code>
* is in SOAPMessage <code>message</code>.
*
* @param message
* The SOAP message
* @param tagname
* The name of the tag to be counted.
* @param nsURI
* The namespace URI of the tag.
* @return
* The number of element in the SOAP message.
* @throws SOAPException
*
*/
public static int countElement(SOAPMessage message
,String tagname
,String nsURI) throws SOAPException{
if (message == null) // return null if the message is null.
throw new NullPointerException("SOAP Message is null.");
// Get the soap body from the response.
SOAPBody elementBody = message.getSOAPPart().getEnvelope().getBody();
if (elementBody == null) // return null if the body is null.
throw new NullPointerException("SOAP Body is null.");
// Find all the child with the childname.
NodeList nl = elementBody.getElementsByTagNameNS(nsURI, tagname);
return nl.getLength();
}
示例7: parseSoapResponseForUrls
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
private void parseSoapResponseForUrls(byte[] data) {
// System.out.println(new String(data));
try {
MessageFactory factory= MessageFactory.newInstance(WS_DISCOVERY_SOAP_VERSION);
final MimeHeaders headers = new MimeHeaders();
// headers.addHeader("Content-type", WS_DISCOVERY_CONTENT_TYPE);
SOAPMessage message = factory.createMessage(headers, new ByteArrayInputStream(data));
SOAPPart part=message.getSOAPPart();
SOAPEnvelope env=part.getEnvelope();
SOAPBody body=message.getSOAPBody();
NodeList list=body.getElementsByTagNameNS("http://schemas.xmlsoap.org/ws/2005/04/discovery", "XAddrs");
int items=list.getLength();
if(items<1)return;
for (int i = 0; i < items; i++) {
Node n=list.item(i);
String raw=n.getTextContent();
//may contain several
String []addrArray=raw.split(" ");
for (String string : addrArray) {
URL url=new URL(string);
discovered.add(url);
}
}
} catch (Exception e) {
System.out.println("Parse failed");
e.printStackTrace();
}
}