Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Web Services
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Web Services
Sharepoint Working Solutions with Axis2
Sairajesh Parameswar
Greenhorn
Posts: 2
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Creating Service and Client using AXIOM
Axis2 client - SOAPProcessingException
Consume Sharepoint Web Service from inside code
Axis2 client to invoke NTLM .NET WCF web services
javax.xml.stream.XMLStreamException: Undeclared prefix 'soapenv' for element <soapenv:Envelope>
More...