3 Replies Latest reply on Sep 1, 2006 4:11 AM by Thomas Diesler

    Programmatic service deployment, again!

    Doug Palmer Newbie

      Hi

      I'm still trying to add aliases for a web service at runtime. I have managed to persuade JBossWS to deploy my service endpoint but my service doesn't get registered with tomcat and requests to the context root return a 404 error. I guess I have missed a step in the deployment; can anyone tell me what I am missing? Here is the code I have so far:

       String targetNS = "http://services/jaws";
       String serviceName = "aService";
       String portName = "aServicePort";
       String operationName = "anOperation";
      
       String javaClassName = this.getClass().getName();
       String javaMethodName = "method";
       String contextRoot = "contextRoot";
       String endpoint = "http://localhost:8080/"+contextRoot+"/"+serviceName;
      
       UnifiedDeploymentInfo udi = new JSR181Deployment(UnifiedDeploymentInfo.Type.JSR181_JSE);
       URLClassLoader ctxLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
       udi.localCl = ctxLoader;
       udi.ucl = ctxLoader.getParent();
       udi.annotationsCl = ctxLoader.getParent();
      
       UnifiedMetaData wsMetaData = new UnifiedMetaData();
       wsMetaData.setClassLoader(udi.ucl);
       ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, new QName(targetNS, serviceName));
       wsMetaData.addService(serviceMetaData);
      
       ServerEndpointMetaData sepMetaData = new ServerEndpointMetaData(serviceMetaData, new QName(targetNS, portName));
       sepMetaData.setServiceEndpointImplName(javaClassName);
       sepMetaData.setStyle(Style.RPC);
       sepMetaData.setEncodingStyle(Use.LITERAL);
       sepMetaData.setParameterStyle(ParameterStyle.BARE);
       sepMetaData.setServiceEndpointID(ObjectNameFactory.create("jboss.ws:context="+contextRoot+",endpoint="+serviceName));
       sepMetaData.setEndpointAddress(endpoint);
       sepMetaData.setContextRoot(contextRoot);
       serviceMetaData.addEndpoint(sepMetaData);
      
       OperationMetaData opMetaData = new OperationMetaData(sepMetaData, new QName(targetNS, operationName), javaMethodName);
       opMetaData.setOneWayOperation(false);
       sepMetaData.addOperation(opMetaData);
      
       ServiceEndpointInfo seInfo = new ServiceEndpointInfo(udi, sepMetaData);
       ServiceEndpointManagerFactory semFactory = ServiceEndpointManagerFactory.getInstance();
       ServiceEndpointManager epManager = semFactory.getServiceEndpointManager();
       epManager.createServiceEndpoint(seInfo);
      
       ObjectName sepID = sepMetaData.getServiceEndpointID();
       epManager.startServiceEndpoint(sepID);
      


      Thanks in advance
      Doug