本文整理汇总了Java中javax.xml.soap.Name.getLocalName方法的典型用法代码示例。如果您正苦于以下问题:Java Name.getLocalName方法的具体用法?Java Name.getLocalName怎么用?Java Name.getLocalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.Name
的用法示例。
在下文中一共展示了Name.getLocalName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOperationElement
import javax.xml.soap.Name; //导入方法依赖的package包/类
public QName getOperationElement() throws WebServiceException {
try {
if (style != Style.RPC) {
return null;
}
switch (contentType) {
case OM:
return ((org.apache.axiom.soap.SOAPEnvelope)content).getBody().
getFirstElement().getQName();
case SPINE:
return ((XMLSpine)content).getOperationElement();
case SOAPENVELOPE:
Iterator it = ((SOAPEnvelope)content).getBody().getChildElements();
while (it.hasNext()) {
Node node = (Node)it.next();
if (node instanceof SOAPElement) {
Name name = ((SOAPElement)node).getElementName();
return new QName(name.getURI(), name.getLocalName(), name.getPrefix());
}
}
}
return null;
} catch (SOAPException se) {
throw ExceptionFactory.makeWebServiceException(se);
}
}
示例2: createElement
import javax.xml.soap.Name; //导入方法依赖的package包/类
/**
* Create a <code>SOAPElement</code> object initialized with the given <code>Name</code>
* object.
*
* @param name a <code>Name</code> object with the XML name for the new element
* @return the new <code>SOAPElement</code> object that was created
* @throws javax.xml.soap.SOAPException if there is an error in creating the <code>SOAPElement</code>
* object
*/
public SOAPElement createElement(Name name) throws SOAPException {
String localName = name.getLocalName();
String prefix = name.getPrefix();
String uri = name.getURI();
OMElement omElement = null;
if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName
, uri, prefix);
} else {
omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName
, uri, prefix);
}
DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
return new SOAPElementImpl((ElementImpl)omElement);
}
示例3: addHeaderElement
import javax.xml.soap.Name; //导入方法依赖的package包/类
/**
* Creates a new <CODE>SOAPHeaderElement</CODE> object initialized with the specified name and
* adds it to this <CODE>SOAPHeader</CODE> object.
*
* @param name a <CODE>Name</CODE> object with the name of the new <CODE>SOAPHeaderElement</CODE>
* object
* @return the new <CODE>SOAPHeaderElement</CODE> object that was inserted into this
* <CODE>SOAPHeader</CODE> object
* @throws SOAPException if a SOAP error occurs
*/
public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
if (name.getURI() == null
|| name.getURI().trim().length() == 0) {
throw new SOAPException("SOAP1.1 and SOAP1.2 requires all HeaderElements to have " +
"a namespace.");
}
String prefix = name.getPrefix() == null ? "" : name.getPrefix();
OMNamespace ns = new NamespaceImpl(name.getURI(), prefix);
SOAPHeaderBlock headerBlock = null;
if (this.element.getOMFactory() instanceof SOAP11Factory) {
headerBlock = new SOAP11HeaderBlockImpl(name.getLocalName(), ns, omSOAPHeader,
(SOAPFactory)this.element.getOMFactory());
} else {
headerBlock = new SOAP12HeaderBlockImpl(name.getLocalName(), ns, omSOAPHeader,
(SOAPFactory)this.element.getOMFactory());
}
SOAPHeaderElementImpl soapHeaderElement = new SOAPHeaderElementImpl(headerBlock);
element.setUserData(SAAJ_NODE, this, null);
soapHeaderElement.element.setUserData(SAAJ_NODE, soapHeaderElement, null);
soapHeaderElement.setParentElement(this);
return soapHeaderElement;
}
示例4: testAddNotUnderstoodHeaderElement
import javax.xml.soap.Name; //导入方法依赖的package包/类
@Validated @Test
public void testAddNotUnderstoodHeaderElement() throws Exception {
javax.xml.soap.SOAPMessage soapMessage =
javax.xml.soap.MessageFactory.newInstance(
SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
javax.xml.soap.SOAPEnvelope soapEnv =
soapMessage.getSOAPPart().getEnvelope();
javax.xml.soap.SOAPHeader header = soapEnv.getHeader();
SOAPElement soapElement = header.addNotUnderstoodHeaderElement(
new QName("http://foo.org", "foo", "f"));
assertNotNull(soapElement);
Name name = soapElement.getElementName();
String uri = name.getURI();
String localName = name.getLocalName();
assertEquals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, uri);
//Validate the LocalName which must be NotUnderstood
assertEquals("NotUnderstood", localName);
}
示例5: testAddUpgradeHeaderElement
import javax.xml.soap.Name; //导入方法依赖的package包/类
@Validated @Test
public void testAddUpgradeHeaderElement() throws Exception {
javax.xml.soap.SOAPMessage soapMessage =
javax.xml.soap.MessageFactory.newInstance(
SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
javax.xml.soap.SOAPEnvelope soapEnv =
soapMessage.getSOAPPart().getEnvelope();
javax.xml.soap.SOAPHeader header = soapEnv.getHeader();
// create a list of supported URIs.
ArrayList supported = new ArrayList();
supported.add(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE);
supported.add(SOAPConstants.URI_NS_SOAP_ENVELOPE);
SOAPElement soapElement = header.addUpgradeHeaderElement(supported.iterator());
assertNotNull(soapElement);
Name name = soapElement.getElementName();
String uri = name.getURI();
String localName = name.getLocalName();
//Validate the URI which must be SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE);
assertTrue(uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE));
assertTrue(localName.equals("Upgrade"));
}
示例6: ExtensionElementImpl
import javax.xml.soap.Name; //导入方法依赖的package包/类
/**
* Construct an <code>ExtensionElement</code> using the given
* <code>SOAPEnvelope</code> and <code>SOAPElement</code>
*/
ExtensionElementImpl(SOAPEnvelope soapEnvelope, SOAPElement soapElement)
throws SOAPException {
this.soapEnvelope = soapEnvelope;
this.soapElement = soapElement;
Name name = soapElement.getElementName();
localName = name.getLocalName();
namespacePrefix = name.getPrefix();
namespaceUri = name.getURI();
}
示例7: getChildElements
import javax.xml.soap.Name; //导入方法依赖的package包/类
public Iterator getChildElements(Name name) {
QName qName = new QName(name.getURI(), name.getLocalName());
Iterator childIter = element.getChildrenWithName(qName);
Collection childElements = new ArrayList();
while (childIter.hasNext()) {
childElements.add(toSAAJNode((org.w3c.dom.Node)childIter.next()));
}
return childElements.iterator();
}
示例8: convertToQName
import javax.xml.soap.Name; //导入方法依赖的package包/类
public static QName convertToQName(Name name) {
return new QName(name.getURI(),
name.getLocalName(),
name.getPrefix());
}
示例9: getChildElements
import javax.xml.soap.Name; //导入方法依赖的package包/类
public Iterator getChildElements(Name name) {
QName qName = new QName(name.getURI(), name.getLocalName());
return getChildren(element.getChildrenWithName(qName));
}
示例10: setFaultCode
import javax.xml.soap.Name; //导入方法依赖的package包/类
/**
* Sets this SOAPFault object with the given fault code.Fault codes, which give information
* about the fault, are defined in the SOAP 1.1 specification. A fault code is mandatory and
* must be of type QName. This method provides a convenient way to set a fault code. For
* example,
* <p/>
* SOAPEnvelope se = ...; // Create a qualified name in the SOAP namespace with a localName //
* of Client. Note that prefix parameter is optional and is null // here which causes the
* implementation to use an appropriate prefix. Name qname = se.createName(Client,
* null,SOAPConstants.URI_NS_SOAP_ENVELOPE); SOAPFault fault = ...; fault.setFaultCode(qname);
* <p/>
* It is preferable to use this method over setFaultCode(String).
*
* @param faultCodeQName - a Name object giving the fault code to be set. It must be namespace
* qualified.
* @throws SOAPException - if there was an error in adding the faultcode element to the
* underlying XML tree.
*/
public void setFaultCode(Name faultCodeName) throws SOAPException {
if (faultCodeName.getURI() == null || faultCodeName.getURI().trim().length() == 0) {
throw new SOAPException("faultCodeQName must be namespace qualified.");
}
QName faultCodeQName =
new QName(faultCodeName.getURI(), faultCodeName.getLocalName(), faultCodeName.getPrefix());
setFaultCode(faultCodeQName);
}