javax.xml.soap.Detail Java Examples

The following examples show how to use javax.xml.soap.Detail. 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: SOAP11Fault.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #2
Source File: SOAP11Fault.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #3
Source File: SOAP11Fault.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #4
Source File: MessageModeOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void validateFault(SoapMessage message, SOAPFault fault, BindingOperationInfo bop) {
    if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) {
        Schema schema = EndpointReferenceUtils.getSchema(message.getExchange().getService()
                                                         .getServiceInfos().get(0),
                                                     message.getExchange().getBus());
        Detail d = fault.getDetail();
        try {
            validateFaultDetail(d, schema, bop);
        } catch (Exception e) {
            throw new SoapFault(e.getMessage(), e, message.getVersion().getReceiver());
        }

        //We validated what we can from a fault standpoint
        message.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    }
}
 
Example #5
Source File: SOAP11Fault.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #6
Source File: SOAP11Fault.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #7
Source File: SOAP11Fault.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #8
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 #9
Source File: HandlerInvocationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSOAPHandlerHandleMessageThrowsSOAPFaultExceptionServerInbound() throws PingException {
    try {
        handlerTest.pingWithArgs("soapHandler3 inbound throw SOAPFaultExceptionWDetail");
        fail("did not get expected SOAPFaultException");
    } catch (SOAPFaultException e) {
        assertEquals("HandleMessage throws exception", e.getMessage());
        SOAPFault fault = e.getFault();
        assertNotNull(fault);
        assertEquals(new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"),
                     fault.getFaultCodeAsQName());
        assertEquals("http://gizmos.com/orders", fault.getFaultActor());

        Detail detail = fault.getDetail();
        assertNotNull(detail);

        QName nn = new QName("http://gizmos.com/orders/", "order");
        Element el = DOMUtils.getFirstChildWithName(detail, nn);
        assertNotNull(el);
        el.normalize();
        assertEquals("Quantity element does not have a value", el.getFirstChild().getNodeValue());
        el = DOMUtils.getNextElement(el);
        el.normalize();
        assertEquals("Incomplete address: no zip code", el.getFirstChild().getNodeValue());
    }
}
 
Example #10
Source File: SOAP11Fault.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #11
Source File: SOAP11Fault.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
Source File: WsaTubeHelper.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
    String action = null;
    if (seiModel == null || wsdlPort == null) {
        return action;
    }

    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }

        if (sm.getSOAPBody() == null) {
            return action;
        }

        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }

        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }

        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();

        WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
        JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl)wsdlOp.getJavaMethod() : null;
        if (jm != null) {
          for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
              if (ce.getDetailType().tagName.getLocalPart().equals(name) &&
                      ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
                  return ce.getFaultAction();
              }
          }
        }
        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #23
Source File: SOAPFactory1_1Impl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Detail createDetail() throws SOAPException {
    return new Detail1_1Impl(createDocument());
}
 
Example #24
Source File: SOAPFactory1_2Impl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Detail createDetail() throws SOAPException {
    return new Detail1_2Impl(createDocument());
}
 
Example #25
Source File: SOAPFactoryDynamicImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Detail createDetail() throws SOAPException {
    throw new UnsupportedOperationException(
            "createDetail() not supported for Dynamic Protocol");
}
 
Example #26
Source File: WebFaultOutInterceptorTestCase.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Detail addDetail() throws SOAPException {
    return null;
}
 
Example #27
Source File: WebFaultOutInterceptorTestCase.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Detail getDetail() {
    return null;
}
 
Example #28
Source File: WsaTubeHelper.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
    String action = null;
    if (seiModel == null || wsdlPort == null) {
        return action;
    }

    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }

        if (sm.getSOAPBody() == null) {
            return action;
        }

        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }

        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }

        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();

        WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
        JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl)wsdlOp.getJavaMethod() : null;
        if (jm != null) {
          for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
              if (ce.getDetailType().tagName.getLocalPart().equals(name) &&
                      ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
                  return ce.getFaultAction();
              }
          }
        }
        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #29
Source File: WsaTubeHelper.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) {
    String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer);
    if (action != null) {
        return action;
    }

    action = addVer.getDefaultFaultAction();
    if (wbo == null) {
        return action;
    }

    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }

        if (sm.getSOAPBody() == null) {
            return action;
        }

        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }

        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }

        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();

        WSDLOperation o = wbo.getOperation();

        WSDLFault fault = o.getFault(new QName(ns, name));
        if (fault == null) {
            return action;
        }

        action = fault.getAction();

        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #30
Source File: SoapFactoryImpl.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public Detail createDetail() throws SOAPException {
    return getSOAPFactory().createDetail();
}