Search in sources :

Example 1 with WebServiceAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceAnnot in project axis-axis2-java-core by apache.

the class OperationDescriptionImplTests method testDetermineOperationQName.

public void testDetermineOperationQName() {
    String wsdlRelativeLocation = "test-resources/wsdl/";
    String wsdlFileName = "BindingNamespaceDefaults.wsdl";
    String targetNamespace = "http://nonanonymous.complextype.test.org";
    String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
    // Build up a DBC, including the WSDL Definition and the annotation information for
    // the impl class.
    DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
    URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
    Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
    assertNotNull(wsdlDefn);
    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
    assertNotNull(webServiceAnnot);
    webServiceAnnot.setWsdlLocation(wsdlLocation);
    webServiceAnnot.setTargetNamespace(targetNamespace);
    webServiceAnnot.setServiceName("EchoMessageService");
    webServiceAnnot.setPortName("EchoMessagePort");
    MethodDescriptionComposite mdc = new MethodDescriptionComposite();
    mdc.setMethodName("echoMessage");
    mdc.setReturnType("java.lang.String");
    ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
    pdc1.setParameterType("java.lang.String");
    mdc.addParameterDescriptionComposite(pdc1);
    dbc.addMethodDescriptionComposite(mdc);
    dbc.setWebServiceAnnot(webServiceAnnot);
    dbc.setClassName(BindingNSImpl.class.getName());
    dbc.setWsdlDefinition(wsdlDefn);
    dbc.setwsdlURL(wsdlURL);
    HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
    dbcMap.put(dbc.getClassName(), dbc);
    List<ServiceDescription> serviceDescList = DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap);
    ServiceDescription sd = serviceDescList.get(0);
    EndpointInterfaceDescription eid = new EndpointInterfaceDescriptionImpl(dbc, new EndpointDescriptionImpl(null, new QName(targetNamespace, "EchoMessagePort"), (ServiceDescriptionImpl) sd));
    assertEquals(new QName(targetNamespace, "echoMessage"), OperationDescriptionImpl.determineOperationQName(eid, mdc));
}
Also used : HashMap(java.util.HashMap) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) MethodDescriptionComposite(org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite) URL(java.net.URL) ParameterDescriptionComposite(org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite) DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) WebServiceAnnot(org.apache.axis2.jaxws.description.builder.WebServiceAnnot) EndpointInterfaceDescription(org.apache.axis2.jaxws.description.EndpointInterfaceDescription)

Example 2 with WebServiceAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceAnnot in project axis-axis2-java-core by apache.

the class ServiceDescriptionImplValidationTests method testInvalidDBC1.

// The tests below progressively setup an identical DBC, gradually setting more values until
// the last one does not cause a validation error.
// FAILURE #1: No WebMethod annotation set on the SEI
public void testInvalidDBC1() {
    DescriptionBuilderComposite seiComposite = new DescriptionBuilderComposite();
    seiComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySEI");
    MethodDescriptionComposite seiMDC = new MethodDescriptionComposite();
    seiMDC.setMethodName("seiMethod");
    seiComposite.addMethodDescriptionComposite(seiMDC);
    DescriptionBuilderComposite superImplComposite = new DescriptionBuilderComposite();
    superImplComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySuperImpl");
    MethodDescriptionComposite superImplMDC = new MethodDescriptionComposite();
    superImplMDC.setMethodName("seiMethod");
    superImplComposite.addMethodDescriptionComposite(superImplMDC);
    DescriptionBuilderComposite implComposite = new DescriptionBuilderComposite();
    implComposite.setClassName("org.apache.axis2.jaxws.description.impl.MyImpl");
    MethodDescriptionComposite implMDC = new MethodDescriptionComposite();
    implMDC.setMethodName("notSeiMethod");
    implComposite.addMethodDescriptionComposite(implMDC);
    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
    webServiceAnnot.setName(null);
    webServiceAnnot.setEndpointInterface("org.apache.axis2.jaxws.description.impl.MySEI");
    implComposite.setWebServiceAnnot(webServiceAnnot);
    implComposite.setIsInterface(false);
    implComposite.setSuperClassName("org.apache.axis2.jaxws.description.impl.MySuperImpl");
    HashMap<String, DescriptionBuilderComposite> dbcList = new HashMap<String, DescriptionBuilderComposite>();
    dbcList.put(seiComposite.getClassName(), seiComposite);
    dbcList.put(implComposite.getClassName(), implComposite);
    dbcList.put(superImplComposite.getClassName(), superImplComposite);
    try {
        ServiceDescriptionImpl serviceDescImpl = new ServiceDescriptionImpl(dbcList, implComposite);
        fail("Did not catch expected exception");
    } catch (WebServiceException ex) {
    // Expected path
    } catch (Exception ex) {
        fail("Unexpected exception received " + ex.toString());
    }
}
Also used : DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) WebServiceAnnot(org.apache.axis2.jaxws.description.builder.WebServiceAnnot) MethodDescriptionComposite(org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite) WebServiceException(javax.xml.ws.WebServiceException)

