• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sharepoint Working Solutions with Axis2

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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;
}
}


 
reply
    Bookmark Topic Watch Topic
  • New Topic