本文整理汇总了Java中javax.xml.soap.Name类的典型用法代码示例。如果您正苦于以下问题:Java Name类的具体用法?Java Name怎么用?Java Name使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Name类属于javax.xml.soap包,在下文中一共展示了Name类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessage
import javax.xml.soap.Name; //导入依赖的package包/类
private SOAPMessage createMessage(MessageFactory mf) throws SOAPException, IOException {
SOAPMessage msg = mf.createMessage();
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
Name name = envelope.createName("hello", "ex", "http://example.com");
envelope.getBody().addChildElement(name).addTextNode("THERE!");
String s = "<root><hello>THERE!</hello></root>";
AttachmentPart ap = msg.createAttachmentPart(
new StreamSource(new ByteArrayInputStream(s.getBytes())),
"text/xml"
);
msg.addAttachmentPart(ap);
msg.saveChanges();
return msg;
}
示例2: createSimpleSOAPPart
import javax.xml.soap.Name; //导入依赖的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");
}
示例3: getFaultCodeAsName
import javax.xml.soap.Name; //导入依赖的package包/类
public Name getFaultCodeAsName() {
String faultcodeString = getFaultCode();
if (faultcodeString == null) {
return null;
}
int prefixIndex = faultcodeString.indexOf(':');
if (prefixIndex == -1) {
// Not a valid SOAP message, but we return the unqualified name
// anyway since some apps do not strictly conform to SOAP
// specs. A message that does not contain a <faultcode>
// element itself is also not valid in which case we return
// null instead of throwing an exception so this is consistent.
return NameImpl.createFromUnqualifiedName(faultcodeString);
}
// Get the prefix and map it to a namespace name (AKA namespace URI)
String prefix = faultcodeString.substring(0, prefixIndex);
if (this.faultCodeElement == null)
findFaultCodeElement();
String nsName = this.faultCodeElement.getNamespaceURI(prefix);
return NameImpl.createFromQualifiedName(faultcodeString, nsName);
}
示例4: equals
import javax.xml.soap.Name; //导入依赖的package包/类
public boolean equals(Object obj) {
if (!(obj instanceof Name)) {
return false;
}
Name otherName = (Name) obj;
if (!uri.equals(otherName.getURI())) {
return false;
}
if (!localName.equals(otherName.getLocalName())) {
return false;
}
return true;
}
示例5: getFaultCodeAsName
import javax.xml.soap.Name; //导入依赖的package包/类
@Override
public Name getFaultCodeAsName() {
String faultcodeString = getFaultCode();
if (faultcodeString == null) {
return null;
}
int prefixIndex = faultcodeString.indexOf(':');
if (prefixIndex == -1) {
// Not a valid SOAP message, but we return the unqualified name
// anyway since some apps do not strictly conform to SOAP
// specs. A message that does not contain a <faultcode>
// element itself is also not valid in which case we return
// null instead of throwing an exception so this is consistent.
return NameImpl.createFromUnqualifiedName(faultcodeString);
}
// Get the prefix and map it to a namespace name (AKA namespace URI)
String prefix = faultcodeString.substring(0, prefixIndex);
if (this.faultCodeElement == null)
findFaultCodeElement();
String nsName = this.faultCodeElement.getNamespaceURI(prefix);
return NameImpl.createFromQualifiedName(faultcodeString, nsName);
}
示例6: equals
import javax.xml.soap.Name; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Name)) {
return false;
}
Name otherName = (Name) obj;
if (!uri.equals(otherName.getURI())) {
return false;
}
if (!localName.equals(otherName.getLocalName())) {
return false;
}
return true;
}
示例7: replaceElementWithSOAPElement
import javax.xml.soap.Name; //导入依赖的package包/类
protected SOAPElement replaceElementWithSOAPElement(
Element element,
ElementImpl copy) {
Iterator<Name> eachAttribute = getAllAttributesFrom(element);
while (eachAttribute.hasNext()) {
Name name = eachAttribute.next();
copy.addAttributeBare(name, getAttributeValueFrom(element, name));
}
Iterator<Node> eachChild = getChildElementsFromDOM(element);
while (eachChild.hasNext()) {
Node nextChild = eachChild.next();
copy.insertBefore(nextChild, null);
}
Node parent = soapDocument.find(element.getParentNode());
if (parent != null) {
parent.replaceChild(copy, element);
} // XXX else throw an exception?
return copy;
}
示例8: getSOAPNamespace
import javax.xml.soap.Name; //导入依赖的package包/类
protected String getSOAPNamespace() {
String soapNamespace = null;
SOAPElement antecedent = this;
while (antecedent != null) {
Name antecedentName = antecedent.getElementName();
String antecedentNamespace = antecedentName.getURI();
if (NameImpl.SOAP11_NAMESPACE.equals(antecedentNamespace)
|| NameImpl.SOAP12_NAMESPACE.equals(antecedentNamespace)) {
soapNamespace = antecedentNamespace;
break;
}
antecedent = antecedent.getParentElement();
}
return soapNamespace;
}
示例9: addHeaderElement
import javax.xml.soap.Name; //导入依赖的package包/类
@Override
public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
SOAPElement newHeaderElement =
ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
name.getLocalName(),
name.getPrefix(),
name.getURI());
if (newHeaderElement == null
|| !(newHeaderElement instanceof SOAPHeaderElement)) {
newHeaderElement = createHeaderElement(name);
}
// header elements must be namespace qualified
// check that URI is not empty, ensuring that the element is NS qualified.
String uri = newHeaderElement.getElementQName().getNamespaceURI();
if ((uri == null) || ("").equals(uri)) {
log.severe("SAAJ0131.impl.header.elems.ns.qualified");
throw new SOAPExceptionImpl("HeaderElements must be namespace qualified");
}
addNode(newHeaderElement);
return (SOAPHeaderElement) newHeaderElement;
}
示例10: writeTerminalResponse
import javax.xml.soap.Name; //导入依赖的package包/类
/**
* Gets the terminal response.
*
* @param message
* @throws SOAPException
*/
private void writeTerminalResponse(SOAPMessage message) throws SOAPException {
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name terminalResponseName = envelope.createName("EditTerminalResponse", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalResponseElement = (SOAPBodyElement) message.getSOAPBody().getChildElements(terminalResponseName).next();
NodeList list = terminalResponseElement.getChildNodes();
Node n = null;
for (int i = 0; i < list.getLength(); i++) {
n = list.item(i);
if ("status".equalsIgnoreCase(n.getLocalName()))
break;
}
logger.info("status of device = " + n.getNodeValue());
}
示例11: createTerminalRequest
import javax.xml.soap.Name; //导入依赖的package包/类
/**
* This method creates a Terminal Request and sends back the SOAPMessage.
* MSISDN value is passed into this method
*
* @param msisdn
* @return
* @throws SOAPException
*/
private SOAPMessage createTerminalRequest(String msisdn) throws SOAPException {
SOAPMessage message = messageFactory.createMessage();
message.getMimeHeaders().addHeader("SOAPAction", "http://api.jasperwireless.com/ws/service/terminal/GetTerminalsByMsisdn");
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name terminalRequestName = envelope.createName("GetTerminalsByMsisdnRequest", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalRequestElement = message.getSOAPBody().addBodyElement(terminalRequestName);
Name msgId = envelope.createName("messageId", PREFIX, NAMESPACE_URI);
SOAPElement msgElement = terminalRequestElement.addChildElement(msgId);
msgElement.setValue("TCE-100-ABC-34084");
Name version = envelope.createName("version", PREFIX, NAMESPACE_URI);
SOAPElement versionElement = terminalRequestElement.addChildElement(version);
versionElement.setValue("1.0");
Name license = envelope.createName("licenseKey", PREFIX, NAMESPACE_URI);
SOAPElement licenseElement = terminalRequestElement.addChildElement(license);
licenseElement.setValue(apiKey);
Name msisdns = envelope.createName("msisdns", PREFIX, NAMESPACE_URI);
SOAPElement msisdnsElement = terminalRequestElement.addChildElement(msisdns);
Name msisdnName = envelope.createName("msisdn", PREFIX, NAMESPACE_URI);
SOAPElement msisdnElement = msisdnsElement.addChildElement(msisdnName);
msisdnElement.setValue(msisdn);
return message;
}
示例12: writeTerminalResponse
import javax.xml.soap.Name; //导入依赖的package包/类
/**
* Gets the terminal response.
*
* @param message
* @throws SOAPException
*/
private String writeTerminalResponse(SOAPMessage message) throws SOAPException {
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name terminalResponseName = envelope.createName("GetTerminalsByMsisdnResponse", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalResponseElement = (SOAPBodyElement) message.getSOAPBody().getChildElements(terminalResponseName).next();
Name terminals = envelope.createName("terminals", PREFIX, NAMESPACE_URI);
Name terminal = envelope.createName("terminal", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalsElement = (SOAPBodyElement) terminalResponseElement.getChildElements(terminals).next();
SOAPBodyElement terminalElement = (SOAPBodyElement) terminalsElement.getChildElements(terminal).next();
NodeList list = terminalElement.getChildNodes();
Node n = null, node = null;
for (int i = 0; i < list.getLength(); i++) {
node = list.item(i);
logger.info(node.getLocalName() + ":" + node.getFirstChild().getNodeValue());
if ("iccid".equalsIgnoreCase(node.getLocalName())) {
n = node;
}
}
return n.getFirstChild().getNodeValue();
}
示例13: createElement
import javax.xml.soap.Name; //导入依赖的package包/类
/**
* Create a SOAP Element with the specified parameters.<p>
*
* Also it create the attributes set as the parameter properties.
*
* @param tagName the name of XML tag.
* @param tagValue the value of XML tag.
* @param nsPrefix the namespace prefix.
* @param nsURI the namespace URL.
* @param attrSet the attributes set in the element.
*
* @return the new SOAP element created.
*/
public static SOAPElement createElement(String tagName
,String tagValue
,String nsPrefix
,String nsURI
,Hashtable attrSet) throws SOAPException {
SOAPElement newElem =
SOAPUtilities.createElement(tagName, tagValue, nsPrefix, nsURI);
if (newElem == null || attrSet.size() == 0)
return newElem;
// Iterate all attributes in the set.
Enumeration keys = attrSet.keys();
while (keys.hasMoreElements()){
Object key = keys.nextElement();
Object value = attrSet.get(key);
// Create SOAP Name for the tag.
Name attrName = SOAPFactory.newInstance().createName(key.toString(), null, null);
newElem.addAttribute(attrName, value.toString());
}
return newElem;
}
示例14: getChildElements
import javax.xml.soap.Name; //导入依赖的package包/类
private static Iterator getChildElements(SOAPElement parent, Name name) {
final ArrayList childElements = new ArrayList();
for (Iterator i=parent.getChildElements() ; i.hasNext() ; ) {
final Object object = i.next();
if ((object instanceof SOAPElement) == false)
continue;
final SOAPElement child = (SOAPElement) object;
final Name childName = child.getElementName();
if (childName.getLocalName().equals(name.getLocalName()) &&
childName.getURI().equals(name.getURI())) {
childElements.add(child);
continue;
}
for (Iterator j=getChildElements(child, name) ; j.hasNext() ; ) {
final SOAPElement grandChild = (SOAPElement) j.next();
childElements.add(grandChild);
}
}
return childElements.iterator();
}
示例15: addParameterList
import javax.xml.soap.Name; //导入依赖的package包/类
protected void addParameterList(SOAPEnvelope envelope, SOAPElement eParent, String typeName, String listName, Map<String, String> params) throws SOAPException
{
Name nPara = envelope.createName(typeName, "", XMLA_URI);
SOAPElement eType = eParent.addChildElement(nPara);
nPara = envelope.createName(listName, "", XMLA_URI);
SOAPElement eList = eType.addChildElement(nPara);
if (params == null)
{
return;
}
for (Iterator<Map.Entry<String, String>> entryIt = params.entrySet().iterator(); entryIt.hasNext();)
{
Map.Entry<String, String> entry = entryIt.next();
String tag = entry.getKey();
String value = entry.getValue();
nPara = envelope.createName(tag, "", XMLA_URI);
SOAPElement eTag = eList.addChildElement(nPara);
eTag.addTextNode(value);
}
}