當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPBody.getElementsByTagNameNS方法代碼示例

本文整理匯總了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;
}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:28,代碼來源:AbstractResponseDeserializer.java

示例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;
}
 
開發者ID:ddRPB,項目名稱:rpb,代碼行數:25,代碼來源:EventDefListAllHandler.java

示例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;
}
 
開發者ID:ddRPB,項目名稱:rpb,代碼行數:25,代碼來源:StudyListAllHandler.java

示例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);	
}
 
開發者ID:cecid,項目名稱:hermes,代碼行數:30,代碼來源:SOAPUtilities.java

示例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;
}
 
開發者ID:cecid,項目名稱:hermes,代碼行數:31,代碼來源:SOAPUtilities.java

示例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();	
}
 
開發者ID:cecid,項目名稱:hermes,代碼行數:31,代碼來源:SOAPUtilities.java

示例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();
			}

		}
 
開發者ID:D2Edev,項目名稱:onvifjava,代碼行數:30,代碼來源:CameraDiscovery.java


注:本文中的javax.xml.soap.SOAPBody.getElementsByTagNameNS方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。