org.apache.cxf.service.model.BindingInfo Java Examples

The following examples show how to use org.apache.cxf.service.model.BindingInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void processBindings(JavaModel model) {
    for (BindingInfo binding : service.getBindings()) {
        bindingType = getBindingType(binding);

        if (bindingType == null) {
            org.apache.cxf.common.i18n.Message msg =
                new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL",
                                                       LOG,
                                                       binding.getName());
            throw new ToolException(msg);
        }

        Collection<BindingOperationInfo> operations = binding.getOperations();
        for (BindingOperationInfo bop : operations) {
            processOperation(model, bop, binding);
        }
    }
}
 
Example #2
Source File: SOAPLoggingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSoap() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    ExchangeImpl exchange = new ExchangeImpl();
    ServiceInfo service = new ServiceInfo();
    BindingInfo info = new BindingInfo(service, "bindingId");
    SoapBinding value = new SoapBinding(info);
    exchange.put(Binding.class, value);
    OperationInfo opInfo = new OperationInfo();
    opInfo.setName(new QName("http://my", "Operation"));
    BindingOperationInfo boi = new BindingOperationInfo(info, opInfo);
    exchange.put(BindingOperationInfo.class, boi);
    message.setExchange(exchange);
    LogEvent event = mapper.map(message);
    Assert.assertEquals("{http://my}Operation", event.getOperationName());
}
 
Example #3
Source File: RPCInInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BindingOperationInfo getOperation(Message message, QName opName) {
    BindingOperationInfo bop = ServiceModelUtil.getOperation(message.getExchange(), opName);
    if (bop == null) {
        Endpoint ep = message.getExchange().getEndpoint();
        if (ep == null) {
            return null;
        }
        BindingInfo service = ep.getEndpointInfo().getBinding();
        boolean output = !isRequestor(message);
        for (BindingOperationInfo info : service.getOperations()) {
            if (info.getName().getLocalPart().equals(opName.getLocalPart())) {
                SoapBody body = null;
                if (output) {
                    body = info.getOutput().getExtensor(SoapBody.class);
                } else {
                    body = info.getInput().getExtensor(SoapBody.class);
                }
                if (body != null
                    && opName.getNamespaceURI().equals(body.getNamespaceURI())) {
                    return info;
                }
            }
        }
    }
    return bop;
}
 
Example #4
Source File: DispatchImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addInvokeOperation(QName operationName, boolean oneWay) {
    ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();

    OperationInfo invokeOpInfo = info.getInterface()
                   .getOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);

    OperationInfo opInfo = info.getInterface().addOperation(operationName);
    opInfo.setInput(invokeOpInfo.getInputName(), invokeOpInfo.getInput());

    if (!oneWay) {
        opInfo.setOutput(invokeOpInfo.getOutputName(), invokeOpInfo.getOutput());
    }

    for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
        BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
        bind.addOperation(bo);
    }
}
 
Example #5
Source File: AbstractOutDatabindingInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) {
    /**
     * Yes, all this code is EXTREMELY ugly. But it gives about a 60-70% performance
     * boost with the JAXB RI, so its worth it.
     */

    if (s == null) {
        return false;
    }

    String enc = (String)m.get(Message.ENCODING);
    return "org.apache.cxf.binding.soap.model.SoapBindingInfo".equals(info.getClass().getName())
        && "org.apache.cxf.jaxb.JAXBDataBinding".equals(s.getDataBinding().getClass().getName())
        && !MessageUtils.isDOMPresent(m)
        && (enc == null || StandardCharsets.UTF_8.name().equals(enc));
}
 
