endpointdescriptionimpl.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,359 行 · 第 1/5 页
JAVA
1,359 行
//Otherwise, build the EID based on the SEI composite
endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(
getServiceDescriptionImpl().getDBCMap().get(seiClassName),
false,
this);
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("WebServiceProvider without WSDL encountered");
}
// REVIEW: Currently this is only supported for HTTP Bindings; SOAPBindings
// for providers currently require that there be WSDL.
String bindingType = getBindingType();
if (javax.xml.ws.http.HTTPBinding.HTTP_BINDING.equals(bindingType)) {
endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(composite, this);
}
}
}
public QName getPortQName() {
// REVIEW: Implement WSDL/Annotation merge? May be OK as is; not sure how would know WHICH port Qname to get out of the WSDL if
// we didn't use annotations.
if (portQName == null) {
// The name was not set by the constructors, so get it from the
// appropriate annotation.
String name = getAnnoWebServicePortName();
String tns = getAnnoWebServiceTargetNamespace();
// TODO: Check for name &/| tns null or empty string and add tests for same
portQName = new QName(tns, name);
}
return portQName;
}
public QName getServiceQName() {
if (serviceQName == null) {
// If the service name has been set on the Service, use that. Otherwise
// get the name off the annotations
QName serviceDescQName = getServiceDescription().getServiceQName();
if (!DescriptionUtils.isEmpty(serviceDescQName)) {
serviceQName = serviceDescQName;
} else {
String localPart = getAnnoWebServiceServiceName();
String tns = getAnnoWebServiceTargetNamespace();
serviceQName = new QName(tns, localPart);
}
}
return serviceQName;
}
public ServiceDescription getServiceDescription() {
return parentServiceDescription;
}
ServiceDescriptionImpl getServiceDescriptionImpl() {
return (ServiceDescriptionImpl)parentServiceDescription;
}
public EndpointInterfaceDescription getEndpointInterfaceDescription() {
return endpointInterfaceDescription;
}
public AxisService getAxisService() {
return axisService;
}
boolean isDynamicPort() {
return isDynamicPort;
}
void updateWithSEI(Class sei) {
// Updating with an SEI is only valid for declared ports; it is not valid for dynamic ports.
if (isDynamicPort()) {
// TODO: RAS and NLS
throw ExceptionFactory.makeWebServiceException(
"Can not update an SEI on a dynamic port. PortQName:" + portQName);
}
if (sei == null) {
// TODO: RAS and NLS
throw ExceptionFactory.makeWebServiceException(
"EndpointDescription.updateWithSEI was passed a null SEI. PortQName:" +
portQName);
}
if (endpointInterfaceDescription != null) {
// The EndpointInterfaceDescription was created previously based on the port declaration (i.e. WSDL)
// so update that with information from the SEI annotations
((EndpointInterfaceDescriptionImpl)endpointInterfaceDescription).updateWithSEI(sei);
} else {
// An EndpointInterfaceDescription does not exist yet. This currently happens in the case where there is
// NO WSDL provided and a Dispatch client is created for prior to a getPort being done for that port.
// There was no WSDL to create the EndpointInterfaceDescription from and there was no annotated SEI to
// use at that time. Now we have an annotated SEI, so create the EndpointInterfaceDescription now.
endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(sei, this);
}
return;
}
private void setupAxisService() {
// TODO: Need to use MetaDataQuery validator to merge WSDL (if any) and annotations (if any)
// Build up the AxisService. Note that if this is a dynamic port, then we don't use the
// WSDL to build up the AxisService since the port added to the Service by the client is not
// one that will be present in the WSDL. A null class passed in as the SEI indicates this
// is a dispatch client.
if (!isDynamicPort && getServiceDescriptionImpl().getWSDLWrapper() != null) {
isAxisServiceBuiltFromWSDL = buildAxisServiceFromWSDL();
} else {
buildAxisServiceFromAnnotations();
}
if (axisService == null) {
// TODO: RAS & NLS
throw ExceptionFactory.makeWebServiceException("Unable to create AxisService for "
+ createAxisServiceName());
}
// Save the Service QName as a parameter.
Parameter serviceNameParameter = new Parameter();
serviceNameParameter.setName(WSDL11ToAllAxisServicesBuilder.WSDL_SERVICE_QNAME);
serviceNameParameter.setValue(getServiceDescription().getServiceQName());
// Save the Port name. Note: Axis does not expect a QName since the namespace for the port is the ns from the WSDL definition
Parameter portParameter = new Parameter();
portParameter.setName(WSDL11ToAllAxisServicesBuilder.WSDL_PORT);
portParameter.setValue(portQName.getLocalPart());
try {
axisService.addParameter(serviceNameParameter);
axisService.addParameter(portParameter);
}
catch (AxisFault e) {
// TODO RAS
e.printStackTrace();
}
}
/*
* This setups and builds the AxisService using only the DescriptionBuilderCompositeList
*
*/
private void setupAxisServiceFromDBL() {
// TODO: Need to use MetaDataQuery validator to merge WSDL (if any) and annotations (if any)
// Build up the AxisService. Note that if this is a dispatch client, then we don't use the
// WSDL to build up the AxisService since the port added to the Service by the client is not
// one that will be present in the WSDL. A null class passed in as the SEI indicates this
// is a dispatch client.
// If WSDL is present, it may be full or only partial. If we can create the AxisService from
// the WSDL, that WSDL is fully specified. Otherwise, it is "partial WSDL". In that case
// we use annotaions to build the AxisService
isAxisServiceBuiltFromWSDL = false;
if (getServiceDescriptionImpl().getWSDLWrapper() != null) {
isAxisServiceBuiltFromWSDL = buildAxisServiceFromWSDL();
}
if (!isAxisServiceBuiltFromWSDL) {
//generateWSDL(composite);
buildAxisServiceFromAnnotations();
}
if (axisService == null) {
// TODO: RAS & NLS
throw ExceptionFactory.makeWebServiceException("Unable to create AxisService for "
+ createAxisServiceName());
}
//Save the Port Type name
Parameter portTypeNameParameter = new Parameter();
portTypeNameParameter.setName(MDQConstants.WSDL_PORTTYPE_NAME);
portTypeNameParameter.setValue(getName());
// Save the Service QName as a parameter.
Parameter serviceNameParameter = new Parameter();
serviceNameParameter.setName(MDQConstants.WSDL_SERVICE_QNAME);
serviceNameParameter.setValue(getServiceDescription().getServiceQName());
// Save the Port name. Note: Axis does not expect a QName since the namespace
// for the port is the ns from the WSDL definition
Parameter portParameter = new Parameter();
portParameter.setName(MDQConstants.WSDL_PORT);
portParameter.setValue(getPortQName().getLocalPart());
//Save the fully qualified class name for the serviceImpl
Parameter serviceClassNameParameter = new Parameter();
serviceClassNameParameter.setName(MDQConstants.SERVICE_CLASS);
serviceClassNameParameter
.setValue(DescriptionUtils.javifyClassName(composite.getClassName()));
try {
axisService.addParameter(portTypeNameParameter);
axisService.addParameter(serviceNameParameter);
axisService.addParameter(portParameter);
axisService.addParameter(serviceClassNameParameter);
}
catch (AxisFault e) {
// TODO RAS
e.printStackTrace();
}
}
private boolean buildAxisServiceFromWSDL() {
boolean isBuiltFromWSDL = false;
try {
// TODO: Change this to use WSDLToAxisServiceBuilder superclass
// Note that the axis service builder takes only the localpart of the port qname.
// TODO:: This should check that the namespace of the definition matches the namespace of the portQName per JAXRPC spec
WSDLWrapper wrapper = getServiceDescriptionImpl().getWSDLWrapper();
WSDL11ToAxisServiceBuilder serviceBuilder =
new WSDL11ToAxisServiceBuilder(
wrapper.getDefinition(),
getServiceDescription().getServiceQName(),
getPortQName().getLocalPart());
//TODO: Temporary, please change the following log.info to log.debug
log.info("Building AxisService from wsdl: " + wrapper.getWSDLLocation());
if (getServiceDescriptionImpl().isDBCMap()) {
//this.class.getClass().getClassLoader();
URIResolverImpl uriResolver =
new URIResolverImpl(composite.getClassLoader());
serviceBuilder.setCustomResolver(uriResolver);
} else {
ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged(new
PrivilegedAction() {
public Object run() {
return Thread.currentThread().getContextClassLoader();
}
});
URIResolverImpl uriResolver = new URIResolverImpl(classLoader);
serviceBuilder.setCustomResolver(uriResolver);
}
// TODO: Currently this only builds the client-side AxisService;
// it needs to do client and server somehow.
// Patterned after AxisService.createClientSideAxisService
if (getServiceDescriptionImpl().isServerSide())
serviceBuilder.setServerSide(true);
else
serviceBuilder.setServerSide(false);
axisService = serviceBuilder.populateService();
axisService.setName(createAxisServiceName());
isBuiltFromWSDL = true;
} catch (AxisFault e) {
// REVIEW: If we couldn't use the WSDL, should we fail instead of continuing to process using annotations?
// Note that if we choose to fail, we need to distinguish the partial WSDL case (which can not fail)
// TODO: RAS/NLS Need to update the message with the appropriate inserts
// log.warn(Messages.getMessage("warnAxisFault", e.toString()), e);
String wsdlLocation = (getServiceDescriptionImpl().getWSDLLocation() != null) ?
getServiceDescriptionImpl().getWSDLLocation().toString() : null;
String implClassName = null;
if (getServiceDescriptionImpl().isDBCMap()) {
implClassName = composite.getClassName();
} else {
implClassName = (implOrSEIClass != null) ? implOrSEIClass.getName() : null;
}
log.warn(
"The WSDL file could not be used due to an exception. The WSDL will be ignored and annotations will be used. Implementaiton class: "
+ implClassName + "; WSDL Location: " + wsdlLocation + "; Exception: " +
e.toString(), e);
isBuiltFromWSDL = false;
return isBuiltFromWSDL;
}
return isBuiltFromWSDL;
}
private void buildAxisServiceFromAnnotations() {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?