Search in sources :

Example 11 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class ClientFactoryBeanTest method testClientFactoryBean.

@Test
public void testClientFactoryBean() throws Exception {
    ClientFactoryBean cfBean = new ClientFactoryBean();
    cfBean.setAddress("http://localhost/Hello");
    cfBean.setBus(getBus());
    cfBean.setServiceClass(HelloService.class);
    Client client = cfBean.create();
    assertNotNull(client);
    Service service = client.getEndpoint().getService();
    Map<QName, Endpoint> eps = service.getEndpoints();
    assertEquals(1, eps.size());
    Endpoint ep = eps.values().iterator().next();
    EndpointInfo endpointInfo = ep.getEndpointInfo();
    BindingInfo b = endpointInfo.getService().getBindings().iterator().next();
    assertTrue(b instanceof SoapBindingInfo);
    SoapBindingInfo sb = (SoapBindingInfo) b;
    assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart());
    assertEquals("document", sb.getStyle());
    assertEquals(4, b.getOperations().size());
    BindingOperationInfo bop = b.getOperations().iterator().next();
    SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class);
    assertNotNull(sop);
    assertEquals("", sop.getAction());
    assertEquals("document", sop.getStyle());
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) Service(org.apache.cxf.service.Service) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 12 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class DispatchImpl method createPayloadEleOpNameMap.

private Map<String, QName> createPayloadEleOpNameMap(BindingInfo bindingInfo, boolean reverseMapping) {
    Map<String, QName> payloadElementMap = new java.util.HashMap<String, QName>();
    // assume a document binding style, which is default according to W3C spec on WSDL
    String bindingStyle = "document";
    // if the bindingInfo is a SOAPBindingInfo instance then we can see if it has a style
    if (bindingInfo instanceof SoapBindingInfo) {
        String tempStyle = ((SoapBindingInfo) bindingInfo).getStyle();
        if (tempStyle != null) {
            bindingStyle = tempStyle;
        }
    }
    for (BindingOperationInfo bop : bindingInfo.getOperations()) {
        SoapOperationInfo soi = bop.getExtensor(SoapOperationInfo.class);
        if (soi != null) {
            // operation style overrides binding style, if present
            String operationStyle = soi.getStyle() != null ? soi.getStyle() : bindingStyle;
            if ("document".equals(operationStyle)) {
                // if doc
                if (bop.getOperationInfo().getInput() != null && bop.getOperationInfo().getInput().getMessagePartsNumber() > 0) {
                    QName qn = bop.getOperationInfo().getInput().getMessagePartByIndex(0).getElementQName();
                    QName op = bop.getOperationInfo().getName();
                    if (reverseMapping) {
                        payloadElementMap.put(op.toString(), qn);
                    } else {
                        payloadElementMap.put(qn.toString(), op);
                    }
                }
            } else if ("rpc".equals(operationStyle)) {
                // if rpc
                QName op = bop.getOperationInfo().getName();
                payloadElementMap.put(op.toString(), op);
            }
        }
    }
    return payloadElementMap;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo)

Example 13 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo 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 14 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class AbstractWSDLBasedEndpointFactory method createEndpointInfo.

protected EndpointInfo createEndpointInfo(BindingInfo bindingInfo) throws BusException {
    // setup the transport ID for the soap over jms if there is only address information
    if (transportId == null && getAddress() != null && getAddress().startsWith("jms:") && !"jms://".equals(getAddress())) {
        // Set the transportId to be soap over jms transport
        transportId = SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID;
    }
    // Get the Service from the ServiceFactory if specified
    Service service = serviceFactory.getService();
    if (bindingInfo == null) {
        // SOAP nonsense
        bindingInfo = createBindingInfo();
        if (bindingInfo instanceof SoapBindingInfo && (((SoapBindingInfo) bindingInfo).getTransportURI() == null || LocalTransportFactory.TRANSPORT_ID.equals(transportId))) {
            ((SoapBindingInfo) bindingInfo).setTransportURI(transportId);
            transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
        }
        service.getServiceInfos().get(0).addBinding(bindingInfo);
    }
    if (transportId == null) {
        if (bindingInfo instanceof SoapBindingInfo) {
            transportId = ((SoapBindingInfo) bindingInfo).getTransportURI();
        }
        if (transportId == null && getAddress() != null && getAddress().contains("://")) {
            transportId = detectTransportIdFromAddress(getAddress());
        }
        if (transportId == null) {
            transportId = "http://schemas.xmlsoap.org/wsdl/http/";
        }
    }
    setTransportId(transportId);
    WSDLEndpointFactory wsdlEndpointFactory = getWSDLEndpointFactory();
    EndpointInfo ei;
    if (wsdlEndpointFactory != null) {
        ei = wsdlEndpointFactory.createEndpointInfo(bus, service.getServiceInfos().get(0), bindingInfo, null);
        ei.setTransportId(transportId);
    } else {
        ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
    }
    int count = 1;
    while (service.getEndpointInfo(endpointName) != null) {
        endpointName = new QName(endpointName.getNamespaceURI(), endpointName.getLocalPart() + count);
        count++;
    }
    ei.setName(endpointName);
    ei.setAddress(getAddress());
    ei.setBinding(bindingInfo);
    if (wsdlEndpointFactory != null) {
        wsdlEndpointFactory.createPortExtensors(bus, ei, service);
    }
    service.getServiceInfos().get(0).addEndpoint(ei);
    serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
    return ei;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) WSDLEndpointFactory(org.apache.cxf.wsdl11.WSDLEndpointFactory) QName(javax.xml.namespace.QName) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) Service(org.apache.cxf.service.Service) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 15 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class RMEndpoint method buildBindingInfo.

