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));
}
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());
}
}
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];
}
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];
}
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
}
}
Aggregations