@Override protected ClientProxy clientClientProxy(Client c) { JaxWsClientProxy cp = new JaxWsClientProxy(c, ((JaxWsEndpointImpl)c.getEndpoint()).getJaxwsBinding()); cp.getRequestContext().putAll(this.getProperties()); buildHandlerChain(cp); return cp; }
Endpoint endpoint = getClient().getEndpoint(); String address = endpoint.getEndpointInfo().getAddress(); MethodDispatcher dispatcher = (MethodDispatcher)endpoint.getService().get( boolean isAsync = isAsync(method); result = invokeAsync(method, oi, params); } else { result = invokeSync(method, oi, params); throw mapException(method, oi, ex); } finally { if (addressChanged(address)) { setupEndpointAddressContext(getClient().getEndpoint()); return adjustObject(result);
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);
public JaxWsClientProxy(Client c, Binding b) { super(c); this.binding = b; setupEndpointAddressContext(getClient().getEndpoint()); this.builder = new EndpointReferenceBuilder((JaxWsEndpointImpl)getClient().getEndpoint()); } public void close() throws IOException {
public Map<String, Object> getResponseContext() { if (client == null) { throw new IllegalStateException("The client has been closed."); } return new WrappedMessageContext(this.getClient().getResponseContext(), null, Scope.APPLICATION); }
InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding()); Object obj = Proxy .newProxyInstance(serviceEndpointInterface.getClassLoader(),
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); }
private void setupEndpointAddressContext(Endpoint endpoint) { // NOTE for jms transport the address would be null if (null != endpoint && null != endpoint.getEndpointInfo().getAddress()) { getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint.getEndpointInfo().getAddress()); } }
private void buildHandlerChain(JaxWsClientProxy cp) { AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(); JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean)getServiceFactory(); @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<>(handlers); if (loadHandlers) { chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), this.getBindingId())); } if (!chain.isEmpty()) { ResourceManager resourceManager = getBus().getExtension(ResourceManager.class); List<ResourceResolver> resolvers = resourceManager.getResourceResolvers(); resourceManager = new DefaultResourceManager(resolvers); resourceManager.addResourceResolver(new WebServiceContextResourceResolver()); ResourceInjector injector = new ResourceInjector(resourceManager); for (Handler<?> h : chain) { if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) { injector.inject(h, getServiceClass()); injector.construct(h, getServiceClass()); } else { injector.inject(h); injector.construct(h); } } } cp.getBinding().setHandlerChain(chain); }
public Map<String, Object> getRequestContext() { if (client == null) { throw new IllegalStateException("The client has been closed."); } return new WrappedMessageContext(this.getClient().getRequestContext(), null, Scope.APPLICATION); } public Map<String, Object> getResponseContext() {
public JaxWsClientProxy(Client c, Binding b) { super(c); this.binding = b; setupEndpointAddressContext(getClient().getEndpoint()); this.builder = new EndpointReferenceBuilder((JaxWsEndpointImpl)getClient().getEndpoint()); } public void close() throws IOException {
private void checkError() { if (error != null) { if (getBinding() instanceof SOAPBinding) { SOAPFault soapFault = null; try { soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(), new Exception(error.toString())); } catch (SOAPException e) { //ignore } if (soapFault != null) { throw new SOAPFaultException(soapFault); } } else if (getBinding() instanceof HTTPBinding) { HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR); exception.initCause(new Exception(error.toString())); throw exception; } throw new WebServiceException(error.toString()); } } private RuntimeException mapException(Exception ex) {
private void setupEndpointAddressContext(Endpoint endpoint) { // NOTE for jms transport the address would be null if (null != endpoint && null != endpoint.getEndpointInfo().getAddress()) { getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint.getEndpointInfo().getAddress()); } }
private void buildHandlerChain(JaxWsClientProxy cp) { AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(); JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean)getServiceFactory(); @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<>(handlers); if (loadHandlers) { chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), this.getBindingId())); } if (!chain.isEmpty()) { ResourceManager resourceManager = getBus().getExtension(ResourceManager.class); List<ResourceResolver> resolvers = resourceManager.getResourceResolvers(); resourceManager = new DefaultResourceManager(resolvers); resourceManager.addResourceResolver(new WebServiceContextResourceResolver()); ResourceInjector injector = new ResourceInjector(resourceManager); for (Handler<?> h : chain) { if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) { injector.inject(h, getServiceClass()); injector.construct(h, getServiceClass()); } else { injector.inject(h); injector.construct(h); } } } cp.getBinding().setHandlerChain(chain); }
Endpoint endpoint = getClient().getEndpoint(); String address = endpoint.getEndpointInfo().getAddress(); MethodDispatcher dispatcher = (MethodDispatcher)endpoint.getService().get( boolean isAsync = isAsync(method); result = invokeAsync(method, oi, params); } else { result = invokeSync(method, oi, params); throw mapException(method, oi, ex); } finally { if (addressChanged(address)) { setupEndpointAddressContext(getClient().getEndpoint()); return adjustObject(result);
@Override protected ClientProxy clientClientProxy(Client c) { JaxWsClientProxy cp = new JaxWsClientProxy(c, ((JaxWsEndpointImpl)c.getEndpoint()).getJaxwsBinding()); cp.getRequestContext().putAll(this.getProperties()); buildHandlerChain(cp); return cp; }
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);
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); }
@SuppressWarnings("unchecked") private Object invokeAsync(Method method, final BindingOperationInfo oi, Object[] params) throws Exception { client.setExecutor(getClient().getEndpoint().getExecutor()); AsyncHandler<Object> handler; if (params.length > 0 && params[params.length - 1] instanceof AsyncHandler) { handler = (AsyncHandler<Object>)params[params.length - 1]; Object[] newParams = new Object[params.length - 1]; for (int i = 0; i < newParams.length; i++) { newParams[i] = params[i]; } params = newParams; } else { handler = null; } ClientCallback callback = new JaxwsClientCallback<Object>(handler, this) { @Override protected Throwable mapThrowable(Throwable t) { if (t instanceof Exception) { t = mapException(null, oi, (Exception)t); } return t; } }; Response<Object> ret = new JaxwsResponseCallback<>(callback); client.invoke(callback, oi, params); return ret; }