Results 1 to 2 of 2
  1. #1
    gorgon777 is offline Member
    Join Date
    Jan 2014
    Posts
    15
    Rep Power
    0

    Default ClassCastException when using a BindingProvider

    Hello,

    I have the below code:
    Java Code:
    	public static ListsSoap sharePointListsAuth(String userName, String password) throws Exception {
    	    ListsSoap port = null;
    	    if (userName != null && password != null) {
    	        try {
    	            Lists service = new ListsLocator();
    	            port = service.getListsSoap();
    	            BindingProvider bp = (BindingProvider) port;
    	            Map<String, Object> rc = bp.getRequestContext();
    	            System.out.println("Web Service Auth Username: " + userName);
    	            rc.put(BindingProvider.USERNAME_PROPERTY, userName);
    	           // ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName);
    	           // ((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
    	        } catch (Exception e) {
    	            throw new Exception("Error: " + e.toString());
    	        }
    	    } else {
    	        throw new Exception("Couldn't authenticate: Invalid connection details given.");
    	    }
    	    return port;
    	}
    The error message I get is
    Java Code:
    java.lang.Exception: Error: java.lang.ClassCastException: com.microsoft.schemas.sharepoint.soap.ListsSoapStub cannot be cast to javax.xml.ws.BindingProvider
    I have been following the tutorial mentioned here

    Does anyone know why I cannot cast a BindingProvider in the above code?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: ClassCastException when using a BindingProvider

    I can only assume that "service.getListsSoap()" returns an object that does not implement BindingProvider, nor is an extension of a class that does.

Similar Threads

  1. ClassCastException
    By MetalR0 in forum New To Java
    Replies: 5
    Last Post: 08-03-2011, 04:22 AM
  2. ClassCastException
    By Umi in forum New To Java
    Replies: 2
    Last Post: 01-14-2010, 12:51 AM
  3. ClassCastException
    By paulsim in forum Java Applets
    Replies: 2
    Last Post: 08-21-2008, 03:14 PM
  4. ClassCastException
    By Ed in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 06:26 AM
  5. ClassCastException
    By Felissa in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 06:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •