[jboss-user] [JBossWS] - Re: Writing a client - no examples for BindingProvider based

alessio.soldano@jboss.com do-not-reply at jboss.com
Fri Jan 4 03:14:53 EST 2008


"mjhammel" wrote : 
  | Then I discovered that the source was actually JBOSS-WS from http://labs.jboss.com/jbossws/downloads/.   My first questions, then, are this:  isn't WS included in the application server?  Do I need to download the WS binary and add it to the JBOSS application server (for V4.2.2GA of the app server)? 
  | 
The application server includes a webservice stack (JBossWS) you can of course use without any further installation. However you would probably want to upgrade the ws stack since JBossWS is released more often than the application server.

anonymous wrote : 
  | Looking through the examples in the WS source code I cannot find an example that seems to implement the simplistic code shown in the client example here:
  | http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools#Client_Side
  | 
Most of the examples use an equivalent generic way of getting the endpoint that is

  | Service service = Service.create(wsdlURL, qname);
  | MyEndpoint port = (MyEndpoint)service.getPort(MyEndpoint.class);
  | 
however you can take a look at the org.jboss.test.ws.jaxws.samples.retail sample which also has a @WebServiceClient annotated service class generated through the tools.

anonymous wrote : 
  | I was hoping it would be as easy as this shows, with the added properties to the BindingProvider for username and password.
  | 
And it should be that easy. Take a look at the org.jboss.test.ws.jaxws.samples.context sample, it is a real simple test case and uses basic auth.

anonymous wrote : 
  | I've written this client, but it fails to compile with an error I've not seen in any discussions or in any googled pages:
  | 
  | package wsTestJAXWS;
  |   | 
  |   | import java.net.URL;
  |   | import javax.xml.ws.*;
  |   | import javax.jws.*;
  |   | 
  |   | /* Web Services interfaces */
  |   | import com.cei.crunch.server.subscriberservices.*;
  |   | 
  |   | /* Crunch DB tables. */
  |   | import com.cei.crunch.ejb.Subscriber;
  |   | 
  |   | public class wsTestJAXWS {
  |   |     
  |   |     private static URL targetURL = null;
  |   |     private String subscriberID = null;
  |   |     private String pw = null;
  |   |     private String host = null; 
  |   |     private String crunchServer = null;
  |   |     private Subscriber profile = null;
  |   |     SubscriberServicesEndpoint ss = null;
  |   |     
  |   |     private boolean serviceBind()
  |   |     {
  |   |         try {
  |   | 
  |   |             SubscriberServicesService service = new SubscriberServicesService();
  |   |             ss = service.getSubscriberServicesPort();
  |   | 
  |   |             /* Set NEW Endpoint Location */
  |   |             BindingProvider bp = (BindingProvider)ss;
  |   |             bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, crunchServer);
  |   | 
  |   |             /* Setup to authenticate with the server. */
  |   |             bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, subscriberID);
  |   |             bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pw);
  |   | 
  |   |             return true; 
  |   |         }   
  |   |         catch (Exception e) {
  |   |             System.out.println("Failed to login to server.");
  |   |             System.exit(1);
  |   |         }
  |   |         return false;
  |   |     }
  |   | 
  |   |     public void run(String[] args) { 
  |   | 
  |   |         /* Save the subscriber login information. */
  |   |         if ( args.length != 3 )
  |   |         {
  |   |             System.out.println("Missing command line args (userid, password, server).");
  |   |             System.exit(1);
  |   |         }
  |   |         this.subscriberID = args[0];
  |   |         this.pw = args[1];
  |   |         this.host = args[2];
  |   | 
  |   |         // crunchServer = "https://" + this.host + ":8443/Crunch/services/SubscriberServices";
  |   |         crunchServer = "http://" + this.host + ":8080/Crunch/services/SubscriberServices";
  |   |         System.out.println("Trying to connect to " + crunchServer + " as User: " + subscriberID + ", password: " + pw);
  |   | 
  |   |         /* Get the WSDL interfaces to the server. */
  |   |         if ( serviceBind() == false )
  |   |         {
  |   |             System.out.println("Login failed.");
  |   |             System.exit(1);
  |   |         }
  |   | 
  |   |         /* Retrieve subscriber profile information. */
  |   |         try {
  |   |             profile = ss.findSubscriber("CRUNCH-DEFAULT-SUPERUSER");
  |   |         }
  |   |         catch (Exception e) {
  |   |             System.out.println("Failed findSubscriber(): " + e.getMessage());
  |   |             e.printStackTrace();
  |   |             System.exit(1);
  |   |         }
  |   |         if ( profile == null )
  |   |         {
  |   |             System.out.println("findSubscriber() failed.");
  |   |             System.exit(1);
  |   |         }
  |   | 
  |   |         System.out.println("Subscriber name : " + profile.getFirstname());
  |   |         System.out.println("Subscriber email: " + profile.getEmailAddress());
  |   |     }
  |   | 
  |   |     public static void main(String[] args) {
  |   |         new wsTestJAXWS().run(args);
  |   |     }
  |   | 
  |   | }
  | 
  | The compile time error is this:
  | 
  | -client.test:
  |   |     [javac] Compiling 1 source file to /home/mjhammel/src/cei/crunch/build/classes/client
  |   |     [javac] /home/mjhammel/src/cei/crunch/src/com/cei/crunch/clients/tests/wsTestJAXWS.java:74: cannot access javax.xml.bind.annotation.XmlAccessorType
  |   |     [javac] file javax/xml/bind/annotation/XmlAccessorType.class not found
  |   |     [javac]             profile = ss.findSubscriber("CRUNCH-DEFAULT-SUPERUSER");
  |   |     [javac]                                            ^
  |   |     [javac] /home/mjhammel/src/cei/crunch/src/com/cei/crunch/clients/tests/wsTestJAXWS.java:76: cannot access javax.xml.bind.annotation.XmlElement
  |   |     [javac] file javax/xml/bind/annotation/XmlElement.class not found
  |   |     [javac]         catch (Exception e) {
  |   |     [javac]                          ^
  |   |     [javac] 2 errors
  | 
  | I can't find any discussion on what the XmlAccessorType or XmlElement classes are or why they're being referenced at the specified points in my code.
  | 
  | FYI:  The SubscriberServicesService class is being generated using wsconsume (http://jbws.dyndns.org/mediawiki/index.php?title=Wsconsume).
  | 

This seems to me an issue with the libraries in your classpath. Check for example that jaxb-api.jar is in your classpath.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116938#4116938

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116938



More information about the jboss-user mailing list