use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class EndpointReferenceHelperTest method testGetWSDLLocationMetadataForFinalSpecEPRWithOldWsdliNamespace.
public void testGetWSDLLocationMetadataForFinalSpecEPRWithOldWsdliNamespace() throws Exception {
String address = "http://ws.apache.org/axis2";
String targetNamespace = "targetNamespace";
String location = "wsdlLocation";
EndpointReference epr = new EndpointReference(address);
// Uses old candidate spec WSDLI namespace on wsdlLocation attribute
OMFactory omf = OMAbstractFactory.getOMFactory();
String value = new StringBuffer(targetNamespace).append(" ").append(location).toString();
QName OLD_WSDLI = new QName("http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation", "wsdli");
OMNamespace wsdliNs = omf.createOMNamespace(OLD_WSDLI.getNamespaceURI(), OLD_WSDLI.getPrefix());
OMAttribute attribute = omf.createOMAttribute(OLD_WSDLI.getLocalPart(), wsdliNs, value);
ArrayList list = new ArrayList();
list.add(attribute);
epr.setMetadataAttributes(list);
WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Final.WSA_NAMESPACE);
assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
assertEquals(wsdlLocation.getLocation(), location);
}
use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class EndpointReferenceHelperTest method testSetAndGetWSDLLocationMetadataForSubmissionSpecEPR.
public void testSetAndGetWSDLLocationMetadataForSubmissionSpecEPR() 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.Submission.WSA_NAMESPACE, new WSDLLocation(targetNamespace, location));
WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Submission.WSA_NAMESPACE);
assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
assertEquals(wsdlLocation.getLocation(), location);
}
use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class PackageSetBuilder method getPackagesFromSchema.
/**
* Walks the schemas of the serviceDesc's wsdl (or generated wsdl) to determine the list of
* packages. This is the preferred algorithm for discovering the package set.
*
* @param serviceDesc ServiceDescription
* @return Set of Packages
*/
public static TreeSet<String> getPackagesFromSchema(ServiceDescription serviceDesc) {
if (log.isDebugEnabled()) {
log.debug("start getPackagesFromSchema");
log.debug("ServiceDescription = " + serviceDesc.toString());
}
TreeSet<String> set = new TreeSet<String>();
// If we are on client side we will get wsdl definition from ServiceDescription. If we are on server side we will have to
// read wsdlLocation from @WebService Annotation.
ServiceDescriptionWSDL sdw = (ServiceDescriptionWSDL) serviceDesc;
Definition wsdlDefinition = sdw.getWSDLDefinition();
Collection<EndpointDescription> endpointDescs = serviceDesc.getEndpointDescriptions_AsCollection();
if (endpointDescs != null) {
for (EndpointDescription ed : endpointDescs) {
if (wsdlDefinition == null) {
// Let see if we can get wsdl definition from endpoint @WebService annotation.
if (ed instanceof EndpointDescriptionJava) {
String wsdlLocation = ((EndpointDescriptionJava) ed).getAnnoWebServiceWSDLLocation();
wsdlDefinition = getWSDLDefinition(wsdlLocation);
}
}
// on client side) or we got it from the @WebService annotation (which means we are running this code on server side)
if (wsdlDefinition != null) {
SchemaReader sr = new SchemaReaderImpl();
try {
Set<String> pkgSet = sr.readPackagesFromSchema(wsdlDefinition);
set.addAll(pkgSet);
} catch (SchemaReaderException e) {
throw ExceptionFactory.makeWebServiceException(e);
}
}
}
}
if (log.isDebugEnabled()) {
log.debug("end getPackagesFromSchema");
}
return set;
}
use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class Provider method getPort.
@Override
public <T> T getPort(EndpointReference jaxwsEPR, Class<T> sei, WebServiceFeature... features) {
if (jaxwsEPR == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNoEndpointReference2"));
}
if (sei == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("getPortInvalidSEI", jaxwsEPR.toString(), "null"));
}
org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils.createAxis2EndpointReference("");
String addressingNamespace = null;
try {
addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2EPR, jaxwsEPR);
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("invalidEndpointReference", e.toString()));
}
org.apache.axis2.jaxws.spi.ServiceDelegate serviceDelegate = null;
try {
ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(axis2EPR, addressingNamespace);
WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(axis2EPR, addressingNamespace);
URL wsdlLocationURL = null;
if (wsdlLocation.getLocation() != null) {
wsdlLocationURL = new URL(wsdlLocation.getLocation());
if (log.isDebugEnabled()) {
log.debug("getPort: Using EPR wsdlLocationURL = " + wsdlLocationURL);
}
} else {
wsdlLocationURL = new URL(axis2EPR.getAddress() + "?wsdl");
if (log.isDebugEnabled()) {
log.debug("getPort: Using default wsdlLocationURL = " + wsdlLocationURL);
}
}
serviceDelegate = new org.apache.axis2.jaxws.spi.ServiceDelegate(wsdlLocationURL, serviceName.getName(), Service.class);
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointUpdateError"), e);
}
return serviceDelegate.getPort(axis2EPR, addressingNamespace, sei, features);
}
use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.
the class GorillaDLWProxyTests method getProxy.
/**
* Utility method to get the proxy
* @return GorillaInterface proxy
* @throws MalformedURLException
*/
public GorillaInterface getProxy() throws Exception {
File wsdl = new File(wsdlLocation);
URL wsdlUrl = wsdl.toURI().toURL();
Service service = Service.create(null, serviceName);
Object proxy = service.getPort(portName, GorillaInterface.class);
BindingProvider p = (BindingProvider) proxy;
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, server.getEndpoint("GorillaService.GorillaProxyImplPort"));
return (GorillaInterface) proxy;
}
Aggregations