javax.xml.soap.DetailEntry Java Examples

The following examples show how to use javax.xml.soap.DetailEntry. 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: TestSOAPHandler.java    From cxf with Apache License 2.0 6 votes vote down vote up
private SOAPFaultException createSOAPFaultExceptionWithDetail(String faultString)
    throws SOAPException {

    SOAPFault fault = SOAPFactory.newInstance().createFault();

    QName faultName = new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE,
                    "Server");
    SAAJUtils.setFaultCode(fault, faultName);
    fault.setFaultActor("http://gizmos.com/orders");
    fault.setFaultString(faultString);

    Detail detail = fault.addDetail();

    QName entryName = new QName("http://gizmos.com/orders/",
                    "order", "PO");
    DetailEntry entry = detail.addDetailEntry(entryName);
    entry.addTextNode("Quantity element does not have a value");

    QName entryName2 = new QName("http://gizmos.com/orders/",
                    "order", "PO");
    DetailEntry entry2 = detail.addDetailEntry(entryName2);
    entry2.addTextNode("Incomplete address: no zip code");

    return new SOAPFaultException(fault);
}
 
Example #2
Source File: SOAPFaultBuilder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #3
Source File: SOAPFaultBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #4
Source File: SOAPFaultBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #5
Source File: JPlagServerAccessHandler.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Manually builds up a JPlagException SOAP message and replaces the
 * original one with it
 */
public void replaceByJPlagException(SOAPMessageContext smsg, String desc, String rep) {
	try {
		SOAPMessage msg = smsg.getMessage();
		SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();

		/*
		 * Remove old header andy body
		 */

		SOAPHeader oldheader = envelope.getHeader();
		if (oldheader != null)
			oldheader.detachNode();
		SOAPBody oldbody = envelope.getBody();
		if (oldbody != null)
			oldbody.detachNode();

		SOAPBody sb = envelope.addBody();
		SOAPFault sf = sb.addFault(envelope.createName("Server", "env", SOAPConstants.URI_NS_SOAP_ENVELOPE),
				"jplagWebService.server.JPlagException");
		Detail detail = sf.addDetail();
		DetailEntry de = detail.addDetailEntry(envelope.createName("JPlagException", "ns0", JPLAG_WEBSERVICE_BASE_URL + "types"));

		SOAPElement e = de.addChildElement("exceptionType");
		e.addTextNode("accessException");

		e = de.addChildElement("description");
		e.addTextNode(desc);

		e = de.addChildElement("repair");
		e.addTextNode(rep);
	} catch (SOAPException x) {
		x.printStackTrace();
	}
}
 
Example #6
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #7
Source File: SOAPFaultBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #8
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #9
Source File: SOAPFaultBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #10
Source File: SOAPFaultBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
Example #11
Source File: Detail1_1Impl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #12
Source File: Detail1_1Impl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #13
Source File: Detail1_1Impl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #14
Source File: Detail1_1Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #15
Source File: Detail1_1Impl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #16
Source File: HWSoapMessageDocProvider.java    From cxf with Apache License 2.0 4 votes vote down vote up
public SOAPMessage invoke(SOAPMessage request) {
    QName qn = (QName)ctx.getMessageContext().get(MessageContext.WSDL_OPERATION);
    if (qn == null) {
        throw new RuntimeException("No Operation Name");
    }

    SOAPMessage response = null;
    SOAPBody body = null;
    try {
        body = SAAJUtils.getBody(request);
    } catch (SOAPException e) {
        return null;
    }
    Node n = body.getFirstChild();

    while (n.getNodeType() != Node.ELEMENT_NODE) {
        n = n.getNextSibling();
    }
    if (n.getLocalName().equals(sayHi.getLocalPart())) {
        response = sayHiResponse;
    } else if (n.getLocalName().equals(greetMe.getLocalPart())) {
        Element el = DOMUtils.getFirstElement(n);
        String v = DOMUtils.getContent(el);
        if (v.contains("Return sayHi")) {
            response = sayHiResponse;
        } else if (v.contains("exceed maxLength")) {
            response = greetMeResponseExceedMaxLengthRestriction;
        } else if (v.contains("throwFault")) {
            try {
                SOAPFactory f = SOAPFactory.newInstance();
                SOAPFault soapFault = f.createFault();

                soapFault.setFaultString("Test Fault String ****");

                Detail detail = soapFault.addDetail();
                detail = soapFault.getDetail();

                QName qName = new QName("http://www.Hello.org/greeter", "TestFault", "ns");
                DetailEntry de = detail.addDetailEntry(qName);

                qName = new QName("http://www.Hello.org/greeter", "ErrorCode", "ns");
                SOAPElement errorElement = de.addChildElement(qName);
                errorElement.setTextContent("errorcode");
                throw new SOAPFaultException(soapFault);
            } catch (SOAPException ex) {
                //ignore
            }

        } else {
            response = greetMeResponse;
        }
    }
    return response;
}
 
Example #17
Source File: HWDOMSourcePayloadProvider.java    From cxf with Apache License 2.0 4 votes vote down vote up
public DOMSource invoke(DOMSource request) {
    QName qn = (QName)ctx.getMessageContext().get(MessageContext.WSDL_OPERATION);
    if (qn == null) {
        throw new RuntimeException("No Operation Name");
    }

    DOMSource response = new DOMSource();

    Node n = request.getNode();
    if (n instanceof Document) {
        n = ((Document)n).getDocumentElement();
    }
    if (n.getLocalName().equals(sayHi.getLocalPart())) {
        response.setNode(sayHiResponse);
    } else if (n.getLocalName().equals(greetMe.getLocalPart())) {
        Element el = DOMUtils.getFirstElement(n);
        String s = DOMUtils.getContent(el);
        if ("throwFault".equals(s.trim())) {
            try {
                SOAPFactory f = SOAPFactory.newInstance();
                SOAPFault soapFault = f.createFault();

                soapFault.setFaultString("Test Fault String ****");

                Detail detail = soapFault.addDetail();
                detail = soapFault.getDetail();

                QName qName = new QName("http://www.Hello.org/greeter", "TestFault", "ns");
                DetailEntry de = detail.addDetailEntry(qName);

                qName = new QName("http://www.Hello.org/greeter", "ErrorCode", "ns");
                SOAPElement errorElement = de.addChildElement(qName);
                errorElement.setTextContent("errorcode");

                throw new SOAPFaultException(soapFault);
            } catch (SOAPException e) {
                e.printStackTrace();
            }
        }

        response.setNode(greetMeResponse);
    }
    return response;
}
 
Example #18
Source File: Detail1_1Impl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #19
Source File: Detail1_1Impl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #20
Source File: Detail1_1Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #21
Source File: Detail1_1Impl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #22
Source File: Detail1_1Impl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #23
Source File: Detail1_1Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #24
Source File: Detail1_1Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #25
Source File: Detail1_1Impl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #26
Source File: Detail1_1Impl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #27
Source File: Detail1_1Impl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(QName name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}
 
Example #28
Source File: Detail1_1Impl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected DetailEntry createDetailEntry(Name name) {
    return new DetailEntry1_1Impl(
        (SOAPDocumentImpl) getOwnerDocument(),
        name);
}