use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class Stub method createPipeline.
/**
* Creates a new pipeline for the given port name.
*/
private Tube createPipeline(WSPortInfo portInfo, WSBinding binding) {
// Check all required WSDL extensions are understood
checkAllWSDLExtensionsUnderstood(portInfo, binding);
SEIModel seiModel = null;
Class sei = null;
if (portInfo instanceof SEIPortInfo) {
SEIPortInfo sp = (SEIPortInfo) portInfo;
seiModel = sp.model;
sei = sp.sei;
}
BindingID bindingId = portInfo.getBindingId();
TubelineAssembler assembler = TubelineAssemblerFactory.create(Thread.currentThread().getContextClassLoader(), bindingId, owner.getContainer());
if (assembler == null) {
// TODO: i18n
throw new WebServiceException("Unable to process bindingID=" + bindingId);
}
return assembler.createClient(new ClientTubeAssemblerContext(portInfo.getEndpointAddress(), portInfo.getPort(), this, binding, owner.getContainer(), ((BindingImpl) binding).createCodec(), seiModel, sei));
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class Stub method getWSEndpointReference.
@Override
public final WSEndpointReference getWSEndpointReference() {
if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
throw new java.lang.UnsupportedOperationException(ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding"));
}
if (endpointReference != null) {
return endpointReference;
}
String eprAddress = requestContext.getEndpointAddress().toString();
QName portTypeName = null;
String wsdlAddress = null;
List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<>();
if (wsdlPort != null) {
portTypeName = wsdlPort.getBinding().getPortTypeName();
wsdlAddress = eprAddress + "?wsdl";
// gather EPRExtensions specified in WSDL.
try {
WSEndpointReference wsdlEpr = wsdlPort.getEPR();
if (wsdlEpr != null) {
for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
wsdlEPRExtensions.add(new WSEPRExtension(XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
}
}
} catch (XMLStreamException ex) {
throw new WebServiceException(ex);
}
}
AddressingVersion av = AddressingVersion.W3C;
this.endpointReference = new WSEndpointReference(av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);
return this.endpointReference;
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class Stub method processAsync.
/**
* Passes a message through a {@link Tube}line for processing. The processing happens
* asynchronously and when the response is available, Fiber.CompletionCallback is
* called. The processing could happen on multiple threads.
*
* <p>
* Unlike {@link Tube} instances,
* this method is thread-safe and can be invoked from
* multiple threads concurrently.
*
* @param receiver The {@link Response} implementation
* @param request The message to be sent to the server
* @param requestContext The {@link RequestContext} when this invocation is originally scheduled.
* This must be the same object as {@link #requestContext} for synchronous
* invocations, but for asynchronous invocations, it needs to be a snapshot
* captured at the point of invocation, to correctly satisfy the spec requirement.
* @param completionCallback Once the processing is done, the callback is invoked.
*/
protected final void processAsync(AsyncResponseImpl<?> receiver, Packet request, RequestContext requestContext, final Fiber.CompletionCallback completionCallback) {
// fill in Packet
request.component = this;
configureRequestPacket(request, requestContext);
final Pool<Tube> pool = tubes;
if (pool == null) {
// TODO: i18n
throw new WebServiceException("close method has already been invoked");
}
final Fiber fiber = engine.createFiber();
configureFiber(fiber);
receiver.setCancelable(fiber);
// check race condition on cancel
if (receiver.isCancelled()) {
return;
}
FiberContextSwitchInterceptorFactory fcsif = owner.getSPI(FiberContextSwitchInterceptorFactory.class);
if (fcsif != null) {
fiber.addInterceptor(fcsif.create());
}
// then send it away!
final Tube tube = pool.take();
Fiber.CompletionCallback fiberCallback = new Fiber.CompletionCallback() {
@Override
public void onCompletion(@NotNull Packet response) {
pool.recycle(tube);
completionCallback.onCompletion(response);
}
@Override
public void onCompletion(@NotNull Throwable error) {
// let's not reuse tubes as they might be in a wrong state, so not
// calling pool.recycle()
completionCallback.onCompletion(error);
}
};
// Check for SyncStartForAsyncInvokeFeature
fiber.start(tube, request, fiberCallback, getBinding().isFeatureEnabled(SyncStartForAsyncFeature.class) && !requestContext.containsKey(PREVENT_SYNC_START_FOR_ASYNC_INVOKE));
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WSServiceDelegate method getPort.
@Override
public <T> T getPort(Class<T> portInterface, WebServiceFeature... features) {
// get the portType from SEI
QName portTypeName = RuntimeModeler.getPortTypeName(portInterface, getMetadadaReader(new WebServiceFeatureList(features), portInterface.getClassLoader()));
WSDLService tmpWsdlService = this.wsdlService;
if (tmpWsdlService == null) {
// assigning it to local variable and not setting it back to this.wsdlService intentionally
// as we don't want to include the service instance with information gathered from sei
tmpWsdlService = getWSDLModelfromSEI(portInterface);
// still null? throw error need wsdl metadata to create a proxy
if (tmpWsdlService == null) {
throw new WebServiceException(ProviderApiMessages.NO_WSDL_NO_PORT(portInterface.getName()));
}
}
// get the first port corresponding to the SEI
WSDLPort port = tmpWsdlService.getMatchingPort(portTypeName);
if (port == null) {
throw new WebServiceException(ClientMessages.UNDEFINED_PORT_TYPE(portTypeName));
}
QName portName = port.getName();
return getPort(portName, portInterface, features);
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WSServiceDelegate method getWSDLModelfromSEI.
private WSDLService getWSDLModelfromSEI(final Class sei) {
WebService ws = AccessController.doPrivileged(new PrivilegedAction<>() {
public WebService run() {
return (WebService) sei.getAnnotation(WebService.class);
}
});
if (ws == null || ws.wsdlLocation().equals(""))
return null;
String wsdlLocation = ws.wsdlLocation();
wsdlLocation = JAXWSUtils.absolutize(JAXWSUtils.getFileOrURLName(wsdlLocation));
Source wsdl = new StreamSource(wsdlLocation);
WSDLService service = null;
try {
URL url = wsdl.getSystemId() == null ? null : new URL(wsdl.getSystemId());
WSDLModel model = parseWSDL(url, wsdl, sei);
service = model.getService(this.serviceName);
if (service == null)
throw new WebServiceException(ClientMessages.INVALID_SERVICE_NAME(this.serviceName, buildNameList(model.getServices().keySet())));
} catch (MalformedURLException e) {
throw new WebServiceException(ClientMessages.INVALID_WSDL_URL(wsdl.getSystemId()));
}
return service;
}
Aggregations