Search in sources :

Example 1 with AddressType

use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.

the class HttpAddressPlugin method createExtension.

public ExtensibilityElement createExtension(final Map<String, Object> args) throws WSDLException {
    String address = getOption(args, ToolConstants.CFG_ADDRESS);
    ExtensibilityElement addr = registry.createExtension(Port.class, WSDLConstants.QNAME_XMLHTTP_BINDING_ADDRESS);
    if (addr instanceof AddressType) {
        ((AddressType) addr).setLocation(address);
    }
    if (addr instanceof HTTPAddress) {
        ((HTTPAddress) addr).setLocationURI(address);
    }
    return addr;
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) AddressType(org.apache.cxf.wsdl.http.AddressType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 2 with AddressType

use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.

the class ServiceImpl method initializePorts.

private void initializePorts() {
    try {
        Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
        javax.wsdl.Service serv = def.getService(serviceName);
        if (serv == null) {
            throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
        }
        Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
        for (Port port : wsdlports.values()) {
            QName name = new QName(serviceName.getNamespaceURI(), port.getName());
            String address = null;
            String bindingID = null;
            List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                } else if (e instanceof SOAP12Binding) {
                    bindingID = SOAPBinding.SOAP12HTTP_BINDING;
                } else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                }
            }
            extensions = CastUtils.cast(port.getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapAddress) {
                    address = ((SoapAddress) e).getLocationURI();
                } else if (e instanceof AddressType) {
                    address = ((AddressType) e).getLocation();
                } else if (e instanceof SOAP12Address) {
                    address = ((SOAP12Address) e).getLocationURI();
                } else if (e instanceof SOAPAddress) {
                    address = ((SOAPAddress) e).getLocationURI();
                } else if (e instanceof HTTPAddress) {
                    address = ((HTTPAddress) e).getLocationURI();
                }
            }
            addPort(name, bindingID, address);
        }
    } catch (WebServiceException e) {
        throw e;
    } catch (Throwable e) {
        if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, e.getLocalizedMessage(), e);
        }
        WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
        Service service = sf.create();
        for (ServiceInfo si : service.getServiceInfos()) {
            for (EndpointInfo ei : si.getEndpoints()) {
                String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
                addPort(ei.getName(), bindingID, ei.getAddress());
            }
        }
    }
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) Port(javax.wsdl.Port) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) UncheckedException(org.apache.cxf.common.i18n.UncheckedException) SoapAddress(org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLManager(org.apache.cxf.wsdl.WSDLManager) AddressType(org.apache.cxf.wsdl.http.AddressType)

Example 3 with AddressType

use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.

the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.

@Test
public void testBuildDefinitionWithXMLBinding() {
    String qname = "http://apache.org/hello_world_xml_http/bare";
    String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
    JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
    builder.setBus(BusFactory.getDefaultBus());
    builder.setContext(env);
    Definition def = builder.build(wsdlUrl);
    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());
    Service service = (Service) services.get(new QName(qname, "XMLService"));
    assertNotNull(service);
    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("XMLPort");
    assertNotNull(port);
    assertEquals(1, port.getExtensibilityElements().size());
    Object obj = port.getExtensibilityElements().get(0);
    if (obj instanceof JAXBExtensibilityElement) {
        obj = ((JAXBExtensibilityElement) obj).getValue();
    }
    assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
    Binding binding = port.getBinding();
    assertNotNull(binding);
    assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
    BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
    assertNotNull(operation);
    BindingInput input = operation.getBindingInput();
    assertNotNull(input);
    assertEquals(1, input.getExtensibilityElements().size());
    obj = input.getExtensibilityElements().get(0);
    if (obj instanceof JAXBExtensibilityElement) {
        obj = ((JAXBExtensibilityElement) obj).getValue();
    }
    assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
Also used : Binding(javax.wsdl.Binding) JAXBExtensibilityElement(org.apache.cxf.wsdl.JAXBExtensibilityElement) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) XMLBindingMessageFormat(org.apache.cxf.bindings.xformat.XMLBindingMessageFormat) AddressType(org.apache.cxf.wsdl.http.AddressType) JAXWSDefinitionBuilder(org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder) Test(org.junit.Test)

Example 4 with AddressType

use of org.apache.cxf.wsdl.http.AddressType in project cxf by apache.

the class HTTPTransportFactory method createEndpointInfo.

public EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b, List<?> ees) {
    if (ees != null) {
        for (Iterator<?> itr = ees.iterator(); itr.hasNext(); ) {
            Object extensor = itr.next();
            if (extensor instanceof AddressType) {
                final AddressType httpAdd = (AddressType) extensor;
                EndpointInfo info = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
                info.setAddress(httpAdd.getLocation());
                info.addExtensor(httpAdd);
                return info;
            }
        }
    }
    HttpEndpointInfo hei = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
    AddressType at = new AddressType();
    hei.addExtensor(at);
    return hei;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) AddressType(org.apache.cxf.wsdl.http.AddressType)

Example 5 with AddressType

use of org.apache.cxf.wsdl.http.AddressType in project tomee by apache.

the class HTTPTransportFactory method createEndpointInfo.

public EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b, List<?> ees) {
    if (ees != null) {
        for (Iterator<?> itr = ees.iterator(); itr.hasNext(); ) {
            Object extensor = itr.next();
            if (extensor instanceof AddressType) {
                final AddressType httpAdd = (AddressType) extensor;
                EndpointInfo info = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
                info.setAddress(httpAdd.getLocation());
                info.addExtensor(httpAdd);
                return info;
            }
        }
    }
    HttpEndpointInfo hei = new HttpEndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
    AddressType at = new AddressType();
    hei.addExtensor(at);
    return hei;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) AddressType(org.apache.cxf.wsdl.http.AddressType)

Aggregations

AddressType (org.apache.cxf.wsdl.http.AddressType)6 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)3 Definition (javax.wsdl.Definition)2 Port (javax.wsdl.Port)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 HTTPAddress (javax.wsdl.extensions.http.HTTPAddress)2 QName (javax.xml.namespace.QName)2 WebService (javax.jws.WebService)1 Binding (javax.wsdl.Binding)1 BindingInput (javax.wsdl.BindingInput)1 BindingOperation (javax.wsdl.BindingOperation)1 Service (javax.wsdl.Service)1 SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)1 SOAP12Address (javax.wsdl.extensions.soap12.SOAP12Address)1 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)1 WebServiceException (javax.xml.ws.WebServiceException)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1 SoapAddress (org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress)1 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)1 XMLBindingMessageFormat (org.apache.cxf.bindings.xformat.XMLBindingMessageFormat)1