javax.xml.soap.Name Java Examples

The following examples show how to use javax.xml.soap.Name. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Fault1_1Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: SoapRequestBean.java    From openxds with Apache License 2.0 6 votes vote down vote up
public SOAPMessage onMessage(SOAPMessage msg){
    //handles the response back from the registry
    PrintStream orig = System.out;
    
    try {
        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
        Name response = env.createName("response");
        env.getBody().getChildElements(response);
        
    } catch (SOAPException ex) {
        ByteArrayOutputStream logarray = new ByteArrayOutputStream();
        ex.printStackTrace(writeErrorlog(logarray));
        logstring = logarray.toString();
        setlogmsg(logstring);  
    }
    
    return msg;
}
 
Example #3
Source File: Fault1_1Impl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
 
Example #4
Source File: NameImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: Fault1_1Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
 
Example #6
Source File: ElementImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: NameImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: NameImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #9
Source File: ElementImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Iterator<Name> getAllAttributes() {
    Iterator<Name> i = getAllAttributesFrom(this);
    ArrayList<Name> list = new ArrayList<>();
    while (i.hasNext()) {
        Name name = i.next();
        if (!"xmlns".equalsIgnoreCase(name.getPrefix()))
            list.add(name);
    }
    return list.iterator();
}
 
Example #10
Source File: NameImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected static Name createFromTagAndUri(String tagName, String uri) {
    if (tagName == null) {
        log.severe("SAAJ0201.name.not.created.from.null.tag");
        throw new IllegalArgumentException("Cannot create a name from a null tag.");
    }
    int index = tagName.indexOf(':');
    if (index < 0) {
        return new NameImpl(tagName, "", uri);
    } else {
        return new NameImpl(
            tagName.substring(index + 1),
            tagName.substring(0, index),
            uri);
    }
}
 
Example #11
Source File: BodyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPFault addFault(
    Name faultCode,
    String faultString,
    Locale locale)
    throws SOAPException {

    SOAPFault fault = addFault();
    fault.setFaultCode(faultCode);
    fault.setFaultString(faultString, locale);
    return fault;
}
 
Example #12
Source File: JRXmlaQueryExecuter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void parseAxesElement(SOAPElement axesElement) throws SOAPException
{
	// Cycle over Axis-Elements
	Name aName = sf.createName("Axis", "", MDD_URI);
	Iterator<?> itAxis = axesElement.getChildElements(aName);
	while (itAxis.hasNext())
	{
		SOAPElement axisElement = (SOAPElement) itAxis.next();
		Name name = sf.createName("name");
		String axisName = axisElement.getAttributeValue(name);

		if (axisName.equals(SLICER_AXIS_NAME))
		{
			continue;
		}

		// LookUp for the Axis
		JRXmlaResultAxis axis = xmlaResult.getAxisByName(axisName);

		// retrieve the tuples by <Tuples>
		name = sf.createName("Tuples", "", MDD_URI);
		Iterator<?> itTuples = axisElement.getChildElements(name);
		if (itTuples.hasNext())
		{
			SOAPElement eTuples = (SOAPElement) itTuples.next();
			handleTuplesElement(axis, eTuples);
		}
	}
}
 
Example #13
Source File: NameImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected static Name createFromTagAndUri(String tagName, String uri) {
    if (tagName == null) {
        log.severe("SAAJ0201.name.not.created.from.null.tag");
        throw new IllegalArgumentException("Cannot create a name from a null tag.");
    }
    int index = tagName.indexOf(':');
    if (index < 0) {
        return new NameImpl(tagName, "", uri);
    } else {
        return new NameImpl(
            tagName.substring(index + 1),
            tagName.substring(0, index),
            uri);
    }
}
 
Example #14
Source File: DocumentWebServiceAdapter.java    From mdw with Apache License 2.0 5 votes vote down vote up
/**
 * Create the SOAP request object based on the document variable value.
 */
protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException {
    try {
        MessageFactory messageFactory = getSoapMessageFactory();
        SOAPMessage soapMessage = messageFactory.createMessage();
        Map<Name,String> soapReqHeaders = getSoapRequestHeaders();
        if (soapReqHeaders != null) {
            SOAPHeader header = soapMessage.getSOAPHeader();
            for (Name name : soapReqHeaders.keySet()) {
                header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name));
            }
        }

        SOAPBody soapBody = soapMessage.getSOAPBody();

        Document requestDoc = null;
        if (requestObj instanceof String) {
            requestDoc = DomHelper.toDomDocument((String)requestObj);
            soapBody.addDocument(requestDoc);
        }
        else {
            Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE));
            XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)getPackage().getTranslator(reqVar.getType());
            requestDoc = docRefTrans.toDomDocument(requestObj);
            Document copiedDocument = DomHelper.copyDomDocument(requestDoc);
            soapBody.addDocument(copiedDocument);
        }

        return soapMessage;
    }
    catch (Exception ex) {
        throw new ActivityException(ex.getMessage(), ex);
    }
}
 