Example #6
Source File: MustUnderstandInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleMessageWithSoapHeader11Param() throws Exception {
    prepareSoapMessage("test-soap-header.xml");
    dsi.getUnderstoodHeaders().add(RESERVATION);

    ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-header.wsdl")
        .toString());

    BindingInfo binding = serviceInfo.getBinding(new QName("http://org.apache.cxf/headers",
                                                           "headerTesterSOAPBinding"));
    BindingOperationInfo bop = binding.getOperation(new QName("http://org.apache.cxf/headers",
                                                              "inHeader"));
    soapMessage.getExchange().put(BindingOperationInfo.class, bop);

    soapMessage.getInterceptorChain().doIntercept(soapMessage);
    assertTrue("DummaySoapInterceptor getRoles has been called!", dsi.isCalledGetRoles());
    assertTrue("DummaySoapInterceptor getUnderstood has been called!", dsi.isCalledGetUnderstood());
}
 
Example #7
Source File: SoapBindingFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
public BindingInfo createBindingInfo(ServiceInfo service, javax.wsdl.Binding binding, String ns) {
    SoapBindingInfo bi = new SoapBindingInfo(service, ns);
    // Copy all the extensors
    initializeBindingInfo(service, binding, bi);

    SoapBinding wSoapBinding
        = SOAPBindingUtil.getSoapBinding(bi.getExtensors(ExtensibilityElement.class));


    bi.setTransportURI(wSoapBinding.getTransportURI());
    bi.setStyle(wSoapBinding.getStyle());

    for (BindingOperationInfo boi : bi.getOperations()) {
        initializeBindingOperation(bi, boi);
    }

    return bi;
}
 
Example #8
Source File: CodeFirstTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Definition createService(boolean wrapped) throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();

    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(Hello.class);
    bean.setWrapped(wrapped);

    Service service = bean.create();

    InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
    assertEquals(5, i.getOperations().size());

    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.setAddress(address);
    svrFactory.create();

    Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings();
    assertEquals(1, bindings.size());

    ServiceWSDLBuilder wsdlBuilder =
        new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
    return wsdlBuilder.build();
}
 
Example #9
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testBare() throws Exception {
    setUpWSDL(BARE_WSDL_PATH, 0);
    BindingInfo bindingInfo = null;
    bindingInfo = serviceInfo.getBindings().iterator().next();
    Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
    assertNotNull(bindingOperationInfos);
    assertEquals(bindingOperationInfos.size(), 1);
    LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    BindingOperationInfo greetMe = bindingInfo.getOperation(name);
    assertNotNull(greetMe);
    assertEquals("greetMe OperationInfo name error", greetMe.getName(), name);
    assertFalse("greetMe should be a Unwrapped operation ", greetMe.isUnwrappedCapable());

    assertNotNull(serviceInfo.getXmlSchemaCollection());
    control.verify();
}
 
Example #10
Source File: ServiceModelVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void walk() {
    begin(serviceInfo);
    begin(serviceInfo.getInterface());

    for (OperationInfo o : serviceInfo.getInterface().getOperations()) {
        begin(o);

        visitOperation(o);

        end(o);
    }

    end(serviceInfo.getInterface());
    for (EndpointInfo endpointInfo : serviceInfo.getEndpoints()) {
        begin(endpointInfo);
        end(endpointInfo);
    }
    for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
        begin(bindingInfo);
        end(bindingInfo);
    }
    end(serviceInfo);
}
 
Example #11
Source File: LoggingOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private CachedOutputStream handleAndGetCachedOutputStream(LoggingOutInterceptor interceptor) {
    interceptor.setPrintWriter(new PrintWriter(new ByteArrayOutputStream()));

    Endpoint endpoint = control.createMock(Endpoint.class);
    EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
    BindingInfo bindingInfo = control.createMock(BindingInfo.class);
    EasyMock.expect(endpointInfo.getBinding()).andReturn(bindingInfo).anyTimes();
    EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(bindingInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
    control.replay();

    Message message = new MessageImpl();
    ExchangeImpl exchange = new ExchangeImpl();
    message.setExchange(exchange);
    exchange.put(Endpoint.class, endpoint);

    message.put(Message.CONTENT_TYPE, "application/xml");
    message.setContent(OutputStream.class, new ByteArrayOutputStream());
    interceptor.handleMessage(message);
    OutputStream os = message.getContent(OutputStream.class);
    assertTrue(os instanceof CachedOutputStream);
    return (CachedOutputStream)os;
}
 
Example #12
Source File: AbstractSTSTokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
static MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
    MessageImpl message = new MessageImpl();
    message.put(SecurityConstants.STS_CLIENT, stsClient);
    message.put(Message.ENDPOINT_ADDRESS, serviceAddress);

    Exchange exchange = new ExchangeImpl();
    ServiceInfo si = new ServiceInfo();
    si.setName(new QName("http://www.apache.org", "ServiceName"));
    Service s = new ServiceImpl(si);
    EndpointInfo ei = new EndpointInfo();
    ei.setName(new QName("http://www.apache.org", "EndpointName"));
    Endpoint ep = new EndpointImpl(bus, s, ei);
    ei.setBinding(new BindingInfo(si, null));
    message.setExchange(exchange);
    exchange.put(Endpoint.class, ep);
    return message;
}
 
