I'm developing a custom component in Java (1.7). This component needs to be able to Push and Pull a file to a SharePoint 2010 Server.
I've successfully Pushed a file along with metadata to the Server. I've also successfully Pulled a file from the Server.
Well I need to be able to search (query) the Server depending on different search criteria according to what the User feeds my component.
I've been unable to successfully connect to the SPSearch Web Service.
I get this error:
"Error caught in main: javax.xml.ws.WebServiceException: {http://microsoft.com/webservices/SharePoint/QueryService}QueryServiceSoap is not a valid service. Valid services are: {http://schemas.microsoft.com/sharepoint/soap/}Lists "
I've searched on Google endlessly and found some C# code that I was able to teach myself how I need to use the service, but it doesn't help me utilize the service successfully. I cannot find a good Java reference to utilize this web service.
Any help or suggestions would be greatly appreciated. Thank you.
(wsdl = SPURL/_vti_bin/spsearch.asmx?wsdl; endpoint = SPURL/_vti_bin/spsearch.asmx)
Here's the Code:
protected ListsSoap getListsSoap(String username, String password, String wsdl, String endpoint) throws Exception {
System.out.println("Creating a ListsSoap instance...");
Lists service = new Lists(new URL(wsdl), new QName("http://schemas.microsoft.com/sharepoint/soap/", "Lists"));
ListsSoap port = service.getListsSoap();
BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
return port;
}
protected CopySoap getCopySoap(String username, String password, String wsdl, String endpoint) throws Exception {
System.out.println("Creating a CopySoap instance...");
Copy service = new Copy(new URL(wsdl), new QName("http://schemas.microsoft.com/sharepoint/soap/", "Copy"));
CopySoap copySoap = service.getCopySoap();
BindingProvider bp = (BindingProvider) copySoap;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
return copySoap;
}
protected QueryServiceSoap getQuerySoap(String username, String password, String wsdl, String endpoint) throws Exception {
System.out.println("Creating a QuerySoap instance...");
QueryService service = new QueryService(new URL(wsdl), new QName("http://microsoft.com/webservices/SharePoint/QueryService", "QueryServiceSoap"));
QueryServiceSoap querySoap = service.getQueryServiceSoap();
BindingProvider bp = (BindingProvider) querySoap;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
return querySoap;
}