Search in sources :

Example 11 with ServiceImpl

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;
}
Also used : Field(java.lang.reflect.Field) WebServiceException(javax.xml.ws.WebServiceException) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) Service(javax.xml.ws.Service) WebServiceException(javax.xml.ws.WebServiceException)

Example 12 with ServiceImpl

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());
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Document(org.w3c.dom.Document) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 13 with ServiceImpl

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());
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) AddressingFeature(javax.xml.ws.soap.AddressingFeature) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Document(org.w3c.dom.Document) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 14 with ServiceImpl

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;
}
Also used : Bus(org.apache.cxf.Bus) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) Service(javax.xml.ws.Service)

Aggregations

ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)14 Test (org.junit.Test)11 Source (javax.xml.transform.Source)7 DOMSource (javax.xml.transform.dom.DOMSource)7 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)4 Number (org.apache.cxf.factory_pattern.Number)4 NumberFactory (org.apache.cxf.factory_pattern.NumberFactory)4 NumberFactoryService (org.apache.cxf.factory_pattern.NumberFactoryService)4 NumberService (org.apache.cxf.factory_pattern.NumberService)4 MessageReplayObserver (org.apache.cxf.jaxws.MessageReplayObserver)4 Document (org.w3c.dom.Document)4 DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 Service (javax.xml.ws.Service)2 Bus (org.apache.cxf.Bus)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 QName (javax.xml.namespace.QName)1 WebServiceException (javax.xml.ws.WebServiceException)1