2 Replies Latest reply on Oct 28, 2007 6:08 AM by mattschmidtdz

    How to actually use your Webservice plugin?

      I've been experimenting with building a Webservice plugin this weekend that extends the current User Service.  My problem comes from the need to actually use that service outside of Jive.  Jive appears to be telling me that the service is there and the WSDL comes back normally, but how do I access it remotely?  All the examples in the webservices documentation talk about the ServiceLocator but I suspect I can't use that to get my own plugin based webservices.  Any help would be appreciated!

        • Re: How to actually use your Webservice plugin?

          ServiceLocator simply acts as a wrapper around the XFire Dynamic client proxy support. Using your webservice interface you can do the same thing by doing the following:

           

          
          Service serviceModel = objectServiceFactory.create(serviceClass, serviceName,
                              "http://jivesoftware.com/webservices/", null);
          
          serviceModel.setProperty("password", password);
          serviceModel.addOutHandler(new DOMOutHandler());
          Properties properties = new Properties();
          properties.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
          properties.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
          properties.setProperty(WSHandlerConstants.USER, username);
          serviceModel.addOutHandler(new WSS4JOutHandler(properties));
          
          MyService svc = (MyService) serviceModel;
          

           

          See ServiceLocator#createServiceProxy for more details.

            • Re: How to actually use your Webservice plugin?

              I tried doing that (based on the code in ServiceLocator and some other docs on XFire that I found, but I get an XFireFault.

               

              I think part of what I don't quite understand here is how does it know where to go for my remote service based on that code?

               

               

              I also get the following error with your code:

               

               

              java.lang.ClassCastException: org.codehaus.xfire.service.Service cannot be cast to com.dzone.clearspace.services.DzUserService

               

               

               

              ObjectServiceFactory objectServiceFactory = new AnnotationServiceFactory(new Jsr181WebAnnotations(),
              new DefaultXFire().getTransportManager(), new AegisBindingProvider(new JaxbTypeRegistry()));
              Service serviceModel = objectServiceFactory.create(DzUserService.class, "DzUserService",
              "http://jivesoftware.com/webservices/", null);
              
              serviceModel.setProperty("password", "****");
              serviceModel.addOutHandler(new DOMOutHandler());
              Properties properties = new Properties();
              properties.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
              properties.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
              properties.setProperty(WSHandlerConstants.USER, "****");
              serviceModel.addOutHandler(new WSS4JOutHandler(properties));
              
              csUserService = (DzUserService) serviceModel;

               

              Message was edited by: mattdz