Search in sources :

Example 6 with BindingInfo

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

the class SoapActionInterceptorTest method createBindingOperation.

private BindingOperationInfo createBindingOperation() {
    ServiceInfo s = new ServiceInfo();
    InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
    s.setInterface(ii);
    ii.addOperation(new QName("fooOp"));
    BindingInfo b = new BindingInfo(s, "foo");
    return b.buildOperation(new QName("fooOp"), null, null);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 7 with BindingInfo

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

the class TestBase method getTestService.

protected BindingInfo getTestService(String wsdlUrl, String port) throws Exception {
    ServiceInfo service = getMockedServiceModel(getClass().getResource(wsdlUrl).toString());
    assertNotNull(service);
    BindingInfo binding = service.getEndpoint(new QName(service.getName().getNamespaceURI(), port)).getBinding();
    assertNotNull(binding);
    return binding;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 8 with BindingInfo

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

the class RPCOutInterceptorTest method setUp.

@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().getOutput().getMessagePartByIndex(0).setIndex(0);
    soapMessage.getExchange().put(BindingOperationInfo.class, boi);
    control.reset();
    Service service = control.createMock(Service.class);
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
    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();
    soapMessage.getExchange().put(Service.class, service);
    soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    control.replay();
    MyComplexStruct mcs = new MyComplexStruct();
    mcs.setElem1("elem1");
    mcs.setElem2("elem2");
    mcs.setElem3(45);
    MessageContentsList param = new MessageContentsList();
    param.add(mcs);
    soapMessage.setContent(List.class, param);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageContentsList(org.apache.cxf.message.MessageContentsList) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) Before(org.junit.Before)

Example 9 with BindingInfo

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

the class SoapBindingFactoryTest method testFactory.

@Test
public void testFactory() throws Exception {
    Definition d = createDefinition("/wsdl_soap/hello_world.wsdl");
    Bus bus = getMockBus();
    BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
    bus.getExtension(BindingFactoryManager.class);
    expectLastCall().andReturn(bfm).anyTimes();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap_http", "SOAPService")).get(0);
    BindingInfo bi = serviceInfo.getBindings().iterator().next();
    assertTrue(bi instanceof SoapBindingInfo);
    SoapBindingInfo sbi = (SoapBindingInfo) bi;
    assertEquals("document", sbi.getStyle());
    assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
    assertTrue(sbi.getSoapVersion() instanceof Soap11);
    BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap_http", "sayHi"));
    SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
    assertNotNull(sboi);
    assertEquals("document", sboi.getStyle());
    assertEquals("", sboi.getAction());
    BindingMessageInfo input = boi.getInput();
    SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
    assertEquals("literal", bodyInfo.getUse());
    List<MessagePartInfo> parts = bodyInfo.getParts();
    assertNotNull(parts);
    assertEquals(1, parts.size());
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Test(org.junit.Test)

Example 10 with BindingInfo

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

the class JaxWsServiceFactoryBean method initializeWSDLOperationsForProvider.

protected void initializeWSDLOperationsForProvider() {
    Class<?> c = getProviderParameterType(getServiceClass());
    if (c == null) {
        throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG));
    }
    if (getEndpointInfo() == null && isFromWsdl()) {
        // most likely, they specified a WSDL, but for some reason
        // did not give a valid ServiceName/PortName.  For provider,
        // we'll allow this since everything is bound directly to
        // the invoke method, however, this CAN cause other problems
        // such as addresses in the wsdl not getting updated and such
        // so we'll WARN about it.....
        List<QName> enames = new ArrayList<>();
        for (ServiceInfo si : getService().getServiceInfos()) {
            for (EndpointInfo ep : si.getEndpoints()) {
                enames.add(ep.getName());
            }
        }
        LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT", new Object[] { getEndpointName(), enames });
    }
    try {
        Method invoke = getServiceClass().getMethod("invoke", c);
        QName catchAll = new QName("http://cxf.apache.org/jaxws/provider", "invoke");
        // Bind every operation to the invoke method.
        for (ServiceInfo si : getService().getServiceInfos()) {
            si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
            if (!isFromWsdl()) {
                for (EndpointInfo ei : si.getEndpoints()) {
                    ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
                }
            }
            for (BindingInfo bind : si.getBindings()) {
                for (BindingOperationInfo bop : bind.getOperations()) {
                    OperationInfo o = bop.getOperationInfo();
                    if (bop.isUnwrappedCapable()) {
                        // force to bare, no unwrapping
                        bop.getOperationInfo().setUnwrappedOperation(null);
                        bop.setUnwrappedOperation(null);
                    }
                    if (o.getInput() != null) {
                        final List<MessagePartInfo> messageParts;
                        if (o.getInput().getMessagePartsNumber() == 0) {
                            MessagePartInfo inf = o.getInput().addMessagePart(o.getName());
                            inf.setConcreteName(o.getName());
                            messageParts = o.getInput().getMessageParts();
                            bop.getInput().setMessageParts(messageParts);
                        } else {
                            messageParts = o.getInput().getMessageParts();
                        }
                        for (MessagePartInfo inf : messageParts) {
                            inf.setTypeClass(c);
                            break;
                        }
                    }
                    if (o.getOutput() != null) {
                        final List<MessagePartInfo> messageParts;
                        if (o.getOutput().getMessagePartsNumber() == 0) {
                            MessagePartInfo inf = o.getOutput().addMessagePart(o.getName());
                            inf.setConcreteName(new QName(o.getName().getNamespaceURI(), o.getName().getLocalPart() + "Response"));
                            messageParts = o.getOutput().getMessageParts();
                            bop.getOutput().setMessageParts(messageParts);
                        } else {
                            messageParts = o.getOutput().getMessageParts();
                        }
                        for (MessagePartInfo inf : messageParts) {
                            inf.setTypeClass(c);
                            break;
                        }
                    }
                    getMethodDispatcher().bind(o, invoke);
                }
                BindingOperationInfo bop = bind.getOperation(catchAll);
                if (bop == null) {
                    OperationInfo op = bind.getInterface().getOperation(catchAll);
                    if (op == null) {
                        op = bind.getInterface().addOperation(catchAll);
                        String name = catchAll.getLocalPart();
                        MessageInfo mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(), name + "Request"), MessageInfo.Type.INPUT);
                        op.setInput(catchAll.getLocalPart() + "Request", mInfo);
                        MessagePartInfo mpi = mInfo.addMessagePart("parameters");
                        mpi.setElement(true);
                        mpi.setTypeClass(c);
                        mpi.setTypeQName(Constants.XSD_ANYTYPE);
                        mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(), name + "Response"), MessageInfo.Type.OUTPUT);
                        op.setOutput(name + "Response", mInfo);
                        mpi = mInfo.addMessagePart("parameters");
                        mpi.setElement(true);
                        mpi.setTypeClass(c);
                        mpi.setTypeQName(Constants.XSD_ANYTYPE);
                        BindingOperationInfo bo = new BindingOperationInfo(bind, op);
                        op.setProperty("operation.is.synthetic", Boolean.TRUE);
                        bo.setProperty("operation.is.synthetic", Boolean.TRUE);
                        bind.addOperation(bo);
                    }
                }
            }
        }
    } catch (SecurityException | NoSuchMethodException e) {
        throw new ServiceConstructionException(e);
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.common.i18n.Message) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Aggregations

BindingInfo (org.apache.cxf.service.model.BindingInfo)103 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)65 QName (javax.xml.namespace.QName)45 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)35 Test (org.junit.Test)29 Endpoint (org.apache.cxf.endpoint.Endpoint)28 OperationInfo (org.apache.cxf.service.model.OperationInfo)21 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)20 Service (org.apache.cxf.service.Service)18 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)17 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)17 Exchange (org.apache.cxf.message.Exchange)15 Message (org.apache.cxf.message.Message)13 ArrayList (java.util.ArrayList)11 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)11 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)11 MessageImpl (org.apache.cxf.message.MessageImpl)11 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)9 Bus (org.apache.cxf.Bus)8