Search in sources :

Example 11 with JAXWSBinding

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.

the class ServiceProcessor method processPort.

private JavaPort processPort(JavaModel model, ServiceInfo si, EndpointInfo port) throws ToolException {
    BindingInfo binding = port.getBinding();
    String portType = binding.getInterface().getName().getLocalPart();
    JavaInterface intf = PortTypeProcessor.getInterface(context, si, binding.getInterface());
    JavaPort jport = new JavaPort(NameUtil.mangleNameToClassName(port.getName().getLocalPart()));
    jport.setPackageName(intf.getPackageName());
    jport.setPortName(port.getName().getLocalPart());
    jport.setBindingAdress(port.getAddress());
    jport.setBindingName(binding.getName().getLocalPart());
    jport.setPortType(portType);
    jport.setInterfaceClass(intf.getName());
    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);
    }
    if (isSoapBinding()) {
        SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj);
        jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle()));
        jport.setTransURI(spbd.getTransportURI());
    }
    Collection<BindingOperationInfo> operations = binding.getOperations();
    for (BindingOperationInfo bop : operations) {
        processOperation(model, bop, binding);
    }
    jport.setJavaDoc(port.getDocumentation());
    JAXWSBinding bind = port.getExtensor(JAXWSBinding.class);
    if (bind != null) {
        jport.setMethodName(bind.getMethodName());
        jport.setJavaDoc(bind.getMethodJavaDoc());
    }
    return jport;
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.common.i18n.Message) Message(org.apache.cxf.common.i18n.Message) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) JavaPort(org.apache.cxf.tools.common.model.JavaPort) BindingInfo(org.apache.cxf.service.model.BindingInfo) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) ToolException(org.apache.cxf.tools.common.ToolException)

Example 12 with JAXWSBinding

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.

the class ServiceProcessor method process.

public void process(ServiceInfo si) throws ToolException {
    jaxwsBinding = new JAXWSBinding();
    this.service = si;
    if (si.getName() == null) {
        processBindings(context.get(JavaModel.class));
    } else {
        processService(context.get(JavaModel.class));
    }
}
Also used : JavaModel(org.apache.cxf.tools.common.model.JavaModel) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)

Example 13 with JAXWSBinding

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.

the class JAXWSDefinitionBuilderTest method testCustomizationWithDifferentNS.

@Test
public void testCustomizationWithDifferentNS() {
    env.put(ToolConstants.CFG_WSDLURL, getClass().getResource("resources/hello_world.wsdl").toString());
    env.put(ToolConstants.CFG_BINDING, getClass().getResource("resources/binding3.xml").toString());
    JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
    builder.setContext(env);
    builder.setBus(BusFactory.getDefaultBus());
    builder.build();
    builder.customize();
    Definition customizedDef = builder.getWSDLModel();
    List<?> defExtensionList = customizedDef.getExtensibilityElements();
    Iterator<?> ite = defExtensionList.iterator();
    while (ite.hasNext()) {
        ExtensibilityElement extElement = (ExtensibilityElement) ite.next();
        JAXWSBinding binding = (JAXWSBinding) extElement;
        assertEquals("Customized package name does not been parsered", "com.foo", binding.getPackage());
        assertEquals("Customized enableAsync does not parsered", true, binding.isEnableAsyncMapping());
    }
    PortType portType = customizedDef.getPortType(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
    List<?> portTypeList = portType.getExtensibilityElements();
    JAXWSBinding binding = (JAXWSBinding) portTypeList.get(0);
    assertEquals("Customized enable EnableWrapperStyle name does not been parsered", true, binding.isEnableWrapperStyle());
    List<?> opList = portType.getOperations();
    Operation operation = (Operation) opList.get(0);
    List<?> extList = operation.getExtensibilityElements();
    binding = (JAXWSBinding) extList.get(0);
    assertEquals("Customized method name does not parsered", "echoMeOneWay", binding.getMethodName());
    assertEquals("Customized parameter element name does not parsered", "number1", binding.getJaxwsParas().get(0).getElementName().getLocalPart());
    assertEquals("Customized parameter message name does not parsered", "greetMeOneWayRequest", binding.getJaxwsParas().get(0).getMessageName());
    assertEquals("customized parameter name does not parsered", "num1", binding.getJaxwsParas().get(0).getName());
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) Operation(javax.wsdl.Operation) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Example 14 with JAXWSBinding

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding in project cxf by apache.

the class JAXWSDefinitionBuilderTest method testCustomization.

@Test
public void testCustomization() {
    env.put(ToolConstants.CFG_WSDLURL, getClass().getResource("resources/hello_world.wsdl").toString());
    env.put(ToolConstants.CFG_BINDING, getClass().getResource("resources/binding2.xml").toString());
    JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
    builder.setContext(env);
    builder.setBus(BusFactory.getDefaultBus());
    builder.build();
    builder.customize();
    Definition customizedDef = builder.getWSDLModel();
    List<?> defExtensionList = customizedDef.getExtensibilityElements();
    Iterator<?> ite = defExtensionList.iterator();
    while (ite.hasNext()) {
        ExtensibilityElement extElement = (ExtensibilityElement) ite.next();
        JAXWSBinding binding = (JAXWSBinding) extElement;
        assertEquals("Customized package name does not been parsered", "com.foo", binding.getPackage());
        assertEquals("Customized enableAsync does not parsered", true, binding.isEnableAsyncMapping());
    }
    PortType portType = customizedDef.getPortType(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
    List<?> portTypeList = portType.getExtensibilityElements();
    JAXWSBinding binding = (JAXWSBinding) portTypeList.get(0);
    assertEquals("Customized enable EnableWrapperStyle name does not been parsered", true, binding.isEnableWrapperStyle());
    List<?> opList = portType.getOperations();
    Operation operation = (Operation) opList.get(0);
    List<?> extList = operation.getExtensibilityElements();
    binding = (JAXWSBinding) extList.get(0);
    assertEquals("Customized method name does not parsered", "echoMeOneWay", binding.getMethodName());
    assertEquals("Customized parameter element name does not parsered", "number1", binding.getJaxwsParas().get(0).getElementName().getLocalPart());
    assertEquals("Customized parameter message name does not parsered", "greetMeOneWayRequest", binding.getJaxwsParas().get(0).getMessageName());
    assertEquals("customized parameter name does not parsered", "num1", binding.getJaxwsParas().get(0).getName());
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) Operation(javax.wsdl.Operation) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Aggregations

JAXWSBinding (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)14 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)5 ToolException (org.apache.cxf.tools.common.ToolException)5 QName (javax.xml.namespace.QName)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 Message (org.apache.cxf.common.i18n.Message)3 JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)3 JAXWSParameter (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter)3 Definition (javax.wsdl.Definition)2 Operation (javax.wsdl.Operation)2 PortType (javax.wsdl.PortType)2 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 JAnnotationElement (org.apache.cxf.tools.common.model.JAnnotationElement)2 JavaMethod (org.apache.cxf.tools.common.model.JavaMethod)2 JavaModel (org.apache.cxf.tools.common.model.JavaModel)2 JavaParameter (org.apache.cxf.tools.common.model.JavaParameter)2 JavaPort (org.apache.cxf.tools.common.model.JavaPort)2 ClassCollector (org.apache.cxf.tools.util.ClassCollector)2 Test (org.junit.Test)2