Search in sources :

Example 36 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class ProviderServiceFactoryTest method testSAAJProviderCodeFirst.

@Test
public void testSAAJProviderCodeFirst() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(SAAJProvider.class);
    bean.setBus(getBus());
    bean.setInvoker(new JAXWSMethodInvoker(new SAAJProvider()));
    Service service = bean.create();
    assertEquals("SAAJProviderService", service.getName().getLocalPart());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);
    assertEquals(1, intf.getOperations().size());
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(getBus());
    svrFactory.setServiceFactory(bean);
    String address = "local://localhost:9000/test";
    svrFactory.setAddress(address);
    ServerImpl server = (ServerImpl) svrFactory.create();
    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof SoapBinding);
    SoapBindingInfo sb = (SoapBindingInfo) endpoint.getEndpointInfo().getBinding();
    assertEquals("document", sb.getStyle());
    assertEquals(false, bean.isWrapped());
    assertEquals(1, sb.getOperations().size());
    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml");
    addNamespace("j", "http://service.jaxws.cxf.apache.org/");
    assertValid("/s:Envelope/s:Body/j:sayHi", res);
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) Node(org.w3c.dom.Node) Service(org.apache.cxf.service.Service) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 37 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class JaxWsServiceFactoryBeanTest method testEndpoint.

@Test
public void testEndpoint() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    BeanInvoker invoker = new BeanInvoker(new GreeterImpl());
    bean.setInvoker(invoker);
    Service service = bean.create();
    String ns = "http://apache.org/hello_world_soap_http";
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals(ns, service.getName().getNamespaceURI());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    OperationInfo op = intf.getOperation(new QName(ns, "sayHi"));
    Class<?> wrapper = op.getInput().getMessageParts().get(0).getTypeClass();
    assertNotNull(wrapper);
    wrapper = op.getOutput().getMessageParts().get(0).getTypeClass();
    assertNotNull(wrapper);
    assertEquals(invoker, service.getInvoker());
    op = intf.getOperation(new QName(ns, "testDocLitFault"));
    Collection<FaultInfo> faults = op.getFaults();
    assertEquals(2, faults.size());
    FaultInfo f = op.getFault(new QName(ns, "BadRecordLitFault"));
    assertNotNull(f);
    Class<?> c = f.getProperty(Class.class.getName(), Class.class);
    assertNotNull(c);
    assertEquals(1, f.getMessageParts().size());
    MessagePartInfo mpi = f.getMessagePartByIndex(0);
    assertNotNull(mpi.getTypeClass());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) FaultInfo(org.apache.cxf.service.model.FaultInfo) QName(javax.xml.namespace.QName) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) URL(java.net.URL) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 38 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class JaxWsServiceFactoryBeanTest method testHolder.

@Test
public void testHolder() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(TestMtomImpl.class);
    Service service = bean.create();
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    OperationInfo op = intf.getOperation(new QName("http://cxf.apache.org/mime", "testXop"));
    assertNotNull(op);
    Iterator<MessagePartInfo> itr = op.getInput().getMessageParts().iterator();
    assertTrue(itr.hasNext());
    MessagePartInfo part = itr.next();
    assertEquals("testXop", part.getElementQName().getLocalPart());
    op = op.getUnwrappedOperation();
    assertNotNull(op);
    // test setup of input parts
    itr = op.getInput().getMessageParts().iterator();
    assertTrue(itr.hasNext());
    part = itr.next();
    assertEquals("name", part.getName().getLocalPart());
    assertEquals(String.class, part.getTypeClass());
/*
         * revisit, try to use other wsdl operation rewrite test in future
        assertTrue(itr.hasNext());
        part = itr.next();
        assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
        assertEquals(byte[].class, part.getTypeClass());

        assertFalse(itr.hasNext());

        // test output setup
        itr = op.getOutput().getMessageParts().iterator();

        assertTrue(itr.hasNext());
        part = itr.next();
        assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
        */
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 39 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class Proxy method createSequence.

