本文整理了Java中javax.xml.soap.SOAPHeader.getElementsByTagNameNS()
方法的一些代码示例,展示了SOAPHeader.getElementsByTagNameNS()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SOAPHeader.getElementsByTagNameNS()
方法的具体详情如下:
包路径:javax.xml.soap.SOAPHeader
类名称:SOAPHeader
方法名:getElementsByTagNameNS
暂无
代码示例来源:origin: ChargeTimeEU/Java-OCA-OCPP
private String getElementValue(String tagName) {
String value = null;
NodeList elements = soapHeader.getElementsByTagNameNS("*", tagName);
if (elements.getLength() > 0)
value = elements.item(0).getChildNodes().item(0).getNodeValue();
return value;
}
}
代码示例来源:origin: org.n52.arctic-sea/shetland
/**
* Get text content from element by namespace.
*
* @param soapHeader
* SOAPHeader element
* @param namespaceURI
* Namespace URI
* @param localName
* local name
* @return Text content.
*/
public static String getContentFromElement(SOAPHeader soapHeader, String namespaceURI, String localName) {
String elementContent = null;
NodeList nodes = soapHeader.getElementsByTagNameNS(namespaceURI, localName);
for (int i = 0; i < nodes.getLength(); i++) {
elementContent = nodes.item(i).getTextContent();
}
return elementContent;
}
代码示例来源:origin: org.n52.shetland/shetland
/**
* Get text content from element by namespace.
*
* @param soapHeader
* SOAPHeader element
* @param namespaceURI
* Namespace URI
* @param localName
* local name
* @return Text content.
*/
public static String getContentFromElement(SOAPHeader soapHeader, String namespaceURI, String localName) {
String elementContent = null;
NodeList nodes = soapHeader.getElementsByTagNameNS(namespaceURI, localName);
for (int i = 0; i < nodes.getLength(); i++) {
elementContent = nodes.item(i).getTextContent();
}
return elementContent;
}
代码示例来源:origin: org.n52.sensorweb.sos/binding-soap
/**
* Get text content from element by namespace.
*
* @param soapHeader
* SOAPHeader element
* @param namespaceURI
* Namespace URI
* @param localName
* local name
* @return Text content.
*/
public static String getContentFromElement(SOAPHeader soapHeader, String namespaceURI, String localName) {
String elementContent = null;
NodeList nodes = soapHeader.getElementsByTagNameNS(namespaceURI, localName);
for (int i = 0; i < nodes.getLength(); i++) {
elementContent = nodes.item(i).getTextContent();
}
return elementContent;
}
代码示例来源:origin: stackoverflow.com
SOAPHeader header = message.getSOAPHeader();
NodeList idSessaoNode = header.getElementsByTagNameNS("*", "IdSessao");
String idSess = idSessaoNode.item(0).getChildNodes().item(0).getNodeValue();
String guid = header.getTextContent();
代码示例来源:origin: org.objectweb.celtix/celtix-rt
private void addSOAPHeaderAttributes(SOAPHeader header, QName elName, boolean mustUnderstand) {
// Set mustUnderstand Attribute on header parts.
NodeList children = header.getElementsByTagNameNS(elName.getNamespaceURI(), elName.getLocalPart());
assert children.getLength() == 1;
// Set the mustUnderstand attribute
if (children.item(0) instanceof Element) {
Element child = (Element)(children.item(0));
String n = header.lookupPrefix(HEADER_MUSTUNDERSTAND.getNamespaceURI());
n += ":" + HEADER_MUSTUNDERSTAND.getLocalPart();
child.setAttributeNS(HEADER_MUSTUNDERSTAND.getNamespaceURI(),
HEADER_MUSTUNDERSTAND.getLocalPart(),
mustUnderstand ? "true" : "false");
}
// TODO Actor/Role Attribute.
}
代码示例来源:origin: net.gltd.gtms.telephony/etrali-websvc
public boolean handleResponse(SOAPMessageContext smc) {
try {
NodeList sessionNodeList = smc.getMessage().getSOAPHeader().getElementsByTagNameNS(
"http://xml.apache.org/axis/session", "sessionID");
if (sessionNodeList.getLength() > 0) {
sessionId = sessionNodeList.item(0).getFirstChild().getNodeValue();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return true;
}
代码示例来源:origin: org.switchyard.components/switchyard-component-soap
/**
* Get the WS-A MessageID from the envelope.
*
* @param soapEnvelope The SOAPEnvelope
* @return The message id if found, null otehrwise
* @throws SOAPException If the envelope could not be read
*/
public static String getMessageID(SOAPEnvelope soapEnvelope) throws SOAPException {
NodeList headers = soapEnvelope.getHeader().getElementsByTagNameNS(WSA_ACTION_QNAME.getNamespaceURI(), WSA_ACTION_QNAME.getLocalPart());
if (headers.getLength() == 1) {
return ((javax.xml.soap.Node)headers.item(0)).getValue();
}
return null;
}
代码示例来源:origin: jboss-switchyard/components
/**
* Get the WS-A MessageID from the envelope.
*
* @param soapEnvelope The SOAPEnvelope
* @return The message id if found, null otehrwise
* @throws SOAPException If the envelope could not be read
*/
public static String getMessageID(SOAPEnvelope soapEnvelope) throws SOAPException {
NodeList headers = soapEnvelope.getHeader().getElementsByTagNameNS(WSA_ACTION_QNAME.getNamespaceURI(), WSA_ACTION_QNAME.getLocalPart());
if (headers.getLength() == 1) {
return ((javax.xml.soap.Node)headers.item(0)).getValue();
}
return null;
}
代码示例来源:origin: ChargeTimeEU/Java-OCA-OCPP
public static String getHeaderValue(SOAPMessage message, String tagName) {
String value = null;
try {
SOAPHeader header = message.getSOAPPart().getEnvelope().getHeader();
NodeList elements = header.getElementsByTagNameNS("*", tagName);
if (elements.getLength() > 0) {
value = elements.item(0).getChildNodes().item(0).getTextContent();
}
} catch (SOAPException e) {
logger.warn("getHeaderValue() failed", e);
}
return value;
}
代码示例来源:origin: org.dcm4che/dcm4chee-xds2-common-ws
private String getWsaHeader(SOAPMessageContext ctx, String name, String def) {
try {
SOAPHeader hdr =ctx.getMessage().getSOAPHeader();
NodeList nodeList = hdr.getElementsByTagNameNS(XDSConstants.WS_ADDRESSING_NS, name);
if (nodeList.getLength() == 0) {
return def;
}
String action = nodeList.item(0).getTextContent();
//remove 'urn:ihe:iti:2007:' to avoid ':' in filename!
int pos = action.lastIndexOf(':');
if (pos != -1)
action = action.substring(++pos);
return action;
} catch (Exception x) {
return "errorGetSOAPHeader";
}
}
代码示例来源:origin: org.dcm4che/dcm4chee-xds2-infoset
private String getWsaHeader(SOAPMessageContext ctx, String name, String def) {
try {
SOAPHeader hdr =ctx.getMessage().getSOAPHeader();
NodeList nodeList = hdr.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing", name);
if (nodeList.getLength() == 0) {
return def;
}
String action = nodeList.item(0).getTextContent();
//remove 'urn:ihe:iti:2007:' to avoid ':' in filename!
int pos = action.lastIndexOf(':');
if (pos != -1)
action = action.substring(++pos);
return action;
} catch (Exception x) {
return "errorGetSOAPHeader";
}
}
代码示例来源:origin: org.dcm4che/dcm4chee-xds2-ws
private String getWsaHeader(SOAPMessageContext ctx, String name, String def) {
try {
SOAPHeader hdr =ctx.getMessage().getSOAPHeader();
NodeList nodeList = hdr.getElementsByTagNameNS(XDSConstants.WS_ADDRESSING_NS, name);
if (nodeList.getLength() == 0) {
return def;
}
String action = nodeList.item(0).getTextContent();
//remove 'urn:ihe:iti:2007:' to avoid ':' in filename!
int pos = action.lastIndexOf(':');
if (pos != -1)
action = action.substring(++pos);
return action;
} catch (Exception x) {
return "errorGetSOAPHeader";
}
}
代码示例来源:origin: stackoverflow.com
// raw SOAP input as String
String input = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"http://WS.com/\">"
+ "<soapenv:Header>"
+ "<userID>34</userID>"
+ "<password>test</password>"
+ "</soapenv:Header>"
+ "<soapenv:Body>"
+ "</soapenv:Body>"
+ "</soapenv:Envelope>";
// Use MessageFactory with raw input as byte array
InputStream is = new ByteArrayInputStream(input.getBytes());
SOAPMessage message = MessageFactory.newInstance().createMessage(null, is);
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();
// obtain all Nodes tagged 'userID' or 'password'
NodeList userIdNode = header.getElementsByTagNameNS("*", "userID");
NodeList passwordNode = header.getElementsByTagNameNS("*", "password");
// extract the username and password
String userId = userIdNode.item(0).getChildNodes().item(0).getNodeValue();
String password = passwordNode.item(0).getChildNodes().item(0).getNodeValue();
System.out.println("userID: " + userId);
System.out.println("password: " + password);
代码示例来源:origin: com.hynnet/xws-security
public void writeTo(SOAPMessage saaj) throws SOAPException {
NodeList nl = saaj.getSOAPHeader().getElementsByTagNameNS(MessageConstants.WSSE_NS,MessageConstants.WSSE_SECURITY_LNAME);
try {
Marshaller writer = getMarshaller();
writer.marshal(bst,nl.item(0));
} catch (JAXBException ex) {
throw new SOAPException(ex);
}
}
代码示例来源:origin: be.e_contract.mycarenet/mycarenet-ehealth-common
private void handleOutboundMessage(SOAPMessageContext context) throws SOAPException {
SOAPMessage soapMessage = context.getMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPHeader header = soapEnvelope.getHeader();
NodeList toNodeList = header.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing", "To");
if (toNodeList.getLength() != 0) {
Element toElement = (Element) toNodeList.item(0);
toElement.setTextContent(this.to);
}
}
代码示例来源:origin: com.vmware.photon.controller/photon-vsphere-adapter-util
/**
* Finds the Security element from the header. If not found then creates one
* and returns the same
*
*/
public static Node getOrCreateSecurityElement(SOAPHeader header) {
NodeList targetElement = header.getElementsByTagNameNS(
WSS_NS, SECURITY_ELEMENT_NAME);
if (targetElement == null || targetElement.getLength() == 0) {
JAXBElement<SecurityHeaderType> value = wsseObjFactory
.createSecurity(wsseObjFactory.createSecurityHeaderType());
Node headerNode = marshallJaxbElement(value).getDocumentElement();
return header.appendChild(header.getOwnerDocument().importNode(
headerNode, true));
} else if (targetElement.getLength() > 1) {
throw new RuntimeException(ERR_INSERTING_SECURITY_HEADER);
}
return targetElement.item(0);
}
代码示例来源:origin: stackoverflow.com
WsDownloadInfs infs = new WsDownloadInfs();
WsDownloadInfsSoap proxy = infs.getWsDownloadInfsSoap();
proxy.login(1779, "5270");
BindingProvider prov = (BindingProvider) proxy;
HeaderList list = (HeaderList) prov.getResponseContext().get("com.sun.xml.internal.ws.api.message.HeaderList");
Header h =list.get(ObjectFactory._SessaoIdHeader_QNAME, true);
SOAPMessage message = MessageFactory.newInstance().createMessage();
h.writeTo(message);
SOAPHeader header = message.getSOAPHeader();
NodeList idSessaoNode = header.getElementsByTagNameNS("*", "IdSessao");
String idSess = idSessaoNode.item(0).getChildNodes().item(0).getNodeValue();
String guid = header.getTextContent();
代码示例来源:origin: org.mil-oss/fgsms-agentcore
NodeList elementsByTagNameNS = soapHeader.getElementsByTagNameNS(FgsmsSoapHeaderConstants.namespace, FgsmsSoapHeaderConstants.threadid_message_localname);
if (elementsByTagNameNS.getLength() > 0) {
Node node = elementsByTagNameNS.item(0);
代码示例来源:origin: org.mil-oss/fgsms-agentcore
NodeList elementsByTagNameNS = soapHeader.getElementsByTagNameNS(FgsmsSoapHeaderConstants.namespace, FgsmsSoapHeaderConstants.related_message_localname);
if (elementsByTagNameNS.getLength() > 0) {
Node node = elementsByTagNameNS.item(0);
内容来源于网络,如有侵权,请联系作者删除!