Example 3 with WebServiceAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceAnnot in project axis-axis2-java-core by apache.

the class WSDLGeneratorImpl method testPartialWSDL2.

/**
 * Tests the binding, service, and port not specified in the WSDL.
 * <p/>
 * This test is based on the FVT test AddNumbersImplPartial2
 */
public void testPartialWSDL2() {
    String wsdlRelativeLocation = "test-resources/wsdl/";
    String wsdlFileName = "PartialWSDL2.wsdl";
    String targetNamespace = "http://serverPartial1.checkexception.webfault.annotations/";
    String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
    // Build up a DBC, including the WSDL Definition and the annotation information for the impl class.
    DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
    URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
    Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
    assertNotNull(wsdlDefn);
    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
    assertNotNull(webServiceAnnot);
    webServiceAnnot.setWsdlLocation(wsdlLocation);
    webServiceAnnot.setTargetNamespace(targetNamespace);
    MethodDescriptionComposite mdc = new MethodDescriptionComposite();
    mdc.setMethodName("addTwoNumbers");
    mdc.setReturnType("int");
    ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
    pdc1.setParameterType("int");
    ParameterDescriptionComposite pdc2 = new ParameterDescriptionComposite();
    pdc1.setParameterType("int");
    mdc.addParameterDescriptionComposite(pdc1);
    mdc.addParameterDescriptionComposite(pdc2);
    dbc.addMethodDescriptionComposite(mdc);
    dbc.setWebServiceAnnot(webServiceAnnot);
    dbc.setClassName(AddNumbersImplPartial1.class.getName());
    dbc.setWsdlDefinition(wsdlDefn);
    dbc.setwsdlURL(wsdlURL);
    dbc.setCustomWsdlGenerator(new WSDLGeneratorImpl(wsdlDefn));
    HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
    dbcMap.put(AddNumbersImplPartial1.class.getName(), dbc);
    List<ServiceDescription> serviceDescList = DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap);
    assertEquals(1, serviceDescList.size());
    ServiceDescription sd = serviceDescList.get(0);
    assertNotNull(sd);
    EndpointDescription[] edArray = sd.getEndpointDescriptions();
    assertNotNull(edArray);
    assertEquals(1, edArray.length);
    EndpointDescription ed = edArray[0];
    assertNotNull(ed);
    // Test for presence of generated WSDL
    AxisService as = ed.getAxisService();
    assertNotNull(as);
    Parameter compositeParam = as.getParameter(MDQConstants.WSDL_COMPOSITE);
    assertNotNull(compositeParam);
    assertNotNull(compositeParam.getValue());
    EndpointInterfaceDescription eid = ed.getEndpointInterfaceDescription();
    assertNotNull(eid);
    OperationDescription[] odArray = eid.getOperations();
    assertNotNull(odArray);
    assertEquals(1, odArray.length);
    OperationDescription od = odArray[0];
}
Also used : HashMap(java.util.HashMap) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) MethodDescriptionComposite(org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite) EndpointDescription(org.apache.axis2.jaxws.description.EndpointDescription) URL(java.net.URL) ParameterDescriptionComposite(org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite) DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) WebServiceAnnot(org.apache.axis2.jaxws.description.builder.WebServiceAnnot) Parameter(org.apache.axis2.description.Parameter)

Example 4 with WebServiceAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceAnnot in project axis-axis2-java-core by apache.

the class WSDLGeneratorImpl method testPartialWSDL1.

/**
 * Tests the binding, service, and port not specified in the WSDL.
 * <p/>
 * This test is based on the FVT test AddNumbersImplPartial1
 */
