Search in sources :

Example 26 with SOAPException

use of jakarta.xml.soap.SOAPException in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageTester method init.

private void init() {
    MessageFactory mf = null;
    try {
        mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        MimeHeaders mhs = new MimeHeaders();
        mhs.addHeader("Content-Type", "text/xml");
        mhs.addHeader("Content-Transfer-Encoding", "binary");
        SOAPMessage sm = mf.createMessage(mhs, new ByteArrayInputStream(soap11Msg.getBytes()));
        msg = new SAAJMessage(sm);
    } catch (SOAPException e) {
        e.printStackTrace();
        assertTrue(false);
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue(false);
    }
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) SOAPException(jakarta.xml.soap.SOAPException) IOException(java.io.IOException) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 27 with SOAPException

use of jakarta.xml.soap.SOAPException in project metro-jax-ws by eclipse-ee4j.

the class ProviderImpl method invoke.

/* 
     */
public Source invoke(Source msg) {
    if (!isInjectionDone()) {
        throw new WebServiceException("Injection is not done");
    }
    // Test if we got the correct SOAPMessage that has handler changes
    try {
        MessageFactory fact = MessageFactory.newInstance();
        SOAPMessage soap = fact.createMessage();
        soap.getSOAPPart().setContent(msg);
        SOAPBody body = soap.getSOAPBody();
        Iterator i = body.getChildElements();
        SOAPElement elem = (SOAPElement) i.next();
        QName name = elem.getElementQName();
        QName exp = new QName("urn:test:types", "MyVoidTest");
        if (!exp.equals(name)) {
            throw new WebServiceException("Handler changes aren't reflected");
        }
    } catch (SOAPException e) {
        throw new WebServiceException("Got Incorrect Source");
    }
    printContext();
    String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body>  <VoidTestResponse xmlns=\"urn:test:types\"></VoidTestResponse></soapenv:Body></soapenv:Envelope>";
    Source source = new StreamSource(new ByteArrayInputStream(content.getBytes()));
    return source;
}
Also used : SOAPBody(jakarta.xml.soap.SOAPBody) WebServiceException(jakarta.xml.ws.WebServiceException) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) QName(javax.xml.namespace.QName) SOAPException(jakarta.xml.soap.SOAPException) StreamSource(javax.xml.transform.stream.StreamSource) Iterator(java.util.Iterator) SOAPElement(jakarta.xml.soap.SOAPElement) SOAPMessage(jakarta.xml.soap.SOAPMessage) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) InputSource(org.xml.sax.InputSource)

Example 28 with SOAPException

use of jakarta.xml.soap.SOAPException in project metro-jax-ws by eclipse-ee4j.

the class WsaTestImpl method createSOAPFault.

SOAPFault createSOAPFault(String message) {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
        fault.setFaultString(message);
        fault.setFaultCode(new QName("http://example.org/echo", "EmptyEchoString"));
        return fault;
    } catch (SOAPException ex) {
        throw new WebServiceException(ex);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) SOAPException(jakarta.xml.soap.SOAPException) SOAPFault(jakarta.xml.soap.SOAPFault)

Example 29 with SOAPException

use of jakarta.xml.soap.SOAPException in project openmq by eclipse-ee4j.

the class SendServiceImpl method rollback.

@Override
public void rollback(SOAPMessage sm) throws JMSException {
    try {
        String sid = MessageUtil.getServiceClientId(sm);
        if (sid == null) {
            throw new JMSException("Cannot rollback a transaction because sid is null.");
        }
        Client client = cache.getClient(sm);
        this.rollback(client);
    } catch (SOAPException soape) {
        JMSException jmse = new JMSException(soape.getMessage());
        jmse.setLinkedException(soape);
        throw jmse;
    }
}
Also used : SOAPException(jakarta.xml.soap.SOAPException) JMSException(jakarta.jms.JMSException)

Example 30 with SOAPException

use of jakarta.xml.soap.SOAPException in project openmq by eclipse-ee4j.

the class MessageUtil method getServiceAttribute.

public static String getServiceAttribute(SOAPMessage soapm, String localName) throws SOAPException {
    SOAPHeaderElement mh = getMessageHeaderElement(soapm);
    SOAPElement serviceElement = getJMSChildElement(mh, Constants.SERVICE);
    if (serviceElement == null) {
        throw new SOAPException("Message does not contain a Service SOAP Header Element.");
    }
    Name n = createJMSName(localName);
    String value = serviceElement.getAttributeValue(n);
    return value;
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) SOAPException(jakarta.xml.soap.SOAPException) SOAPElement(jakarta.xml.soap.SOAPElement) Name(jakarta.xml.soap.Name)

Aggregations

SOAPException (jakarta.xml.soap.SOAPException)71 SOAPMessage (jakarta.xml.soap.SOAPMessage)37 WebServiceException (jakarta.xml.ws.WebServiceException)30 SOAPBody (jakarta.xml.soap.SOAPBody)26 Node (org.w3c.dom.Node)20 QName (javax.xml.namespace.QName)13 MessageFactory (jakarta.xml.soap.MessageFactory)12 SOAPFault (jakarta.xml.soap.SOAPFault)12 SOAPElement (jakarta.xml.soap.SOAPElement)10 XMLStreamException (javax.xml.stream.XMLStreamException)8 DataHandler (jakarta.activation.DataHandler)6 StreamSource (javax.xml.transform.stream.StreamSource)6 SOAPHeader (jakarta.xml.soap.SOAPHeader)5 SOAPPart (jakarta.xml.soap.SOAPPart)5 StringReader (java.io.StringReader)5 Map (java.util.Map)5 Source (javax.xml.transform.Source)5 Message (com.sun.xml.ws.api.message.Message)4 SOAPFactory (jakarta.xml.soap.SOAPFactory)4 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)4