3 Replies Latest reply on Nov 16, 2006 3:42 AM by thomas.diesler

    web services client

    ypasmk

      I want to implement a user authentication service using web services..so I have these classes

      package server.webservices;
      
      import javax.ejb.Local;
      import javax.ejb.Remote;
      
      @Local
      @Remote
      public interface LoginService
      {
      public boolean Authenticate(String userid,String passid);
      }
      



      package server.webservices;
      
      import javax.ejb.Local;
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      
      
      @Stateless
      @Local( { LoginService.class } )
      @Remote( { LoginService.class } )
      
      @WebService(name = "LoginService",
      serviceName = "LoginService",
      endpointInterface = "server.webservices.LoginServiceSEI"
      )
      public class LoginServiceBean implements LoginService
      {
      
      @WebMethod
      public boolean Authenticate(String userid, String passid)
      {
       //testing
       return true;
      }
      
      
      }
      


      package server.webservices;
      
      import java.rmi.Remote;
      import java.rmi.RemoteException;
      
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      
      import org.jboss.annotation.ejb.RemoteBinding;
      import org.jboss.ws.annotation.PortComponent;
      
      @WebService(name = "LoginService",
       serviceName = "LoginService"
      // See JSR-181 for exact details: http://jcp.org/aboutJava/communityprocess/mrel/jsr181/index.html
       )
      
      @SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
      use = SOAPBinding.Use.LITERAL,
      parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
      
      /*
      * BossWS propriatary annotations
      */
      @RemoteBinding(jndiBinding = "/ejb3/EJBLoginServiceSEI")
      @PortComponent(transportGuarantee="NONE",
      contextRoot = "/",
      urlPattern="/server/soap/LoginService")
      public interface LoginServiceSEI extends Remote
      {
      
      
      public boolean Authenticate(String userid,String passid) throws RemoteException;
      }
      


      so I use wstools.sh to generate the client classes and I have four classes

      /*
       * JBossWS WS-Tools Generated Source
       *
       * Generation Date: Thu Oct 12 14:16:24 CEST 2006
       *
       * This generated source code represents a derivative work of the input to
       * the generator that produced it. Consult the input for the copyright and
       * terms of use that apply to this source code.
       */
      
      package client.webservices.client;
      
      
      public class Authenticate
      {
      
      protected java.lang.String string_1;
      
      protected java.lang.String string_2;
      public Authenticate(){}
      
      public Authenticate(java.lang.String string_1, java.lang.String string_2){
      this.string_1=string_1;
      this.string_2=string_2;
      }
      public java.lang.String getString_1() { return string_1 ;}
      
      public void setString_1(java.lang.String string_1){ this.string_1=string_1; }
      
      public java.lang.String getString_2() { return string_2 ;}
      
      public void setString_2(java.lang.String string_2){ this.string_2=string_2; }
      
      }
      


      /*
       * JBossWS WS-Tools Generated Source
       *
       * Generation Date: Thu Oct 12 14:16:24 CEST 2006
       *
       * This generated source code represents a derivative work of the input to
       * the generator that produced it. Consult the input for the copyright and
       * terms of use that apply to this source code.
       */
      
      package client.webservices.client;
      
      public class AuthenticateResponse
      {
      
      protected boolean result;
      public AuthenticateResponse(){}
      
      public AuthenticateResponse(boolean result){
      this.result=result;
      }
      public boolean isResult() { return result ;}
      
      public void setResult(boolean result){ this.result=result; }
      
      }
      


      /*
       * JBossWS WS-Tools Generated Source
       *
       * Generation Date: Thu Oct 12 14:16:24 CEST 2006
       *
       * This generated source code represents a derivative work of the input to
       * the generator that produced it. Consult the input for the copyright and
       * terms of use that apply to this source code.
       */
      package client.webservices.client;
      public interface LoginService_PortType extends java.rmi.Remote
      {
      
       public client.webservices.client.AuthenticateResponse authenticate(client.webservices.client.Authenticate authenticate) throws java.rmi.RemoteException;
      }
      



      /*
      * JBoss, the OpenSource EJB server
      * Distributable under LGPL license. See terms of license at gnu.org.
      */
      
      //Auto Generated by jbossws - Please do not edit!!!
      
      package client.webservices.client;
      
      
      import javax.xml.rpc.*;
      
      
      public interface LoginService_Service extends javax.xml.rpc.Service
      {
      
       public client.webservices.client.LoginService_PortType getLoginServicePort() throws ServiceException;
      
      }
      


      so my question is how can I use those clients classes to implement a request in an ejb3.0 bean class. A small example would be great...

        • 1. Re: web services client
          heiko.braun

          The JSR-181 preview under JAX-RPC doesn't have a client programming model. In order to consume your service you'd need to use one the jax-rpc client models:

          http://labs.jboss.com/portal/jbossws/user-guide/en/html/clients.html

          • 2. Re: web services client
            alesj

             

            "heiko.braun@jboss.com" wrote:
            The JSR-181 preview under JAX-RPC doesn't have a client programming model.


            This means there is no annotation support for authenticated client call?

            To put so annotated authentification info in this classes?

            @WebServiceClient(
             name = "AccountServiceEndpointService",
             wsdlLocation = "http://localhost:8081/jaxrpc/axis/AccountService?wsdl",
             targetNamespace = "http://localhost:8081/jaxrpc/axis/AccountService"
            )
            public class AccountServiceImpl extends javax.xml.ws.Service {
            
             public AccountServiceImpl() throws MalformedURLException {
             this(
             new URL("http://localhost:8081/jaxrpc/axis/AccountService?wsdl"),
             new QName("http://localhost:8081/jaxrpc/axis/AccountService", "AccountServiceEndpointService")
             );
             }
            
             public AccountServiceImpl(URL url, QName qName) {
             super(url, qName);
             }
            
             @WebEndpoint(name = "AccountService")
             public AccountService getSimplePort() {
             return (AccountService) super.getPort(
             new QName("http://localhost:8081/jaxrpc/axis/AccountService", "AccountService"),
             AccountService.class);
             }
            
            }
            
            --
            
            @WebService
            @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
            public interface AccountService {
            
             @WebMethod
             @WebResult(name = "createAccountReturn")
             Account createAccount(String username);
            
             @WebMethod
             @Oneway
             void insertAccount(Account account);
            
            }
            
            --
            
             @WebServiceRef(AccountServiceImpl.class)
             private AccountService simpleService;
            
            


            • 3. Re: web services client
              thomas.diesler

              This will be supported in jbossws-2.0.x