void buildBindingInfo(ServiceInfo si, ProtocolVariation protocol) {
    // explicitly
    if (null != applicationEndpoint) {
        final QName bindingQName = new QName(protocol.getWSRMNamespace(), BINDING_NAME);
        SoapBindingInfo sbi = (SoapBindingInfo) applicationEndpoint.getEndpointInfo().getBinding();
        SoapVersion sv = sbi.getSoapVersion();
        String bindingId = sbi.getBindingId();
        SoapBindingInfo bi = new SoapBindingInfo(si, bindingId, sv);
        bi.setName(bindingQName);
        BindingOperationInfo boi = null;
        RMConstants consts = protocol.getConstants();
        boi = bi.buildOperation(consts.getCreateSequenceOperationName(), consts.getCreateSequenceOperationName().getLocalPart(), null);
        addAction(boi, consts.getCreateSequenceAction(), consts.getCreateSequenceResponseAction());
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getTerminateSequenceOperationName(), consts.getTerminateSequenceOperationName().getLocalPart(), null);
        if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) {
            addAction(boi, consts.getTerminateSequenceAction(), RM11Constants.INSTANCE.getTerminateSequenceResponseAction());
        } else {
            addAction(boi, consts.getTerminateSequenceAction());
        }
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getTerminateSequenceAnonymousOperationName(), null, consts.getTerminateSequenceAnonymousOperationName().getLocalPart());
        addAction(boi, consts.getTerminateSequenceAction());
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getSequenceAckOperationName(), null, null);
        addAction(boi, consts.getSequenceAckAction());
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getCloseSequenceOperationName(), null, null);
        if (RM11Constants.NAMESPACE_URI.equals(protocol.getWSRMNamespace())) {
            addAction(boi, consts.getCloseSequenceAction(), RM11Constants.INSTANCE.getCloseSequenceResponseAction());
        } else {
            addAction(boi, consts.getCloseSequenceAction());
        }
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getAckRequestedOperationName(), null, null);
        addAction(boi, consts.getAckRequestedAction());
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getCreateSequenceOnewayOperationName(), consts.getCreateSequenceOnewayOperationName().getLocalPart(), null);
        addAction(boi, consts.getCreateSequenceAction());
        bi.addOperation(boi);
        boi = bi.buildOperation(consts.getCreateSequenceResponseOnewayOperationName(), consts.getCreateSequenceResponseOnewayOperationName().getLocalPart(), null);
        addAction(boi, consts.getCreateSequenceResponseAction());
        bi.addOperation(boi);
        si.addBinding(bi);
    }
// TODO: BindingFaultInfo (SequenceFault)
}
Also used : SoapVersion(org.apache.cxf.binding.soap.SoapVersion) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo)

Aggregations

SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)23 QName (javax.xml.namespace.QName)11 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)11 BindingInfo (org.apache.cxf.service.model.BindingInfo)10 Endpoint (org.apache.cxf.endpoint.Endpoint)9 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)9 Test (org.junit.Test)9 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)8 Service (org.apache.cxf.service.Service)8 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)5 Bus (org.apache.cxf.Bus)4 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)4 Definition (javax.wsdl.Definition)3 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 SoapVersion (org.apache.cxf.binding.soap.SoapVersion)3 SoapBodyInfo (org.apache.cxf.binding.soap.model.SoapBodyInfo)3 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)3 BusException (org.apache.cxf.BusException)2 Binding (org.apache.cxf.binding.Binding)2 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)2