aspose file tools*
The moose likes Web Services and the fly likes Sharepoint Working  Solutions with Axis2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Sharepoint Working  Solutions with Axis2" Watch "Sharepoint Working  Solutions with Axis2" New topic
Author

Sharepoint Working Solutions with Axis2

Sairajesh Parameswar
Greenhorn

Joined: Aug 21, 2013
Posts: 2


import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.commons.httpclient.auth.AuthPolicy;
import com.microsoft.schemas.sharepoint.soap.ListsStub;
import com.microsoft.schemas.sharepoint.soap.ListsStub.QueryOptions_type0;




public class WorkSharepoint {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
auth.setUsername ("notMyUserName");
auth.setPassword ("notMyPassword");
auth.setDomain ("notMyDomain");
auth.setHost ("notMyHost");
List authPrefs = new ArrayList (1);
authPrefs.add (AuthPolicy.BASIC);
auth.setAuthSchemes (authPrefs);
ListsStub lists = new ListsStub
("https://site_URL//_vti_bin/Lists.asmx");
lists._getServiceClient ().getOptions ()
.setProperty (HTTPConstants.AUTHENTICATE, auth);
Options options = lists._getServiceClient().getOptions();
options.setSoapVersionURI(Constants.URI_SOAP11_ENV);
String liste = "Project Milestone Chart";
String document2ID;
{
com.microsoft.schemas.sharepoint.soap.ListsStub.GetListCollection req = new com.microsoft.schemas.sharepoint.soap.ListsStub.GetListCollection();
ListsStub.GetListCollectionResponse res = lists.getListCollection (req);
document2ID = getIDByTitle (res, liste);
displayResult (req, res);
}
{
String dir = "folder/subfolder";
ListsStub.GetListItems req
= new ListsStub.GetListItems ();
req.setListName (document2ID);
QueryOptions_type0 query
= new QueryOptions_type0 ();
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement root = fac.createOMElement(new javax.xml.namespace.QName("", "QueryOptions"));
query.setExtraElement (root);

OMElement folder = fac.createOMElement (
new javax.xml.namespace.QName("", "Folder"));
root.addChild (folder);
folder.setText (liste+"/"+dir); // <--!!
req.setQueryOptions(query);
System.out.println("AAAAAAAA");
com.microsoft.schemas.sharepoint.soap.ListsStub.GetListItemsResponse res = lists.getListItems(req) ;
displayResult (req, res);
}

}
private static void displayResult (com.microsoft.schemas.sharepoint.soap.ListsStub.GetListItems req,
com.microsoft.schemas.sharepoint.soap.ListsStub.GetListItemsResponse res)
{
System.out.println ("Result OK: "
+res.getGetListItemsResult());
OMElement root = res.getGetListItemsResult().getExtraElement();
dump (System.out, root, 0);
}
private static void displayResult (com.microsoft.schemas.sharepoint.soap.ListsStub.GetListCollection req,
com.microsoft.schemas.sharepoint.soap.ListsStub.GetListCollectionResponse res)
{
System.out.println ("Result OK: "
+res.getGetListCollectionResult());
OMElement root = res.getGetListCollectionResult().getExtraElement();
dump (System.out, root, 0);
}
private static void dump (PrintStream out, OMElement e, int indent)
{
indent(out, indent);
out.print (e.getLocalName ());
for (Iterator iter = e.getAllAttributes (); iter.hasNext (); )
{
OMAttribute attr = (OMAttribute)iter.next ();
out.print (" ");
out.print (attr.getLocalName ());
out.print ("=");
out.print (attr.getAttributeValue ());
out.print ("");
}
out.println ();

for (Iterator iter = e.getChildElements (); iter.hasNext (); )
{
OMElement child = (OMElement)iter.next ();
dump (out, child, indent+1);
}
}

private static void indent (PrintStream out, int indent)
{
for (int i=0; i<indent; i++)
out.print (" ");
}
private static String getIDByTitle (com.microsoft.schemas.sharepoint.soap.ListsStub.GetListCollectionResponse res, String title)
{
OMElement root = res.getGetListCollectionResult().getExtraElement();
javax.xml.namespace.QName qnameTitle = new javax.xml.namespace.QName ("Title");
javax.xml.namespace.QName qnameID = new javax.xml.namespace.QName ("ID");
for (Iterator iter = root.getChildrenWithLocalName ("List"); iter.hasNext (); )
{
OMElement list = (OMElement)iter.next ();
if (title.equals (list.getAttributeValue (qnameTitle)))
return list.getAttributeValue (qnameID);
}
return null;
}
}


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sharepoint Working Solutions with Axis2