Example #13
Source File: RMEndpointTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetUsingAddressing() {
    EndpointInfo ei = null;
    control.replay();
    assertNull(rme.getUsingAddressing(ei));
    control.verify();

    control.reset();
    ExtensibilityElement ua = control.createMock(ExtensibilityElement.class);
    ei = control.createMock(EndpointInfo.class);
    List<ExtensibilityElement> noExts = new ArrayList<>();
    List<ExtensibilityElement> exts = new ArrayList<>();
    exts.add(ua);
    EasyMock.expect(ei.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(ei.getBinding()).andReturn(bi).times(2);
    EasyMock.expect(bi.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(ei.getService()).andReturn(si).times(2);
    EasyMock.expect(si.getExtensors(ExtensibilityElement.class)).andReturn(exts);
    EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME);
    control.replay();
    assertSame(ua, rme.getUsingAddressing(ei));
}
 
Example #14
Source File: ExchangeImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public <T> T get(Class<T> key) {
    T t = key.cast(get(key.getName()));

    if (t == null) {
        if (key == Bus.class) {
            t = key.cast(bus);
        } else if (key == OperationInfo.class && bindingOp != null) {
            t = key.cast(bindingOp.getOperationInfo());
        } else if (key == BindingOperationInfo.class) {
            t = key.cast(bindingOp);
        } else if (key == Endpoint.class) {
            t = key.cast(endpoint);
        } else if (key == Service.class) {
            t = key.cast(service);
        } else if (key == Binding.class) {
            t = key.cast(binding);
        } else if (key == BindingInfo.class && binding != null) {
            t = key.cast(binding.getBindingInfo());
        } else if (key == InterfaceInfo.class && endpoint != null) {
            t = key.cast(endpoint.getEndpointInfo().getService().getInterface());
        } else if (key == ServiceInfo.class && endpoint != null) {
            t = key.cast(endpoint.getEndpointInfo().getService());
        }
    }
    return t;
}
 
Example #15
Source File: EndpointImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
final void createBinding(BindingInfo bi) throws EndpointException {
    if (null != bi) {
        String namespace = bi.getBindingId();
        BindingFactory bf = null;
        try {
            bf = bus.getExtension(BindingFactoryManager.class).getBindingFactory(namespace);
            if (null == bf) {
                Message msg = new Message("NO_BINDING_FACTORY", BUNDLE, namespace);
                throw new EndpointException(msg);
            }
            binding = bf.createBinding(bi);
        } catch (BusException ex) {
            throw new EndpointException(ex);
        }
    }
}
 
Example #16
Source File: ProtobufClient.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
protected void setExchangeProperties(Exchange exchange, Endpoint ep) {
    if (ep != null) {
        exchange.put(Endpoint.class, ep);
        exchange.put(Service.class, ep.getService());
        if (ep.getEndpointInfo().getService() != null) {
            exchange.put(ServiceInfo.class, ep.getEndpointInfo()
                    .getService());
            exchange.put(InterfaceInfo.class, ep.getEndpointInfo()
                    .getService().getInterface());
        }
        exchange.put(Binding.class, ep.getBinding());
        exchange.put(BindingInfo.class, ep.getEndpointInfo().getBinding());
    }

    exchange.put(MessageObserver.class, this);
    exchange.put(Bus.class, getBus());
}
 
Example #17
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected NVList prepareArguments(CorbaMessage corbaMsg,
                                  InterfaceInfo info,
                                  OperationType opType,
                                  QName opQName,
                                  CorbaTypeMap typeMap,
                                  CorbaDestination destination,
                                  ServiceInfo service) {
    BindingInfo bInfo = destination.getBindingInfo();
    EndpointInfo eptInfo = destination.getEndPointInfo();
    BindingOperationInfo bOpInfo = bInfo.getOperation(opQName);
    OperationInfo opInfo = bOpInfo.getOperationInfo();
    Exchange exg = corbaMsg.getExchange();
    exg.put(BindingInfo.class, bInfo);
    exg.put(InterfaceInfo.class, info);
    exg.put(EndpointInfo.class, eptInfo);
    exg.put(EndpointReferenceType.class, destination.getAddress());
    exg.put(ServiceInfo.class, service);
    exg.put(BindingOperationInfo.class, bOpInfo);
    exg.put(OperationInfo.class, opInfo);
    exg.put(MessageInfo.class, opInfo.getInput());
    exg.put(String.class, opQName.getLocalPart());
    exg.setInMessage(corbaMsg);

    corbaMsg.put(MessageInfo.class, opInfo.getInput());

    List<ParamType> paramTypes = opType.getParam();
    CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
    return prepareDIIArgsList(corbaMsg, bOpInfo,
                              arguments, paramTypes,
                              typeMap,
                              exg.get(ORB.class), service);
}
 
Example #18
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpUsingAddressing(Message message,
                                  Exchange exchange,
                                  boolean usingAddressing) {
    setUpMessageExchange(message, exchange);
    Endpoint endpoint = control.createMock(Endpoint.class);
    endpoint.getOutInterceptors();
    EasyMock.expectLastCall().andReturn(new ArrayList<Interceptor<? extends Message>>()).anyTimes();

    setUpExchangeGet(exchange, Endpoint.class, endpoint);
    EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
    endpoint.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(endpointInfo).anyTimes();
    List<ExtensibilityElement> endpointExts =
        new ArrayList<>();
    endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(endpointExts).anyTimes();
    BindingInfo bindingInfo = control.createMock(BindingInfo.class);
    endpointInfo.getBinding();
    EasyMock.expectLastCall().andReturn(bindingInfo).anyTimes();
    bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
    ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
    endpointInfo.getService();
    EasyMock.expectLastCall().andReturn(serviceInfo).anyTimes();
    serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
    ExtensibilityElement ext =
        control.createMock(ExtensibilityElement.class);
    if (usingAddressing) {
        QName elementType = usingAddressing
            ? Names.WSAW_USING_ADDRESSING_QNAME
            : new QName(SOAP_NAMESPACE, "encodingStyle");
        ext.getElementType();
        EasyMock.expectLastCall().andReturn(elementType).anyTimes();
        endpointExts.add(ext);
    }
}
 
Example #19
Source File: ClientImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private EndpointInfo findEndpoint(Service svc, QName port) {
    if (port != null) {
        EndpointInfo epfo = svc.getEndpointInfo(port);
        if (epfo == null) {
            throw new IllegalArgumentException("The service " + svc.getName()
                                               + " does not have an endpoint " + port + ".");
        }
        return epfo;
    }
    
    for (ServiceInfo svcfo : svc.getServiceInfos()) {
        for (EndpointInfo e : svcfo.getEndpoints()) {
            BindingInfo bfo = e.getBinding();
            String bid = bfo.getBindingId();
            if ("http://schemas.xmlsoap.org/wsdl/soap/".equals(bid)
                || "http://schemas.xmlsoap.org/wsdl/soap12/".equals(bid)) {
                for (Object o : bfo.getExtensors().get()) {
                    try {
                        String s = (String)o.getClass().getMethod("getTransportURI").invoke(o);
                        if (s != null && s.endsWith("http")) {
                            return e;
                        }
                    } catch (Throwable t) {
                        //ignore
                    }
                }
            }
        }
    }
    throw new UnsupportedOperationException(
         "Only document-style SOAP 1.1 and 1.2 http are supported "
         + "for auto-selection of endpoint; none were found.");
}
 
Example #20
Source File: RPCInInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();
    ServiceInfo si = getMockedServiceModel(this.getClass()
                                           .getResource("/wsdl_soap/hello_world_rpc_lit.wsdl")
            .toString());
    BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
    BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
    boi.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
    boi.getOperationInfo().getInput().getMessagePartByIndex(0).setIndex(1);
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
    soapMessage.getExchange().put(BindingOperationInfo.class, boi);

    control.reset();
    Service service = control.createMock(Service.class);
    JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
    service.getDataBinding();
    EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
    service.getServiceInfos();
    List<ServiceInfo> list = Arrays.asList(si);
    EasyMock.expectLastCall().andReturn(list).anyTimes();
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();

    soapMessage.getExchange().put(Service.class, service);
    soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    control.replay();
}
 
