use of org.apache.cxf.jaxws.ServiceImpl in project cxf by apache.
the class ServiceDelegateAccessor method get.
/**
* Get the delegate reference from the Service private field. This method
* uses Field.setAccessible() which, in the presence of a SecurityManager,
* requires the suppressAccessChecks permission
*
* @param service the taraget service
* @return the implementation delegate
* @throws WebServiceException if access to the field fails for any reason
*/
public static ServiceImpl get(Service service) {
ServiceImpl delegate = null;
try {
Field delegateField = Service.class.getDeclaredField(DELEGATE_FIELD_NAME);
ReflectionUtil.setAccessible(delegateField);
delegate = (ServiceImpl) delegateField.get(service);
} catch (Exception e) {
try {
Field delegateField = Service.class.getDeclaredField(DELEGATE_FIELD_NAME2);
ReflectionUtil.setAccessible(delegateField);
delegate = (ServiceImpl) delegateField.get(service);
} catch (Exception e2) {
WebServiceException wse = new WebServiceException("Failed to access Field named " + DELEGATE_FIELD_NAME + " of Service instance " + service, e);
LOG.log(Level.SEVERE, e.getMessage(), e);
throw wse;
}
}
return delegate;
}
use of org.apache.cxf.jaxws.ServiceImpl in project cxf by apache.
the class DispatchOpTest method testResolveOperationWithSource.
@Test
public void testResolveOperationWithSource() throws Exception {
ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource(wsdlResource), serviceName, null);
Dispatch<Source> disp = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
disp.getRequestContext().put(MessageContext.WSDL_OPERATION, operationName);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
d.setMessageObserver(new MessageReplayObserver(responseResource));
BindingOperationVerifier bov = new BindingOperationVerifier();
((DispatchImpl<?>) disp).getClient().getOutInterceptors().add(bov);
Document doc = StaxUtils.read(getResourceAsStream(requestResource));
DOMSource source = new DOMSource(doc);
Source res = disp.invoke(source);
assertNotNull(res);
BindingOperationInfo boi = bov.getBindingOperationInfo();
assertNotNull(boi);
assertEquals(operationName, boi.getName());
}
use of org.apache.cxf.jaxws.ServiceImpl in project cxf by apache.
the class DispatchOpTest method testResolveOperationWithSourceAndWSA.
@Test
public void testResolveOperationWithSourceAndWSA() throws Exception {
ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource(wsdlResource), serviceName, null, new AddressingFeature());
Dispatch<Source> disp = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
disp.getRequestContext().put(MessageContext.WSDL_OPERATION, operationName);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
d.setMessageObserver(new MessageReplayObserver(responseResource));
BindingOperationVerifier bov = new BindingOperationVerifier();
((DispatchImpl<?>) disp).getClient().getOutInterceptors().add(bov);
Document doc = StaxUtils.read(getResourceAsStream(requestResource));
DOMSource source = new DOMSource(doc);
Source res = disp.invoke(source);
assertNotNull(res);
BindingOperationInfo boi = bov.getBindingOperationInfo();
assertNotNull(boi);
assertEquals(operationName, boi.getName());
}
use of org.apache.cxf.jaxws.ServiceImpl in project cxf by apache.
the class WSDiscoveryClient method getService.
private synchronized ServiceImpl getService() {
if (service == null) {
Bus b = BusFactory.getAndSetThreadDefaultBus(bus);
try {
service = new ServiceImpl(bus, null, version.getServiceName(), Service.class);
service.addPort(version.getServiceName(), soapVersion, address);
} finally {
BusFactory.setThreadDefaultBus(b);
}
}
return service;
}
Aggregations