Search in sources :

Example 11 with InterfaceInfo

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

the class ProviderServiceFactoryTest method testSOAPBindingFromCode.

@Test
public void testSOAPBindingFromCode() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(SOAPSourcePayloadProvider.class);
    bean.setBus(getBus());
    bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider()));
    Service service = bean.create();
    assertEquals("SOAPSourcePayloadProviderService", 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();
    // See if our endpoint was created correctly
    assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
    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 12 with InterfaceInfo

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

the class MAPAggregatorTest method setUpBindingOperationInfo.

private BindingOperationInfo setUpBindingOperationInfo(String nsuri, String opreq, String opresp, String opfault, Method method) {
    ServiceInfo si = new ServiceInfo();
    InterfaceInfo iinf = new InterfaceInfo(si, new QName(nsuri, method.getDeclaringClass().getSimpleName()));
    OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
    opInfo.setProperty(Method.class.getName(), method);
    opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
    opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));
    FaultInfo finfo = opInfo.addFault(new QName(nsuri, opfault), new QName(nsuri, opfault));
    finfo.addMessagePart("fault");
    return new TestBindingOperationInfo(opInfo);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) QName(javax.xml.namespace.QName) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Method(java.lang.reflect.Method)

Example 13 with InterfaceInfo

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

the class PolicyAnnotationListener method addPolicies.

private void addPolicies(AbstractServiceFactoryBean factory, Endpoint endpoint, Class<?> cls, List<Policy> list, Policy.Placement defaultPlace) {
    ListIterator<Policy> it = list.listIterator();
    InterfaceInfo inf = endpoint.getEndpointInfo().getInterface();
    BindingInfo binf = endpoint.getBinding().getBindingInfo();
    ServiceInfo si = endpoint.getService().getServiceInfos().get(0);
    while (it.hasNext()) {
        Policy p = it.next();
        Policy.Placement place = p.placement();
        if (place == Policy.Placement.DEFAULT) {
            place = defaultPlace;
        }
        switch(place) {
            case PORT_TYPE:
                {
                    addPolicy(inf, si, p, cls, inf.getName().getLocalPart() + "PortTypePolicy");
                    it.remove();
                    break;
                }
            case BINDING:
                {
                    addPolicy(binf, si, p, cls, binf.getName().getLocalPart() + "BindingPolicy");
                    it.remove();
                    break;
                }
            case SERVICE:
                {
                    addPolicy(si, si, p, cls, si.getName().getLocalPart() + "ServicePolicy");
                    it.remove();
                    break;
                }
            case SERVICE_PORT:
                {
                    addPolicy(endpoint.getEndpointInfo(), si, p, cls, endpoint.getEndpointInfo().getName().getLocalPart() + "PortPolicy");
                    it.remove();
                    break;
                }
            default:
        }
    }
}
Also used : Policy(org.apache.cxf.annotations.Policy) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 14 with InterfaceInfo

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

the class URIDomainExpressionTest method mockInfoObjects.

