use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class ClientDBCSupportEchoServiceImplWithSEI method testServiceClientWSDLLocationOverride.
/**
* Create a ServiceDescription using a sparse composite that overrides the wsdlLocation on the
* WebServiceClient annotation. Validate the override only affects the wsdlLocation and not
* the other annotations members.
*/
public void testServiceClientWSDLLocationOverride() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
// Create a composite with a WebServiceClient override of the WSDL location.
DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
String overridenWsdlLocation = DescriptionTestUtils.getWSDLLocation("ClientEndpointMetadata.wsdl");
WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, overridenWsdlLocation);
composite.setWebServiceClientAnnot(wsClientAnno);
Object compositeKey = "CompositeKey";
ServiceDescription svcDesc = new ServiceDescriptionImpl(null, serviceQName, ClientDBCSupportServiceSubclass.class, composite, compositeKey);
assertNotNull(svcDesc);
ServiceDescriptionImpl svcDescImpl = (ServiceDescriptionImpl) svcDesc;
DescriptionBuilderComposite svcDescComposite = svcDescImpl.getDescriptionBuilderComposite();
assertNotNull(svcDescComposite);
assertNotSame(composite, svcDescComposite);
assertSame(composite, svcDescComposite.getSparseComposite(compositeKey));
// The client annot we set as a sparse composite should be the same.
assertSame(wsClientAnno, svcDescComposite.getSparseComposite(compositeKey).getWebServiceClientAnnot());
// The WebServiceClient annot on the service desc should represent the wsdl override from the
// sparse composite
WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot(compositeKey);
assertEquals(overridenWsdlLocation, wsClient.wsdlLocation());
// Make sure the non-overridden values still come from the service class annotation
assertEquals("originalTNS", wsClient.targetNamespace());
assertEquals("", wsClient.name());
}
use of org.apache.axis2.addressing.metadata.WSDLLocation 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.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class EndpointReferenceHelper method getWSDLLocationMetadata.
/**
* Retrieves the wsdli:wsdlLocation attribute from an EPR.
*
* @param epr the EPR to retrieve the attribute from
* @param addressingNamespace the WS-Addressing namespace associated with
* the EPR.
* @return an instance of <code>WSDLLocation</code>. The return value is
* never <code>null</code>.
* @throws AxisFault
*/
public static WSDLLocation getWSDLLocationMetadata(EndpointReference epr, String addressingNamespace) throws AxisFault {
WSDLLocation wsdlLocation = new WSDLLocation();
List attributes = null;
if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace))
attributes = epr.getAttributes();
else
attributes = epr.getMetadataAttributes();
if (attributes != null) {
// Retrieve the wsdl location.
for (int i = 0, size = attributes.size(); i < size; i++) {
OMAttribute omAttribute = (OMAttribute) attributes.get(i);
if (WSDLLocation.isWSDLLocationAttribute(omAttribute)) {
wsdlLocation.fromOM(omAttribute);
break;
}
}
}
return wsdlLocation;
}
use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class WSDLLocation method fromOM.
/**
* Convenience method for converting an OMAttribute to an instance of either of these types.
* <p>
* <... xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...>
* </p>
* <p>
* <... xmlns:wsdli="http://www.w3.org/ns/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...>
* </p>
* @param omAttribute the <code>OMAttribute</code> that holds the wsdl location.
* @throws AxisFault
*/
public void fromOM(OMAttribute omAttribute) throws AxisFault {
QName qname = omAttribute.getQName();
if (WSDLI.equals(qname) || FINAL_WSDLI.equals(qname)) {
String value = omAttribute.getAttributeValue().trim();
String[] values = value.split("\\s", 2);
// give us the correct number of elements.
if (values.length != 2)
return;
targetNamespace = values[0];
wsdlURL = values[1];
if (log.isDebugEnabled()) {
log.debug("fromOM: Extracted WSDLLocation targetNamespace = " + targetNamespace + " and wsdlURL = " + wsdlURL + " from an OMAttribute with QName = " + qname);
}
} else {
throw new AxisFault("Unrecognized element.");
}
}
use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class EndpointReferenceHelperTest method testSetAndGetWSDLLocationMetadataForFinalSpecEPR.
public void testSetAndGetWSDLLocationMetadataForFinalSpecEPR() throws Exception {
String address = "http://ws.apache.org/axis2";
String targetNamespace = "targetNamespace";
String location = "wsdlLocation";
EndpointReference epr = new EndpointReference(address);
OMFactory omf = OMAbstractFactory.getOMFactory();
// Uses final WSDLI namespace on wsdlLocation attribute
EndpointReferenceHelper.setWSDLLocationMetadata(omf, epr, AddressingConstants.Final.WSA_NAMESPACE, new WSDLLocation(targetNamespace, location));
WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Final.WSA_NAMESPACE);
assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
assertEquals(wsdlLocation.getLocation(), location);
}
Aggregations