private Object getInstance ( TransientWebServiceRefInfo tInfo , WebServiceRefInfo wsrInfo ) throws Exception { Object instance = null ; // First, obtain an instance of the JAX-WS Service class. Service svc = null ; List < WebServiceFeature > originalWsFeatureList = LibertyProviderImpl . getWebServiceFeatures ( ) ; WebServiceRefInfo originalWebServiceRefInfo = LibertyProviderImpl . getWebServiceRefInfo ( ) ; try { //Check @MTOM @RespectBinding @Addressing //set web service features to ThreadLocal final List < WebServiceFeature > wsFeatureList = wsrInfo . getWSFeatureForSEIClass ( wsrInfo . getServiceRefTypeClassName ( ) ) ; LibertyProviderImpl . setWebServiceRefInfo ( wsrInfo ) ; LibertyProviderImpl . setWebServiceFeatures ( wsFeatureList ) ; svc = getServiceInstance ( tInfo , wsrInfo ) ; } finally { LibertyProviderImpl . setWebServiceFeatures ( originalWsFeatureList ) ; LibertyProviderImpl . setWebServiceRefInfo ( originalWebServiceRefInfo ) ; } // Set handlerResolver svc . setHandlerResolver ( new JaxWsClientHandlerResolver ( tInfo . getWebServiceRefInfo ( ) , tInfo . getClientMetaData ( ) ) ) ; // Next, retrieve the "type" class, which corresponds to the service-ref-type attribute. // If the "typeClass" is *not* the default (Object.class) *and* it's also not a subclass of the Service class, // then we have a situation where the user wants to do a port-type injection. // In that case, we need to call Service.getPort() on the service instance we just obtained above. Class < ? > typeClass = tInfo . getServiceRefTypeClass ( ) ; if ( typeClass != null && ! typeClass . getName ( ) . equals ( Object . class . getName ( ) ) && ! Service . class . isAssignableFrom ( typeClass ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Creating a port instance based on class: " + tInfo . getServiceRefTypeClass ( ) . getName ( ) ) ; } instance = svc . getPort ( typeClass ) ; } else { // Otherwise, this was just a normal Service-type injection so we'll return the service. if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Service instance created based on class: " + svc . getClass ( ) . getName ( ) ) ; } instance = svc ; } return instance ; }
This method will create an instance of a JAX - WS service ref using the metadata supplied in the WebServiceRefInfo object .