Search in sources :

Example 1 with HTTPBinding

use of javax.xml.ws.http.HTTPBinding in project cxf by apache.

the class DispatchTest method testHTTPBinding.

@Test
public void testHTTPBinding() throws Exception {
    ServiceImpl service = new ServiceImpl(getBus(), null, SERVICE_NAME, null);
    service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING, "local://foobar");
    Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
    assertTrue(disp.getBinding() instanceof HTTPBinding);
}
Also used : ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) HTTPBinding(javax.xml.ws.http.HTTPBinding) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 2 with HTTPBinding

use of javax.xml.ws.http.HTTPBinding in project cxf by apache.

the class DispatchImpl method mapException.

private RuntimeException mapException(Exception ex) {
    if (ex instanceof Fault && ex.getCause() instanceof IOException) {
        throw new WebServiceException(ex.getMessage(), ex.getCause());
    }
    if (getBinding() instanceof HTTPBinding) {
        HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
        exception.initCause(ex);
        return exception;
    } else if (getBinding() instanceof SOAPBinding) {
        SOAPFault soapFault = null;
        try {
            soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding) getBinding(), ex);
        } catch (SOAPException e) {
        // ignore
        }
        if (soapFault == null) {
            return new WebServiceException(ex);
        }
        SOAPFaultException exception = new SOAPFaultException(soapFault);
        exception.initCause(ex);
        return exception;
    }
    return new WebServiceException(ex);
}
Also used : HTTPException(javax.xml.ws.http.HTTPException) WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPBinding(javax.xml.ws.soap.SOAPBinding) SOAPFault(javax.xml.soap.SOAPFault) Fault(org.apache.cxf.interceptor.Fault) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) HTTPBinding(javax.xml.ws.http.HTTPBinding)

Example 3 with HTTPBinding

use of javax.xml.ws.http.HTTPBinding in project cxf by apache.

the class JaxWsClientProxy method mapException.

Exception mapException(Method method, BindingOperationInfo boi, Exception ex) {
    if (method != null) {
        for (Class<?> excls : method.getExceptionTypes()) {
            if (excls.isInstance(ex)) {
                return ex;
            }
        }
    } else if (boi != null) {
        for (BindingFaultInfo fi : boi.getFaults()) {
            Class<?> c = fi.getFaultInfo().getProperty(Class.class.getName(), Class.class);
            if (c != null && c.isInstance(ex)) {
                return ex;
            }
        }
        if (ex instanceof IOException) {
            return ex;
        }
    }
    if (ex instanceof Fault && ex.getCause() instanceof IOException) {
        return new WebServiceException(ex.getMessage(), ex.getCause());
    }
    if (getBinding() instanceof HTTPBinding) {
        HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
        exception.initCause(ex);
        return exception;
    } else if (getBinding() instanceof SOAPBinding) {
        try {
            SOAPFault soapFault = createSoapFault((SOAPBinding) getBinding(), ex);
            if (soapFault == null) {
                throw new WebServiceException(ex);
            }
            SOAPFaultException exception = new SOAPFaultException(soapFault);
            if (ex instanceof Fault && ex.getCause() != null) {
                exception.initCause(ex.getCause());
            } else {
                exception.initCause(ex);
            }
            return exception;
        } catch (SOAPException e) {
            return new WebServiceException(ex);
        }
    }
    return new WebServiceException(ex);
}
Also used : HTTPException(javax.xml.ws.http.HTTPException) WebServiceException(javax.xml.ws.WebServiceException) SOAPException(javax.xml.soap.SOAPException) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Fault(org.apache.cxf.interceptor.Fault) SOAPFault(javax.xml.soap.SOAPFault) SoapFault(org.apache.cxf.binding.soap.SoapFault) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) HTTPBinding(javax.xml.ws.http.HTTPBinding)

Example 4 with HTTPBinding

use of javax.xml.ws.http.HTTPBinding in project cxf by apache.

the class EndpointImpl method getEndpointReference.

public EndpointReference getEndpointReference(Element... referenceParameters) {
    if (!isPublished()) {
        throw new WebServiceException(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_PUBLISHED", LOG).toString());
    }
    if (getBinding() instanceof HTTPBinding) {
        throw new UnsupportedOperationException(new org.apache.cxf.common.i18n.Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING", LOG).toString());
    }
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address(address);
    builder.serviceName(serviceName);
    builder.endpointName(endpointName);
    if (referenceParameters != null) {
        for (Element referenceParameter : referenceParameters) {
            builder.referenceParameter(referenceParameter);
        }
    }
    builder.wsdlDocumentLocation(wsdlLocation);
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(EndpointReferenceBuilder.class.getClassLoader());
        return builder.build();
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) WebServiceException(javax.xml.ws.WebServiceException) Message(org.apache.cxf.message.Message) Element(org.w3c.dom.Element) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) HTTPBinding(javax.xml.ws.http.HTTPBinding)

Aggregations

HTTPBinding (javax.xml.ws.http.HTTPBinding)4 WebServiceException (javax.xml.ws.WebServiceException)3 IOException (java.io.IOException)2 SOAPException (javax.xml.soap.SOAPException)2 SOAPFault (javax.xml.soap.SOAPFault)2 HTTPException (javax.xml.ws.http.HTTPException)2 SOAPBinding (javax.xml.ws.soap.SOAPBinding)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 Fault (org.apache.cxf.interceptor.Fault)2 Source (javax.xml.transform.Source)1 DOMSource (javax.xml.transform.dom.DOMSource)1 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)1 SoapFault (org.apache.cxf.binding.soap.SoapFault)1 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)1 ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)1 Message (org.apache.cxf.message.Message)1 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1