Example #15
Source File: JRXmlaQueryExecuter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void handleTuplesElement(JRXmlaResultAxis axis, SOAPElement tuplesElement) throws SOAPException
{
	Name tName = sf.createName("Tuple", "", MDD_URI);
	for (Iterator<?> itTuple = tuplesElement.getChildElements(tName); itTuple.hasNext();)
	{
		SOAPElement eTuple = (SOAPElement) itTuple.next();
		handleTupleElement(axis, eTuple);
	}
}
 
Example #16
Source File: HeaderImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris)
    throws SOAPException {

    if (supportedSoapUris == null) {
        log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");
        throw new SOAPException("Argument cannot be null; array of supportedURIs cannot be null");
    }
    if (supportedSoapUris.length == 0) {
        log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs");
        throw new SOAPException("List of supported URIs cannot be empty");
    }
    Name upgradeName = getUpgradeName();
    SOAPHeaderElement upgradeHeaderElement =
        (SOAPHeaderElement) addChildElement(upgradeName);
    Name supportedEnvelopeName = getSupportedEnvelopeName();
    for (int i = 0; i < supportedSoapUris.length; i ++) {
        SOAPElement subElement =
            upgradeHeaderElement.addChildElement(supportedEnvelopeName);
        String ns = "ns" + Integer.toString(i);
        subElement.addAttribute(
            NameImpl.createFromUnqualifiedName("qname"),
            ns + ":Envelope");
        subElement.addNamespaceDeclaration(ns, supportedSoapUris[i]);
    }
    return upgradeHeaderElement;
}
 
Example #17
Source File: BodyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPFault addFault(Name faultCode, String faultString)
    throws SOAPException {

    SOAPFault fault = addFault();
    fault.setFaultCode(faultCode);
    fault.setFaultString(faultString);
    return fault;
}
 
Example #18
Source File: FaultElement1_2Impl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #19
Source File: BodyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
    SOAPBodyElement newBodyElement =
        (SOAPBodyElement) ElementFactory.createNamedElement(
            ((SOAPDocument) getOwnerDocument()).getDocument(),
            name.getLocalName(),
            name.getPrefix(),
            name.getURI());
    if (newBodyElement == null) {
        newBodyElement = createBodyElement(name);
    }
    addNode(newBodyElement);
    return newBodyElement;
}
 
Example #20
Source File: NameImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static Name convertToName(QName qname) {
    return new NameImpl(qname.getLocalPart(),
                        qname.getPrefix(),
                        qname.getNamespaceURI());
}
 
Example #21
Source File: HeaderElement1_2Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public HeaderElement1_2Impl(SOAPDocumentImpl ownerDoc, Name qname) {
    super(ownerDoc, qname);
}
 
Example #22
Source File: WebFaultOutInterceptorTestCase.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Name getFaultCodeAsName() {
    return null;
}
 
Example #23
Source File: HeaderElement1_1Impl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public HeaderElement1_1Impl(SOAPDocumentImpl ownerDoc, Name qname) {
    super(ownerDoc, qname);
}
 
Example #24
Source File: NameImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static Name createFromTagName(String tagName) {
    return createFromTagAndUri(tagName, "");
}
 
Example #25
Source File: HeaderElement1_1Impl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public HeaderElement1_1Impl(SOAPDocumentImpl ownerDoc, Name qname) {
    super(ownerDoc, qname);
}
 
Example #26
Source File: HeaderElement1_1Impl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public HeaderElement1_1Impl(SOAPDocumentImpl ownerDoc, Name qname) {
    super(ownerDoc, qname);
}
 
Example #27
Source File: SoapFactoryImpl.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public SOAPElement createElement(Name arg0) throws SOAPException {
    return getSOAPFactory().createElement(arg0);
}
 
Example #28
Source File: NameImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static QName convertToQName(Name name) {
    return new QName(name.getURI(),
                     name.getLocalName(),
                     name.getPrefix());
}
 
Example #29
Source File: HeaderImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected SOAPElement addElement(Name name) throws SOAPException {
    return addHeaderElement(name);
}
 
Example #30
Source File: NameImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static QName convertToQName(Name name) {
    return new QName(name.getURI(),
                     name.getLocalName(),
                     name.getPrefix());
}