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);
}
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);
}
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);
}
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);
}
}
Aggregations