private void mockInfoObjects() {
    si = control.createMock(ServiceInfo.class);
    ei = control.createMock(EndpointInfo.class);
    boi = control.createMock(BindingOperationInfo.class);
    bmi = control.createMock(BindingMessageInfo.class);
    bfi = control.createMock(BindingFaultInfo.class);
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getTargetNamespace()).andReturn(TARGET_NAMESPACE).anyTimes();
    EasyMock.expect(si.getName()).andReturn(SERVICE_QNAME).anyTimes();
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    EasyMock.expect(ii.getName()).andReturn(INTERFACE_QNAME).anyTimes();
    EasyMock.expect(ei.getName()).andReturn(PORT_QNAME).anyTimes();
    EasyMock.expect(ei.getService()).andReturn(si).anyTimes();
    BindingInfo bi = control.createMock(BindingInfo.class);
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(boi.getName()).andReturn(OPERATION_QNAME).anyTimes();
    EasyMock.expect(boi.getBinding()).andReturn(bi).anyTimes();
    EasyMock.expect(bi.getName()).andReturn(BINDING_QNAME).anyTimes();
    EasyMock.expect(boi.getOperationInfo()).andReturn(oi).anyTimes();
    EasyMock.expect(oi.getInterface()).andReturn(ii).anyTimes();
    EasyMock.expect(oi.getName()).andReturn(OPERATION_QNAME).anyTimes();
    mi = control.createMock(MessageInfo.class);
    EasyMock.expect(bmi.getMessageInfo()).andReturn(mi).anyTimes();
    EasyMock.expect(mi.getName()).andReturn(MESSAGE_QNAME).anyTimes();
    EasyMock.expect(bmi.getBindingOperation()).andReturn(boi).anyTimes();
    FaultInfo fi = control.createMock(FaultInfo.class);
    bfi = control.createMock(BindingFaultInfo.class);
    EasyMock.expect(bfi.getBindingOperation()).andReturn(boi).anyTimes();
    EasyMock.expect(bfi.getFaultInfo()).andReturn(fi).anyTimes();
    EasyMock.expect(fi.getFaultName()).andReturn(FAULT_QNAME).anyTimes();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 15 with InterfaceInfo

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

the class CorbaStreamInInterceptor method handleRequest.

private void handleRequest(Message msg) {
    ORB orb;
    ServiceInfo service;
    CorbaDestination destination;
    if (msg.getDestination() != null) {
        destination = (CorbaDestination) msg.getDestination();
    } else {
        destination = (CorbaDestination) msg.getExchange().getDestination();
    }
    service = destination.getBindingInfo().getService();
    CorbaMessage message = (CorbaMessage) msg;
    Exchange exchange = message.getExchange();
    CorbaTypeMap typeMap = message.getCorbaTypeMap();
    BindingInfo bInfo = destination.getBindingInfo();
    InterfaceInfo info = bInfo.getInterface();
    String opName = exchange.get(String.class);
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    OperationType opType = null;
    BindingOperationInfo bopInfo = null;
    QName opQName = null;
    while (i.hasNext()) {
        bopInfo = i.next();
        if (bopInfo.getName().getLocalPart().equals(opName)) {
            opType = bopInfo.getExtensor(OperationType.class);
            opQName = bopInfo.getName();
            break;
        }
    }
    if (opType == null) {
        throw new RuntimeException("Couldn't find the binding operation for " + opName);
    }
    orb = exchange.get(ORB.class);
    ServerRequest request = exchange.get(ServerRequest.class);
    NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
    request.arguments(list);
    message.setList(list);
    HandlerIterator paramIterator = new HandlerIterator(message, true);
    CorbaTypeEventProducer eventProducer = null;
    BindingMessageInfo msgInfo = bopInfo.getInput();
    boolean wrap = false;
    if (bopInfo.isUnwrappedCapable()) {
        wrap = true;
    }
    if (wrap) {
        // wrapper element around our args
        QName wrapperElementQName = msgInfo.getMessageInfo().getName();
        eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
    } else {
        eventProducer = new ParameterEventProducer(paramIterator, service, orb);
    }
    CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
    message.setContent(XMLStreamReader.class, reader);
}
Also used : CorbaTypeMap(org.apache.cxf.binding.corba.CorbaTypeMap) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) WrappedParameterSequenceEventProducer(org.apache.cxf.binding.corba.types.WrappedParameterSequenceEventProducer) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) QName(javax.xml.namespace.QName) HandlerIterator(org.apache.cxf.binding.corba.types.HandlerIterator) CorbaStreamReader(org.apache.cxf.binding.corba.runtime.CorbaStreamReader) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Exchange(org.apache.cxf.message.Exchange) ParameterEventProducer(org.apache.cxf.binding.corba.types.ParameterEventProducer) CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) CorbaTypeEventProducer(org.apache.cxf.binding.corba.types.CorbaTypeEventProducer) ServerRequest(org.omg.CORBA.ServerRequest) NVList(org.omg.CORBA.NVList) ORB(org.omg.CORBA.ORB)

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