Search in sources :

Example 16 with InterfaceInfo

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

the class ReflectionServiceFactoryTest method testWrappedBuild.

@Test
public void testWrappedBuild() throws Exception {
    Service service = createService(true);
    ServiceInfo si = service.getServiceInfos().get(0);
    InterfaceInfo intf = si.getInterface();
    assertEquals(4, intf.getOperations().size());
    String ns = si.getName().getNamespaceURI();
    OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello"));
    assertNotNull(sayHelloOp);
    assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart());
    List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertNotNull(messageParts.get(0).getXmlSchema());
    // test unwrapping
    assertTrue(sayHelloOp.isUnwrappedCapable());
    OperationInfo unwrappedOp = sayHelloOp.getUnwrappedOperation();
    assertEquals("sayHello", unwrappedOp.getInput().getName().getLocalPart());
    messageParts = unwrappedOp.getInput().getMessageParts();
    assertEquals(0, messageParts.size());
    // test output
    messageParts = sayHelloOp.getOutput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart());
    messageParts = unwrappedOp.getOutput().getMessageParts();
    assertEquals("sayHelloResponse", unwrappedOp.getOutput().getName().getLocalPart());
    assertEquals(1, messageParts.size());
    MessagePartInfo mpi = messageParts.get(0);
    assertEquals("return", mpi.getName().getLocalPart());
    assertEquals(String.class, mpi.getTypeClass());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 17 with InterfaceInfo

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

the class ProviderServiceFactoryTest method testFromWSDL.

@Test
public void testFromWSDL() throws Exception {
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(HWSoapMessageProvider.class);
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(implInfo);
    bean.setWsdlURL(resource.toString());
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(HWSoapMessageProvider.class);
    Service service = bean.create();
    assertTrue(service.getInvoker() instanceof JAXWSMethodInvoker);
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.setStart(false);
    ServerImpl server = (ServerImpl) svrFactory.create();
    assertTrue(server.getEndpoint().getService().getInvoker() instanceof JAXWSMethodInvoker);
    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof SoapBinding);
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) Bus(org.apache.cxf.Bus) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) URL(java.net.URL) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 18 with InterfaceInfo

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

the class JaxWsServiceFactoryBeanTest method testWrappedDocLit.

@Test
public void testWrappedDocLit() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
    Service service = bean.create();
    ServiceInfo si = service.getServiceInfos().get(0);
    InterfaceInfo intf = si.getInterface();
    assertEquals(4, intf.getOperations().size());
    String ns = si.getName().getNamespaceURI();
    assertEquals("http://apache.org/hello_world_doc_lit", ns);
    OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
    assertNotNull(greetMeOp);
    assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_doc_lit", greetMeOp.getInput().getName().getNamespaceURI());
    List<MessagePartInfo> messageParts = greetMeOp.getInput().getMessageParts();
    assertEquals(1, messageParts.size());
    MessagePartInfo inMessagePart = messageParts.get(0);
    assertEquals("http://apache.org/hello_world_doc_lit", inMessagePart.getName().getNamespaceURI());
    assertEquals("http://apache.org/hello_world_doc_lit/types", inMessagePart.getElementQName().getNamespaceURI());
    // test output
    messageParts = greetMeOp.getOutput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
    MessagePartInfo outMessagePart = messageParts.get(0);
    // assertEquals("result", outMessagePart.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
    assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName().getNamespaceURI());
    OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new QName(ns, "greetMeOneWay"));
    assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
    assertNull(greetMeOneWayOp.getOutput());
    Collection<SchemaInfo> schemas = si.getSchemas();
    assertEquals(1, schemas.size());
}
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) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 19 with InterfaceInfo

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

the class ProxyTest method testLastMessage.

@Test
public void testLastMessage() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Level.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    SourceSequence ss = control.createMock(SourceSequence.class);
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EasyMock.expect(ss.getTarget()).andReturn(null).anyTimes();
    control.replay();
    proxy.lastMessage(ss);
    control.verify();
    control.reset();
    org.apache.cxf.ws.addressing.EndpointReferenceType target = RMUtils.createAnonymousReference();
    EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
    control.replay();
    proxy.lastMessage(ss);
    control.verify();
    control.reset();
    target = RMUtils.createReference("http://localhost:9000/greeterPort");
    EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.CLOSE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
    expectInvokeWithContext(proxy, oi, null);
    control.replay();
    proxy.lastMessage(ss);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 20 with InterfaceInfo

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

the class ProxyTest method testAcknowledge.

@Test
public void testAcknowledge() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    DestinationSequence ds = control.createMock(DestinationSequence.class);
    EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EndpointReferenceType acksToEPR = control.createMock(EndpointReferenceType.class);
    EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR).anyTimes();
    AttributedURIType acksToURI = control.createMock(AttributedURIType.class);
    EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI).anyTimes();
    String acksToAddress = "acksTo";
    EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.SEQUENCE_ACK_QNAME)).andReturn(oi).anyTimes();
    expectInvoke(proxy, oi, null);
    control.replay();
    proxy.acknowledge(ds);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Endpoint(org.apache.cxf.endpoint.Endpoint) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Method(java.lang.reflect.Method) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) 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