I have no experience in developing SharePoint before. Recently I made a small project for Windows Store and SharePoint service. Thanks to my friends, I would like to sum up my experience here for your reference.
First, each page or website of shearpoint has its own powerful WebService or WCF. You only need to add/_ Vti_bin/lists. asmx
An important issue here is that Windows Store applications automatically generate referencesCodeWill generate some errorsHttp: // ******/_ vti_bin/lists. asmxBut the actual address we add is:Http: // ******/sites/*******/_ vti_bin/lists. asmxSo I need to replace the wrong address with the vs replacement function in the project.
Do not forget to check the private network and Enterprise Authentication options in the appxmanifest file after the reference is completed because my project can be logged on in the Company domain using the Windows integrated authentication method.
In addition, I provide a method to call the service.System. servicemodel. Security. messagesecurityexceptionThis exception is caused by the user's failure to enter the domain and the user name and password verification,System. servicemodel. endpointnotfoundexceptionIs a network connection error.
The second way to obtain the content of a form is to callGetlistitemsasyncMethod.
Private Async Task <xelement> getdatafromservice ( String Servicename, String Username = Null , String Password = Null , String Domain = Null ) {Spservice. listssoapclient Client = New Spservice. listssoapclient (); VaR Binding = (Basichttpbinding) client. endpoint. Binding); binding. Security. Mode = System. servicemodel. basichttpsecuritymode. transportcredentialonly; binding. Security. Transport. clientcredentialtype = System. servicemodel. httpclientcredentialtype. NTLM; client. clientcredentials. Windows. clientcredential = New Networkcredential (username, password, domain); getlistitemsresponse lists = Null ; Try {Lists = Await Client. getlistitemsasync (servicename, String . Empty, Null , Null , " 1000 " , Null , Null );} Catch (System. servicemodel. Security. messagesecurityexception e ){ Throw New Messagesecurityexception ( " Please check your user name and password. " );} Catch (System. servicemodel. endpointnotfoundexception e ){ Throw New Endpointnotfoundexception ( " Please check your Microsoft network connection and access permissions. " );} Return Lists. Body. getlistitemsresult ;}
The previous method will return an xelement, which requires manual parsing but is also very simple.
Public Async Task <observablecollection <dashboard> getdashboard ( String Username = Null , String Password = Null , String Domain = Null ) {Xelement XML = Await Getdatafromservice ( " Dashboardtable " , Username, password, domain ); VaR Items = XML. Elements (). Elements (). tolist (); VaR Result = From O In Items Select New Dashboard () {Department = O. Attribute ( " Ows_department " ). Getstringfromxmlattribute (), attained = O. Attribute ( " Ows_attained " ). Getstringfromxmlattribute (), Target = O. Attribute ( " Ows_target " ). Getstringfromxmlattribute (),}; observablecollection <Dashboard> List = New Observablecollection <dashboard> (Result ); Return List ;}
Actually, it corresponds to the value in each item in Sharepoint.
The usage is relatively simple here to pave the way for future students