public void testPartialWSDL1() {
    String wsdlRelativeLocation = "test-resources/wsdl/";
    String wsdlFileName = "PartialWSDL1.wsdl";
    String targetNamespace = "http://serverPartial1.checkexception.webfault.annotations/";
    String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
    // Build up a DBC, including the WSDL Definition and the annotation information for the impl class.
    DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
    URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
    Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
    assertNotNull(wsdlDefn);
    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
    assertNotNull(webServiceAnnot);
    webServiceAnnot.setWsdlLocation(wsdlLocation);
    webServiceAnnot.setTargetNamespace(targetNamespace);
    MethodDescriptionComposite mdc = new MethodDescriptionComposite();
    mdc.setMethodName("addTwoNumbers");
    mdc.setReturnType("int");
    ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
    pdc1.setParameterType("int");
    ParameterDescriptionComposite pdc2 = new ParameterDescriptionComposite();
    pdc1.setParameterType("int");
    mdc.addParameterDescriptionComposite(pdc1);
    mdc.addParameterDescriptionComposite(pdc2);
    dbc.addMethodDescriptionComposite(mdc);
    dbc.setWebServiceAnnot(webServiceAnnot);
    dbc.setClassName(AddNumbersImplPartial1.class.getName());
    dbc.setWsdlDefinition(wsdlDefn);
    dbc.setwsdlURL(wsdlURL);
    dbc.setCustomWsdlGenerator(new WSDLGeneratorImpl(wsdlDefn));
    HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
    dbcMap.put(AddNumbersImplPartial1.class.getName(), dbc);
    List<ServiceDescription> serviceDescList = DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap);
    assertEquals(1, serviceDescList.size());
    ServiceDescription sd = serviceDescList.get(0);
    assertNotNull(sd);
    EndpointDescription[] edArray = sd.getEndpointDescriptions();
    assertNotNull(edArray);
    assertEquals(1, edArray.length);
    EndpointDescription ed = edArray[0];
    assertNotNull(ed);
    // Test for presence of generated WSDL
    AxisService as = ed.getAxisService();
    assertNotNull(as);
    Parameter compositeParam = as.getParameter(MDQConstants.WSDL_COMPOSITE);
    assertNotNull(compositeParam);
    assertNotNull(compositeParam.getValue());
    EndpointInterfaceDescription eid = ed.getEndpointInterfaceDescription();
    assertNotNull(eid);
    OperationDescription[] odArray = eid.getOperations();
    assertNotNull(odArray);
    assertEquals(1, odArray.length);
    OperationDescription od = odArray[0];
}
Also used : HashMap(java.util.HashMap) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) MethodDescriptionComposite(org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite) EndpointDescription(org.apache.axis2.jaxws.description.EndpointDescription) URL(java.net.URL) ParameterDescriptionComposite(org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite) DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) WebServiceAnnot(org.apache.axis2.jaxws.description.builder.WebServiceAnnot) Parameter(org.apache.axis2.description.Parameter)

Example 5 with WebServiceAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceAnnot in project axis-axis2-java-core by apache.

the class ValidateWSDLImpl2 method testValidatePortType.

/**
 * The SEI used by the service impl does not contain all the methods defined on the PortType
 */
public void testValidatePortType() {
    String wsdlRelativeLocation = System.getProperty("basedir", ".") + "/" + "test-resources/wsdl/";
    String wsdlFileName = "ValidateWSDL1.wsdl";
    String targetNamespace = "http://serverPartial1.checkexception.webfault.annotations/";
    String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
    // Build up a DBC, including the WSDL Definition and the annotation information for the impl class.
    DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
    URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
    Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
    assertNotNull(wsdlDefn);
    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
    assertNotNull(webServiceAnnot);
    webServiceAnnot.setWsdlLocation(wsdlLocation);
    webServiceAnnot.setTargetNamespace(targetNamespace);
    MethodDescriptionComposite mdc = new MethodDescriptionComposite();
    mdc.setMethodName("addTwoNumbers");
    mdc.setReturnType("int");
    ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
    pdc1.setParameterType("int");
    ParameterDescriptionComposite pdc2 = new ParameterDescriptionComposite();
    pdc1.setParameterType("int");
    mdc.addParameterDescriptionComposite(pdc1);
    mdc.addParameterDescriptionComposite(pdc2);
    dbc.addMethodDescriptionComposite(mdc);
    dbc.setWebServiceAnnot(webServiceAnnot);
    dbc.setClassName(ValidateWSDLImpl1.class.getName());
    dbc.setWsdlDefinition(wsdlDefn);
    dbc.setwsdlURL(wsdlURL);
    HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
    dbcMap.put(ValidateWSDLImpl1.class.getName(), dbc);
    try {
        List<ServiceDescription> serviceDescList = DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap);
    // Removing the fail() call here as we removed the Valdiation Error from
    // EndpointInterfaceDescriptionValidator.
    // Expected code path
    } catch (WebServiceException e) {
    // Expected code path
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) MethodDescriptionComposite(org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite) URL(java.net.URL) ParameterDescriptionComposite(org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite) DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) WebServiceAnnot(org.apache.axis2.jaxws.description.builder.WebServiceAnnot)

Aggregations

WebServiceAnnot (org.apache.axis2.jaxws.description.builder.WebServiceAnnot)20 DescriptionBuilderComposite (org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite)19 MethodDescriptionComposite (org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite)17 HashMap (java.util.HashMap)16 ParameterDescriptionComposite (org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite)14 URL (java.net.URL)12 Definition (javax.wsdl.Definition)12 WebServiceException (javax.xml.ws.WebServiceException)6 AxisService (org.apache.axis2.description.AxisService)6 AxisFault (org.apache.axis2.AxisFault)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 Parameter (org.apache.axis2.description.Parameter)2 EndpointDescription (org.apache.axis2.jaxws.description.EndpointDescription)2 JavaClassToDBCConverter (org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter)2 WebParam (javax.jws.WebParam)1 WebService (javax.jws.WebService)1 QName (javax.xml.namespace.QName)1 EndpointInterfaceDescription (org.apache.axis2.jaxws.description.EndpointInterfaceDescription)1 ServiceDescription (org.apache.axis2.jaxws.description.ServiceDescription)1 WebMethodAnnot (org.apache.axis2.jaxws.description.builder.WebMethodAnnot)1