6 Replies Latest reply on Oct 3, 2008 4:33 AM by Jorge Morales

    Are ports reusable/concurrent?

    Jorge Morales Master

      Hi, I'm developing an application with JBossWS, and using it as server and as client, invoking some other webservices in other servers.
      Doing tunning of my app, I have found that too much time is spent every time I invoke getPort on a service, as it seems that everytime is generating the port on the fly.


      2008-10-01 15:46:18,103:org.jboss.ws.core.jaxws.spi.ServiceDelegateImplCannot get port meta data for: {http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms|
      2008-10-01 15:46:18,103:org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilderSTART: rebuildMetaData|
      2008-10-01 15:46:18,103:org.jboss.ws.metadata.umdm.EndpointMetaDatasetParameterStyle: null|
      2008-10-01 15:46:18,103:org.jboss.ws.metadata.umdm.EndpointMetaDataCreate new config [name=Standard Client,file=META-INF/standard-jaxws-client-config.xml]|
      2008-10-01 15:46:18,103:org.jboss.ws.metadata.config.JBossWSConfigFactorygetConfig: [name=Standard Client,url=META-INF/standard-jaxws-client-config.xml]|
      2008-10-01 15:46:18,103:org.jboss.ws.metadata.config.JBossWSConfigFactoryparse: file:/C:/jboss-4.2.3/core/server/som/deploy/jbossws.sar/META-INF/standard-jaxws-client-config.xml|
      2008-10-01 15:46:18,181:org.jboss.ws.metadata.umdm.EndpointConfigMetaDataConfigure EndpointMetaData|
      2008-10-01 15:46:18,181:org.jboss.ws.metadata.umdm.EndpointConfigMetaDataAdded 0 PRE handlers|
      2008-10-01 15:46:18,181:org.jboss.ws.metadata.umdm.EndpointConfigMetaDataAdded 0 ENDPOINT handlers|
      2008-10-01 15:46:18,181:org.jboss.ws.metadata.umdm.EndpointConfigMetaDataAdded 0 POST handlers|
      2008-10-01 15:46:18,181:org.jboss.ws.metadata.umdm.EndpointMetaDatasetParameterStyle: WRAPPED|
      2008-10-01 15:46:18,181:org.jboss.ws.metadata.umdm.EndpointMetaDataUsing default style: document|
      2008-10-01 15:46:18,213:org.jboss.ws.metadata.umdm.EndpointMetaDatasetParameterStyle: WRAPPED|
      2008-10-01 15:46:18,228:org.jboss.ws.metadata.umdm.EndpointMetaDatasetParameterStyle: WRAPPED|
      2008-10-01 15:46:18,228:org.jboss.ws.metadata.umdm.EndpointMetaDatasetParameterStyle: WRAPPED|
      2008-10-01 15:46:18,244:org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilderJAXBContext [types=[class com.hp.som.ws.parlayx21.sms.send.SendSms_Type, class com.hp.som.ws.parlayx21.sms.send.SendSmsResponse, class com.hp.som.ws.parlayx21.common.PolicyExceptionInfo, class com.hp.som.ws.parlayx21.common.ServiceExceptionInfo, class com.hp.som.ws.parlayx21.sms.send.SendSmsRingtone, class com.hp.som.ws.parlayx21.sms.send.SendSmsRingtoneResponse, class com.hp.som.ws.parlayx21.common.PolicyExceptionInfo, class com.hp.som.ws.parlayx21.common.ServiceExceptionInfo, class com.hp.som.ws.parlayx21.sms.send.SendSmsLogo, class com.hp.som.ws.parlayx21.sms.send.SendSmsLogoResponse, class com.hp.som.ws.parlayx21.common.PolicyExceptionInfo, class com.hp.som.ws.parlayx21.common.ServiceExceptionInfo, class com.hp.som.ws.parlayx21.sms.send.GetSmsDeliveryStatus, class com.hp.som.ws.parlayx21.sms.send.GetSmsDeliveryStatusResponse, class com.hp.som.ws.parlayx21.common.PolicyExceptionInfo, class com.hp.som.ws.parlayx21.common.ServiceExceptionInfo],tns=http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface]|
      2008-10-01 15:46:18,478:org.jboss.ws.metadata.umdm.OperationMetaDataFound best matching java method: public abstract java.lang.String com.hp.som.ws.parlayx21.sms.send.SendSms.sendSms(java.util.List,java.lang.String,com.hp.som.ws.parlayx21.common.ChargingInformation,java.lang.String,com.hp.som.ws.parlayx21.common.SimpleReference) throws com.hp.som.ws.parlayx21.common.PolicyException,com.hp.som.ws.parlayx21.common.ServiceException|
      2008-10-01 15:46:18,478:org.jboss.ws.metadata.umdm.OperationMetaDataFound best matching java method: public abstract java.lang.String com.hp.som.ws.parlayx21.sms.send.SendSms.sendSmsRingtone(java.util.List,java.lang.String,com.hp.som.ws.parlayx21.common.ChargingInformation,java.lang.String,com.hp.som.ws.parlayx21.sms.common.SmsFormat,com.hp.som.ws.parlayx21.common.SimpleReference) throws com.hp.som.ws.parlayx21.common.PolicyException,com.hp.som.ws.parlayx21.common.ServiceException|
      2008-10-01 15:46:18,509:org.jboss.ws.metadata.umdm.OperationMetaDataFound best matching java method: public abstract java.lang.String com.hp.som.ws.parlayx21.sms.send.SendSms.sendSmsLogo(java.util.List,java.lang.String,com.hp.som.ws.parlayx21.common.ChargingInformation,byte[],com.hp.som.ws.parlayx21.sms.common.SmsFormat,com.hp.som.ws.parlayx21.common.SimpleReference) throws com.hp.som.ws.parlayx21.common.PolicyException,com.hp.som.ws.parlayx21.common.ServiceException|
      2008-10-01 15:46:18,509:org.jboss.ws.metadata.umdm.OperationMetaDataFound best matching java method: public abstract java.util.List com.hp.som.ws.parlayx21.sms.send.SendSms.getSmsDeliveryStatus(java.lang.String) throws com.hp.som.ws.parlayx21.common.PolicyException,com.hp.som.ws.parlayx21.common.ServiceException|
      2008-10-01 15:46:18,509:org.jboss.ws.metadata.umdm.EndpointMetaDataUsing default encoding style: literal|
      2008-10-01 15:46:18,572:org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilderEND: rebuildMetaData

      ServiceMetaData:
      qname={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms
      refName=null
      wsdName=null
      wsdlFile=null
      wsdlLocation=null
      jaxrpcMapping=null
      publishLocation=null
      securityConfig=null
      properties=null

      TypesMetaData:
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}sendSms,javaType=com.hp.som.ws.parlayx21.sms.send.SendSms_Type]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}sendSmsResponse,javaType=com.hp.som.ws.parlayx21.sms.send.SendSmsResponse]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}PolicyException,javaType=com.hp.som.ws.parlayx21.common.PolicyExceptionInfo]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}ServiceException,javaType=com.hp.som.ws.parlayx21.common.ServiceExceptionInfo]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}sendSmsRingtone,javaType=com.hp.som.ws.parlayx21.sms.send.SendSmsRingtone]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}sendSmsRingtoneResponse,javaType=com.hp.som.ws.parlayx21.sms.send.SendSmsRingtoneResponse]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}sendSmsLogo,javaType=com.hp.som.ws.parlayx21.sms.send.SendSmsLogo]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}sendSmsLogoResponse,javaType=com.hp.som.ws.parlayx21.sms.send.SendSmsLogoResponse]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}getSmsDeliveryStatus,javaType=com.hp.som.ws.parlayx21.sms.send.GetSmsDeliveryStatus]
      [complexType={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/interface}getSmsDeliveryStatusResponse,javaType=com.hp.som.ws.parlayx21.sms.send.GetSmsDeliveryStatusResponse]

      |
      2008-10-01 15:46:18,572:org.jboss.ws.metadata.umdm.EndpointMetaDataConfigure SOAPBinding|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.handler.HandlerResolverImplinitHandlerChain: PRE|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.handler.HandlerResolverImplinitHandlerChain: ENDPOINT|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.handler.HandlerResolverImplinitHandlerChain: POST|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.handler.HandlerResolverImplgetHandlerChain: [type=PRE,info=[service={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms,port={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms,binding=http://schemas.xmlsoap.org/wsdl/soap/http]]|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.handler.HandlerResolverImplgetHandlerChain: [type=POST,info=[service={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms,port={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms,binding=http://schemas.xmlsoap.org/wsdl/soap/http]]|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.handler.HandlerResolverImplgetHandlerChain: [type=ENDPOINT,info=[service={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms,port={http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms,binding=http://schemas.xmlsoap.org/wsdl/soap/http]]|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.binding.BindingImplsetHandlerChain: []|
      2008-10-01 15:46:18,572:org.jboss.ws.core.jaxws.spi.ServiceDelegateImplNo port configuration for: {http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service}SendSms|



      I don`t know if this is the correct usage pattern, or I should reuse the obtained Port.

      I have browse the tests and examples, but I haven`t been able to get a conclusion.
      Also, requests made to obtained port, must be done with different endpoint,timeout in some requests from other, so I don`t know If I should pool obtained port for every endpoint, and use pooled instances. Also, If I have 2 concurrent requests to send to same pooled port, is it going to have any problem, or it is thread safe?

      Now I'm doing a static service, and using as this:

      private String send(...params...){
       SendSmsService service = new SendSmsService(null, qname);
       SendSms stub = service.getSendSms();
       stub.getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT,1000);
      stub.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ...);
      response = stub.sendSms(...params....);
      return response;
      }
      ...
      And, the getSendSms in the port is:
      public class SendSmsService extends Service{
       ....
       public SendSms getSendSms() {
       return (SendSms)super.getPort(new QName("http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service", "SendSms"), SendSms.class);
       }
      }
      


        • 1. Re: Are ports reusable/concurrent?
          johanpersson Newbie

          Bundled WSDL file in META-INF in client and loads it with classloader works fine and reduces network traffic.

          URL wsdlURL = Resources.findFileAsURL(wsdlURLFileName);
          String namespaceURI = Resources.getProperty("namespaceURI");
          String localpart = Resources.getProperty("localpart");
          service = new MyService(wsdlURL, new QName(namespaceURI, localpart));
          port = service.getMyPort();
          ((StubExt)port).setConfigName("Standard WSSecurity Client");

          Port is reused (read somewhere port is not thread safe).

          Otherwise proxy will use URL hardcoded from proxygenerator.

          Works fine (for us).
          HTH.

          • 2. Re: Are ports reusable/concurrent?
            Jorge Morales Master

            We have done this:

             // Static initialization of webservice client
             static protected SendSms stub;
            
             static{
             QName qname = new QName(
             "http://www.csapi.org/wsdl/parlayx/sms/send/v2_2/service",
             "SendSms");
             SendSmsService service = new SendSmsService(null, qname);
             stub = service.getSendSms();
             }
            
            
             @Override
             protected String sendMessage(...params...) throws Exception {
             String response = null;
            
             if (stub==null){
             throw new Exception("There is no stub for SendSms PX 2.1 service created.");
             }
            
             //Configure stub
             stub.getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT,1000);
             stub.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ...);
             response = stub.sendSms(...params....);
             return response;
             }
            
            


            But I doing tests to see if it is ThreadSafe to do this, or configuring an endpoint on the stub, will afect other clients sending messages to a previously configured stub in a previous (but concurrent) call.

            In this cases I see that Stub generation only happens in the static initialization, and this way, performance is much more better.

            Am I doing something wrong?

            • 3. Re: Are ports reusable/concurrent?
              johanpersson Newbie

              (hope real experts can comment on this)

              For being on the safe side you shold not use concurrent calls on the port from your client app.. Instead collect your client calls and run them in sequence to the server endpoint...my personal opinion.

              • 4. Re: Are ports reusable/concurrent?
                Jorge Morales Master

                I have thought on initially creating a pool of ports, to eache endpoint I must use, and use these instances from pool, this way preventing concurrency, but I'm not sure if this is efficient, or even, really needed. I wanted to know prior to develop, because it`s a lot of work, since I have lots of clients, and different endpoints.
                Since my class is going to be invoked acting like a proxiing web service, I can't not guarantee there are not going to be concurrent invocations.

                • 5. Re: Are ports reusable/concurrent?
                  Richard Opalka Master

                  Take a look what our FAQ says.
                  There's also JBWS-2324.

                  • 6. Re: Are ports reusable/concurrent?
                    Jorge Morales Master

                    I've seen the FAQ and the Jira request, and now my question is, how are users using JBossWS as a client for, for example, acting as a proxy?
                    I hope there is a large users community that can share experience with us.