Example #21
Source File: SoapTransportFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Destination getDestination(EndpointInfo ei, Bus bus) throws IOException {
    String address = ei.getAddress();
    BindingInfo bi = ei.getBinding();
    String transId = ei.getTransportId();
    if (bi instanceof SoapBindingInfo) {
        transId = ((SoapBindingInfo)bi).getTransportURI();
        if (transId == null) {
            transId = ei.getTransportId();
        }
    }
    DestinationFactory destinationFactory;
    try {
        DestinationFactoryManager mgr = bus.getExtension(DestinationFactoryManager.class);
        if (StringUtils.isEmpty(address)
            || address.startsWith("http")
            || address.startsWith("jms")
            || address.startsWith("soap.udp")
            || address.startsWith("/")) {
            destinationFactory = mgr.getDestinationFactory(mapTransportURI(transId, address));
        } else {
            destinationFactory = mgr.getDestinationFactoryForUri(address);
        }
        if (destinationFactory == null) {
            throw new IOException("Could not find destination factory for transport " + transId);
        }

        return destinationFactory.getDestination(ei, bus);
    } catch (BusException e) {
        IOException ex = new IOException("Could not find destination factory for transport " + transId);
        ex.initCause(e);
        throw ex;
    }
}
 
Example #22
Source File: XMLBindingFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainsInAttachmentInterceptor() {
    XMLBindingFactory xbf = new XMLBindingFactory();
    Binding b = xbf.createBinding(new BindingInfo(null, null));

    boolean found = false;
    for (Interceptor<? extends Message> interseptor : b.getInInterceptors()) {
        if (interseptor instanceof AttachmentInInterceptor) {
            found = true;
        }
    }

    assertTrue("No in attachment interceptor found", found);
}
 
