Search in sources :

Example 1 with JAXBExtensibilityElement

use of org.apache.cxf.wsdl.JAXBExtensibilityElement in project cxf by apache.

the class XmlIoPlugin method createExtension.

public ExtensibilityElement createExtension(final Map<String, Object> args) throws WSDLException {
    XMLBindingMessageFormat xmlFormat = null;
    Class<?> clz = getOption(args, Class.class);
    QName qname = getOption(args, QName.class);
    ExtensibilityElement ext = registry.createExtension(clz, ToolConstants.XML_FORMAT);
    if (ext instanceof JAXBExtensibilityElement) {
        xmlFormat = (XMLBindingMessageFormat) ((JAXBExtensibilityElement) ext).getValue();
    } else {
        xmlFormat = (XMLBindingMessageFormat) ext;
    }
    xmlFormat.setRootNode(qname);
    return ext;
}
Also used : JAXBExtensibilityElement(org.apache.cxf.wsdl.JAXBExtensibilityElement) XMLBindingMessageFormat(org.apache.cxf.bindings.xformat.XMLBindingMessageFormat) QName(javax.xml.namespace.QName) JAXBExtensibilityElement(org.apache.cxf.wsdl.JAXBExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 2 with JAXBExtensibilityElement

use of org.apache.cxf.wsdl.JAXBExtensibilityElement 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)

Aggregations

QName (javax.xml.namespace.QName)2 XMLBindingMessageFormat (org.apache.cxf.bindings.xformat.XMLBindingMessageFormat)2 JAXBExtensibilityElement (org.apache.cxf.wsdl.JAXBExtensibilityElement)2 Binding (javax.wsdl.Binding)1 BindingInput (javax.wsdl.BindingInput)1 BindingOperation (javax.wsdl.BindingOperation)1 Definition (javax.wsdl.Definition)1 Port (javax.wsdl.Port)1 Service (javax.wsdl.Service)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 JAXWSDefinitionBuilder (org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder)1 AddressType (org.apache.cxf.wsdl.http.AddressType)1 Test (org.junit.Test)1