public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo, boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context) throws RMException {
    this.sequenceContext = context;
    SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
    CreateSequenceType create = new CreateSequenceType();
    String address = sp.getAcksTo();
    EndpointReferenceType acksTo = null;
    if (null != address) {
        acksTo = RMUtils.createReference(address);
    } else {
        acksTo = defaultAcksTo;
    }
    create.setAcksTo(acksTo);
    Duration d = sp.getSequenceExpiration();
    if (null != d) {
        Expires expires = new Expires();
        expires.setValue(d);
        create.setExpires(expires);
    }
    if (sp.isIncludeOffer()) {
        OfferType offer = new OfferType();
        d = sp.getOfferedSequenceExpiration();
        if (null != d) {
            Expires expires = new Expires();
            expires.setValue(d);
            offer.setExpires(expires);
        }
        offer.setIdentifier(reliableEndpoint.getSource().generateSequenceIdentifier());
        offer.setEndpoint(acksTo);
        create.setOffer(offer);
        setOfferedIdentifier(offer);
    }
    InterfaceInfo ii = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface();
    EncoderDecoder codec = protocol.getCodec();
    RMConstants constants = codec.getConstants();
    final OperationInfo oi = isServer ? ii.getOperation(constants.getCreateSequenceOnewayOperationName()) : ii.getOperation(constants.getCreateSequenceOperationName());
    final Object send = codec.convertToSend(create);
    if (isServer) {
        LOG.fine("sending CreateSequenceRequest from server side");
        Runnable r = new Runnable() {

            public void run() {
                try {
                    invoke(oi, protocol, new Object[] { send }, null, exchange);
                } catch (RMException ex) {
                // already logged
                }
            }
        };
        Executor ex = reliableEndpoint.getApplicationEndpoint().getExecutor();
        if (ex == null) {
            ex = SynchronousExecutor.getInstance();
        }
        ex.execute(r);
        return null;
    }
    Object resp = invoke(oi, protocol, new Object[] { send }, context, exchange);
    return codec.convertReceivedCreateSequenceResponse(resp);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Duration(javax.xml.datatype.Duration) OfferType(org.apache.cxf.ws.rm.v200702.OfferType) Executor(java.util.concurrent.Executor) SynchronousExecutor(org.apache.cxf.workqueue.SynchronousExecutor) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) Expires(org.apache.cxf.ws.rm.v200702.Expires) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 40 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class MAPAggregatorTest method testGetReplyToUsingBaseAddress.

@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    final String localReplyTo = "/SoapContext/decoupled";
    final String decoupledEndpointBase = "http://localhost:8181/cxf";
    final String replyTo = decoupledEndpointBase + localReplyTo;
    ServiceInfo s = new ServiceInfo();
    Service svc = new ServiceImpl(s);
    EndpointInfo ei = new EndpointInfo();
    InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
    s.setInterface(ii);
    ii.addOperation(new QName("fooOp"));
    SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
    b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    ei.setBinding(b);
    ei.setAddress("http://nowhere.com/bar/foo");
    ei.setName(new QName("http://nowhere.com/port", "foo"));
    Bus bus = new ExtensionManagerBus();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    DestinationFactory df = control.createMock(DestinationFactory.class);
    Destination d = control.createMock(Destination.class);
    bus.setExtension(dfm, DestinationFactoryManager.class);
    EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
    EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
    EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
    Endpoint ep = new EndpointImpl(bus, svc, ei);
    exchange.put(Endpoint.class, ep);
    exchange.put(Bus.class, bus);
    exchange.setOutMessage(message);
    setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE);
    message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
    message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
    message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
    AddressingProperties maps = new AddressingProperties();
    AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(""));
    setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps);
    control.replay();
    aggregator.mediate(message, false);
    AddressingProperties props = (AddressingProperties) message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
    assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
    control.verify();
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) Message(org.apache.cxf.message.Message) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ServiceImpl(org.apache.cxf.service.ServiceImpl) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Service(org.apache.cxf.service.Service) Exchange(org.apache.cxf.message.Exchange) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)52 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)32 OperationInfo (org.apache.cxf.service.model.OperationInfo)30 QName (javax.xml.namespace.QName)25 Test (org.junit.Test)23 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)21 Service (org.apache.cxf.service.Service)20 Endpoint (org.apache.cxf.endpoint.Endpoint)19 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)17 BindingInfo (org.apache.cxf.service.model.BindingInfo)16 Method (java.lang.reflect.Method)15 ArrayList (java.util.ArrayList)10 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)9 Bus (org.apache.cxf.Bus)8 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)7 List (java.util.List)5 WebService (javax.jws.WebService)5 MessageInfo (org.apache.cxf.service.model.MessageInfo)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5