Example #23
Source File: ProtobufServerFactoryBean.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
protected EndpointInfo createEndpointInfo() throws BusException {
    String transportId = getTransportId();
    if (transportId == null && getAddress() != null) {
        DestinationFactory df = getDestinationFactory();
        if (df == null) {
            DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
            df = dfm.getDestinationFactoryForUri(getAddress());
        }

        if (df != null) {
            transportId = df.getTransportIds().get(0);
        }
    }

    // default to http transport
    if (transportId == null) {
        transportId = "http://schemas.xmlsoap.org/wsdl/soap/http";
    }

    setTransportId(transportId);

    EndpointInfo ei = new EndpointInfo();
    ei.setTransportId(transportId);
    ei.setName(serviceFactory.getService().getName());
    ei.setAddress(getAddress());
    ei.setProperty(PROTOBUF_MESSAGE_CLASS, messageClass);

    BindingInfo bindingInfo = createBindingInfo();
    ei.setBinding(bindingInfo);

    return ei;
}
 
Example #24
Source File: ProtobufBindingFactory.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
public BindingInfo createBindingInfo(Service service, String namespace,
                                     Object obj) {

    ServiceInfo si = new ServiceInfo();
    si.setTargetNamespace(ProtobufBindingFactory.PROTOBUF_BINDING_ID);

    BindingInfo info = new BindingInfo(si,
            ProtobufBindingFactory.PROTOBUF_BINDING_ID);

    return info;
}
 
