endpointdescriptionimpl.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,359 行 · 第 1/5 页
JAVA
1,359 行
// TODO: Refactor this to create from annotations.
String serviceName = null;
if (portQName != null) {
serviceName = createAxisServiceName();
} else {
// REVIEW: Can the portQName ever be null?
// Make this service name unique. The Axis2 engine assumes that a service it can not find is a client-side service.
serviceName = ServiceClient.ANON_SERVICE + this.hashCode() + System.currentTimeMillis();
}
axisService = new AxisService(serviceName);
//TODO: Set other things on AxisService here, this function may have to be
// moved to after we create all the AxisOperations
}
private void buildDescriptionHierachy() {
// Build up the Description Hierachy. Note that if this is a dynamic port, then we don't use the
// WSDL to build up the hierachy since the port added to the Service by the client is not
// one that will be present in the WSDL.
//First, check to see if we can build this with the DBC List
//TODO: When MDQ input is the only possible input, then we can remove the check for
// the DBC list, until that time the code in here may appear somewhat redundant
if (getServiceDescriptionImpl().isDBCMap()) {
if (!isDynamicPort && isWSDLFullySpecified())
buildEndpointDescriptionFromWSDL();
else
buildEndpointDescriptionFromAnnotations();
} else {
//Still processing annotations from the class
// This path was not updated
if (!isDynamicPort && isWSDLFullySpecified()) {
buildEndpointDescriptionFromWSDL();
} else if (implOrSEIClass != null) {
// Create the rest of the description hierachy from annotations on the class.
// If there is no SEI class, then this is a Distpach case, and we currently
// don't create the rest of the description hierachy (since it is not an SEI and thus
// not operation-based client.
buildEndpointDescriptionFromAnnotations();
}
}
}
private void buildEndpointDescriptionFromWSDL() {
Definition wsdlDefinition = getServiceDescriptionImpl().getWSDLWrapper().getDefinition();
javax.wsdl.Service wsdlService =
wsdlDefinition.getService(getServiceDescription().getServiceQName());
if (wsdlService == null) {
throw ExceptionFactory.makeWebServiceException(
Messages.getMessage("serviceDescErr2", createAxisServiceName()));
}
Map wsdlPorts = wsdlService.getPorts();
boolean wsdlPortFound = false;
if (wsdlPorts != null && wsdlPorts.size() > 0) {
Iterator wsdlPortIterator = wsdlPorts.values().iterator();
while (wsdlPortIterator.hasNext() && !wsdlPortFound) {
Port wsdlPort = (Port)wsdlPortIterator.next();
// Note the namespace is not included on the WSDL Port.
if (wsdlPort.getName().equals(portQName.getLocalPart())) {
// Build the EndpointInterface based on the specified SEI if there is one
// or on the service impl class (i.e. an implicit SEI).
if (getServiceDescriptionImpl().isDBCMap()) {
String seiClassName = getAnnoWebServiceEndpointInterface();
if (DescriptionUtils.isEmpty(seiClassName)) {
// No SEI specified, so use the service impl as an implicit SEI
endpointInterfaceDescription =
new EndpointInterfaceDescriptionImpl(composite, true, this);
} else {
// Otherwise, build the EID based on the SEI composite
endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(
getServiceDescriptionImpl().getDBCMap().get(seiClassName),
false,
this);
}
} else {
// Create the Endpoint Interface Description based on the WSDL.
endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(this);
// Update the EndpointInterfaceDescription created with WSDL with information from the
// annotations in the SEI
((EndpointInterfaceDescriptionImpl)endpointInterfaceDescription)
.updateWithSEI(implOrSEIClass);
}
wsdlPortFound = true;
}
}
}
if (!wsdlPortFound) {
// TODO: NLS and RAS
throw ExceptionFactory.makeWebServiceException(
"WSDL Port not found for port " + portQName.getLocalPart());
}
}
/**
* Adds the anonymous axis operations to the AxisService. Note that this is only needed on the
* client side, and they are currently used in two cases (1) For Dispatch clients (which don't
* use SEIs and thus don't use operations) (2) TEMPORARLIY for Services created without WSDL
* (and thus which have no AxisOperations created) See the AxisInvocationController invoke
* methods for more details.
* <p/>
* Based on ServiceClient.createAnonymouService
*/
private void addAnonymousAxisOperations() {
if (axisService != null) {
OutOnlyAxisOperation outOnlyOperation =
new OutOnlyAxisOperation(ServiceClient.ANON_OUT_ONLY_OP);
axisService.addOperation(outOnlyOperation);
OutInAxisOperation outInOperation =
new OutInAxisOperation(ServiceClient.ANON_OUT_IN_OP);
axisService.addOperation(outInOperation);
}
}
public ServiceClient getServiceClient() {
try {
if (serviceClient == null) {
ConfigurationContext configCtx = getServiceDescription().getAxisConfigContext();
AxisService axisSvc = getAxisService();
AxisConfiguration axisCfg = configCtx.getAxisConfiguration();
if (axisCfg.getService(axisSvc.getName()) != null) {
axisSvc.setName(axisSvc.getName() + this.hashCode());
}
serviceClient = new ServiceClient(configCtx, axisSvc);
}
} catch (AxisFault e) {
throw ExceptionFactory.makeWebServiceException(
Messages.getMessage("serviceClientCreateError"), e);
}
return serviceClient;
}
//This should eventually be deprecated in favor 'createAxisServiceNameFromDBL
private String createAxisServiceName() {
String portName = null;
if (portQName != null) {
portName = portQName.getLocalPart();
} else {
portName = "NoPortNameSpecified";
}
return getServiceDescription().getServiceQName().getLocalPart() + "." + portName;
}
public boolean isWSDLFullySpecified() {
return isAxisServiceBuiltFromWSDL;
}
public boolean isProviderBased() {
return webServiceProviderAnnotation != null;
}
public boolean isEndpointBased() {
return webServiceAnnotation != null;
}
// ===========================================
// ANNOTATION: WebService and WebServiceProvider
// ===========================================
public String getAnnoWebServiceWSDLLocation() {
if (annotation_WsdlLocation == null) {
if (getAnnoWebService() != null) {
annotation_WsdlLocation = getAnnoWebService().wsdlLocation();
//If this is not an implicit SEI, then make sure that its not on the SEI
if (getServiceDescriptionImpl().isDBCMap()) {
if (!DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface())) {
DescriptionBuilderComposite seic =
getServiceDescriptionImpl().getDBCMap()
.get(composite.getWebServiceAnnot().endpointInterface());
if (!DescriptionUtils.isEmpty(seic.getWebServiceAnnot().wsdlLocation())) {
annotation_WsdlLocation = seic.getWebServiceAnnot().wsdlLocation();
}
}
}
} else if (getAnnoWebServiceProvider() != null
&& !DescriptionUtils.isEmpty(getAnnoWebServiceProvider().wsdlLocation())) {
annotation_WsdlLocation = getAnnoWebServiceProvider().wsdlLocation();
} else {
// There is no default value per JSR-181 MR Sec 4.1 pg 16
annotation_WsdlLocation = "";
}
}
return annotation_WsdlLocation;
}
public String getAnnoWebServiceServiceName() {
if (annotation_ServiceName == null) {
if (getAnnoWebService() != null
&& !DescriptionUtils.isEmpty(getAnnoWebService().serviceName())) {
annotation_ServiceName = getAnnoWebService().serviceName();
} else if (getAnnoWebServiceProvider() != null
&& !DescriptionUtils.isEmpty(getAnnoWebServiceProvider().serviceName())) {
annotation_ServiceName = getAnnoWebServiceProvider().serviceName();
} else {
// Default value is the "simple name" of the class or interface + "Service"
// Per JSR-181 MR Sec 4.1, pg 15
if (getServiceDescriptionImpl().isDBCMap()) {
annotation_ServiceName = DescriptionUtils
.getSimpleJavaClassName(composite.getClassName()) + "Service";
} else {
annotation_ServiceName =
DescriptionUtils.getSimpleJavaClassName(implOrSEIClass) + "Service";
}
}
}
return annotation_ServiceName;
}
public String getAnnoWebServicePortName() {
if (annotation_PortName == null) {
if (getAnnoWebService() != null
&& !DescriptionUtils.isEmpty(getAnnoWebService().portName())) {
annotation_PortName = getAnnoWebService().portName();
} else if (getAnnoWebServiceProvider() != null
&& !DescriptionUtils.isEmpty(getAnnoWebServiceProvider().portName())) {
annotation_PortName = getAnnoWebServiceProvider().portName();
} else {
// Default the value
if (isProviderBased()) {
// This is the @WebServiceProvider annotation path
// Default value is not specified in JSR-224, but we can assume it is
// similar to the default in the WebService case, however there is no
// name attribute for a WebServiceProvider. So in this case we use
// the default value for WebService.name per JSR-181 MR sec 4.1 pg 15.
// Note that this is really the same thing as the call to getWebServiceName()
// in the WebService case; it is done sepertely just to be clear there is no
// name element on the WebServiceProvider annotation
annotation_PortName = (getServiceDescriptionImpl().isDBCMap()) ?
DescriptionUtils.getSimpleJavaClassName(composite.getClassName()) +
"Port"
: DescriptionUtils.getSimpleJavaClassName(implOrSEIClass) + "Port";
} else {
// This is the @WebService annotation path
// Default value is the @WebService.name of the class or interface + "Port"
// Per JSR-181 MR Sec 4.1, pg 15
annotation_PortName = getAnnoWebServiceName() + "Port";
}
}
}
return annotation_PortName;
}
public String getAnnoWebServiceTargetNamespace() {
if (annotation_TargetNamespace == null) {
if (getAnnoWebService() != null
&& !DescriptionUtils.isEmpty(getAnnoWebService().targetNamespace())) {
annotation_TargetNamespace = getAnnoWebService().targetNamespace();
} else if (getAnnoWebServiceProvider() != null
&& !DescriptionUtils.isEmpty(getAnnoWebServiceProvider().targetNamespace())) {
annotation_TargetNamespace = getAnnoWebServiceProvider().targetNamespace();
} else {
// Default value per JSR-181 MR Sec 4.1 pg 15 defers to "Implementation defined,
// as described in JAX-WS 2.0, section 3.2" which is JAX-WS 2.0 Sec 3.2, pg 29.
// FIXME: Hardcoded protocol for namespace
if (getServiceDescriptionImpl().isDBCMap())
annotation_TargetNamespace =
DescriptionUtils.makeNamespaceFromPackageName(
DescriptionUtils.getJavaPackageName(composite.getClassName()),
"http");
else
annotation_TargetNamespace =
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?