Example #25
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBareOutSingle() throws Exception {

    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add(myComplexStruct);

    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"),
                    MyComplexStructType.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "sendReceiveData"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareMyComplexStructTypeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(myComplexStruct.getElem1(), dxr.getText());
}
 
Example #26
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBindingInfo() throws Exception {
    setUpBasic();
    BindingInfo bindingInfo = null;
    assertEquals(1, serviceInfo.getBindings().size());
    bindingInfo = serviceInfo.getBindings().iterator().next();
    assertNotNull(bindingInfo);
    assertEquals(bindingInfo.getInterface().getName().getLocalPart(), "Greeter");
    assertEquals(bindingInfo.getName().getLocalPart(), "Greeter_SOAPBinding");
    assertEquals(bindingInfo.getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    control.verify();
}
 
Example #27
Source File: XMLBindingFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public BindingInfo createBindingInfo(ServiceInfo service, String namespace, Object config) {
    BindingInfo info = new BindingInfo(service, "http://cxf.apache.org/bindings/xformat");
    info.setName(new QName(service.getName().getNamespaceURI(),
                           service.getName().getLocalPart() + "XMLBinding"));

    for (OperationInfo op : service.getInterface().getOperations()) {
        adjustConcreteNames(op.getInput());
        adjustConcreteNames(op.getOutput());
        BindingOperationInfo bop =
            info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());
        info.addOperation(bop);
    }

    return info;
}
 
Example #28
Source File: ColocMessageObserverTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetExchangeProperties() throws Exception {
    QName opName = new QName("A", "B");
    msg.put(Message.WSDL_OPERATION, opName);
    EasyMock.expect(ep.getService()).andReturn(srv);
    Binding binding = control.createMock(Binding.class);
    EasyMock.expect(ep.getBinding()).andReturn(binding);
    EndpointInfo ei = control.createMock(EndpointInfo.class);
    EasyMock.expect(ep.getEndpointInfo()).andReturn(ei);
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(ei.getBinding()).andReturn(bi);
    BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
    EasyMock.expect(bi.getOperation(opName)).andReturn(boi);
    EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader());
    control.replay();
    observer = new ColocMessageObserver(ep, bus);
    observer.setExchangeProperties(ex, msg);
    control.verify();

    assertNotNull("Bus should be set",
                  ex.getBus());
    assertNotNull("Endpoint should be set",
                  ex.getEndpoint());
    assertNotNull("Binding should be set",
                  ex.getBinding());
    assertNotNull("Service should be set",
                  ex.getService());
    assertNotNull("BindingOperationInfo should be set",
                  ex.getBindingOperationInfo());
}
 
Example #29
Source File: WadlGeneratorJsonTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Message mockMessage(String baseAddress, String pathInfo, String query,
                            ClassResourceInfo cri) throws Exception {
    Message m = new MessageImpl();
    Exchange e = new ExchangeImpl();
    e.put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri)));
    m.setExchange(e);
    control.reset();
    ServletDestination d = control.createMock(ServletDestination.class);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();

    Endpoint endpoint = new EndpointImpl(null, null, epr);
    e.put(Endpoint.class, endpoint);

    e.setDestination(d);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, "GET");
    control.replay();
    return m;
}
 
Example #30
Source File: AbstractBindingFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a "default" BindingInfo object for the service.  Can return a subclass
 * which can then process the extensors within the subclass.   By default, just
 * creates it for the first ServiceInfo in the service
 */
public BindingInfo createBindingInfo(Service service, String namespace, Object config) {
    BindingInfo bi = createBindingInfo(service.getServiceInfos().get(0), namespace, config);
    if (bi.getName() == null) {
        bi.setName(new QName(service.getName().getNamespaceURI(),
                             service.getName().getLocalPart() + "Binding"));
    }
    return bi;
}