<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Web Services</title>
        <link>http://geekswithblogs.net/socasanta/category/6497.aspx</link>
        <description>Web Services</description>
        <language>en-US</language>
        <copyright>Michael Awai</copyright>
        <managingEditor>Nospamsocasanta@nc.rr.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Uploading files to WSS 3.0 document libraries using HTTP PUT and Lists.asmx</title>
            <link>http://geekswithblogs.net/socasanta/archive/2007/07/09/113809.aspx</link>
            <description>&lt;p&gt;
Uploading a file to a Windows SharePoint Services 3.0 document library from external applications can be done in 2 steps using a combination of HTTP PUT and the Lists Web service. 
	
&lt;/p&gt;
&lt;p&gt;
Firstly, for the HTTP PUT side of things, check out:
&lt;a href="http://blogs.msdn.com/rohitpuri/archive/2007/04/10/upload-download-file-to-from-wss-document-library-using-dav.aspx"&gt;
http://blogs.msdn.com/rohitpuri/archive/2007/04/10/upload-download-file-to-from-wss-document-library-using-dav.aspx&lt;/a&gt; 
.  In the code to follow, I use a variation of Rohit's helper class that 
takes a byte[].&lt;/p&gt;
&lt;p&gt;
Secondly, use the Lists Web service UpdateListItems() method to do the update.  
But how do we get the ID from the HTTP PUT?  Turns out you don't need it.  
Providing the FileRef field is enough.  For example, if you uploaded the 
file to &lt;a href="http://mycompany/hr/Documents/bonus.xls"&gt;http://mycompany/hr/Documents/bonus.xls&lt;/a&gt;, 
that's exactly what you'd put in FileRef, as shown below.&lt;/p&gt;
&lt;pre&gt;        public static string UploadFile(string url, string listName, byte[] document, 
                               List&amp;lt;KeyValuePair&amp;lt;string, object&amp;gt;&amp;gt; fileProperties)
        {
            string s = DAVHelper.UploadFile(url, document);
            if(s != "success")
                throw new Exception("File upload to: " + url + " failed.");

            // Update the attributes
            string updateRes = UpdateFileAttributes(url, listName, fileProperties);
            return updateRes;
	}

&lt;/pre&gt;
&lt;pre&gt;        public static string UpdateFileAttributes(string fileUrl, string listName, 
                                List&amp;lt;KeyValuePair&amp;lt;string, object&amp;gt;&amp;gt; fileProperties)
        {
            WssLists.ListsSoapClient listService 
                = new WssLists.ListsSoapClient("ListsSoap");
            listService.ClientCredentials.Windows.AllowedImpersonationLevel 
                = System.Security.Principal.TokenImpersonationLevel.Delegation;

            // Note that when building the Method fields, the field named ID
            // is required, although in this case we can and will leave it empty.
	    // (Concatenated empty string is just for visuals ;)
            StringBuilder sb = new StringBuilder();
            sb.Append("&amp;lt;Method ID='1' Cmd='Update'&amp;gt;");
            sb.Append("  &amp;lt;Field Name='ID'/&amp;gt;" + "" + "&amp;lt;/Field&amp;gt;");
            sb.Append("  &amp;lt;Field Name='FileRef'&amp;gt;" + fileUrl + "&amp;lt;/Field&amp;gt;");

	    // This is what the loop is basically doing:
            // sb.Append("  &amp;lt;Field Name='CustomColumn1'&amp;gt;" + "Some value" + "&amp;lt;/Field&amp;gt;");
            for (int i = 0; i &amp;lt; fileProperties.Count; i++)
            {
                sb.Append("  &amp;lt;Field Name='" + fileProperties[i].Key + "'&amp;gt;" + 
                           Convert.ToString(fileProperties[i].Value) + "&amp;lt;/Field&amp;gt;");
            }

            sb.Append("&amp;lt;/Method&amp;gt;");

            XmlDocument xmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");

            elBatch.SetAttribute("OnError", "Continue");
            elBatch.SetAttribute("PreCalc", "TRUE"); 
            elBatch.SetAttribute("ListVersion", "0"); 

            elBatch.InnerXml = sb.ToString();

	    // Do the update
            XmlNode ndReturn = listService.UpdateListItems(listName, elBatch);

            return ndReturn.OuterXml;
        }&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113809"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113809" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/socasanta/aggbug/113809.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Michael Awai</dc:creator>
            <guid>http://geekswithblogs.net/socasanta/archive/2007/07/09/113809.aspx</guid>
            <pubDate>Tue, 10 Jul 2007 00:09:34 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/socasanta/comments/113809.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/socasanta/archive/2007/07/09/113809.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/socasanta/comments/commentRss/113809.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/socasanta/services/trackbacks/113809.aspx</trackback:ping>
        </item>
        <item>
            <title>Calling WSS 3.0 Web Services from WCF clients</title>
            <link>http://geekswithblogs.net/socasanta/archive/2007/07/06/113725.aspx</link>
            <description>&lt;p&gt;Having just gone through this, I thought I'd share the basic procedure when calling WSS 3.0 Web services such as lists.asmx and views.asmx from a WCF client.  As you may know, the exceptions returned by the WSS Web services are terse.  Hopefully, this post will help someone trying to avoid those in their own project.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1 - Add a Service Reference to the WCF service you want to call (Duh)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Note that I included the "?wsdl".  If you don't VS will be redirected to /_vti_bin/Lists.asmx.  That doesn't matter from a service client code generation standpoint, just that the WCF endpoint addresses in App.config will need to be changed as they'll be pointing to the wrong URL, and none of the lists and other objects in your site will be found by the Web services.    &lt;/p&gt;
&lt;p&gt;&lt;img height="216" alt="" width="530" src="/images/geekswithblogs_net/socasanta/AddReference(1).JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2 - Modify the App.Config file to change the security binding configuration used by the client&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the basicHttpBinding section, replace:&lt;/p&gt;
&lt;p class="style1"&gt;&amp;lt;security mode="None"&amp;gt; &lt;br /&gt;
    &amp;lt;transport clientCredentialType="None" &lt;br /&gt;
               proxyCredentialType="None" realm="" /&amp;gt; &lt;br /&gt;
    &amp;lt;message clientCredentialType="UserName" algorithmSuite="Default" /&amp;gt; &lt;br /&gt;
&amp;lt;/security&amp;gt; &lt;/p&gt;
&lt;p&gt;With:&lt;/p&gt;
&lt;p class="style1"&gt;&amp;lt;security mode="TransportCredentialOnly"&amp;gt; &lt;br /&gt;
    &amp;lt;transport clientCredentialType="Ntlm" /&amp;gt; &lt;br /&gt;
&amp;lt;/security&amp;gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3 - Allow the Web service to impersonate the user&lt;/strong&gt;&lt;/p&gt;
&lt;p class="style2"&gt;WssList.ListsSoapClient listService = new WssList.ListsSoapClient("ListsSoap"); &lt;br /&gt;
listService.ClientCredentials.Windows.AllowedImpersonationLevel &lt;br /&gt;
    = System.Security.Principal.TokenImpersonationLevel.Delegation; &lt;br /&gt;
&lt;br /&gt;
XmlElement elem = listService.GetListCollection(); &lt;/p&gt;
&lt;p class="style2"&gt; &lt;/p&gt;
&lt;p class="style2"&gt;End transmission... &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113725"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113725" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/socasanta/aggbug/113725.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Michael Awai</dc:creator>
            <guid>http://geekswithblogs.net/socasanta/archive/2007/07/06/113725.aspx</guid>
            <pubDate>Fri, 06 Jul 2007 14:47:39 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/socasanta/comments/113725.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/socasanta/archive/2007/07/06/113725.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/socasanta/comments/commentRss/113725.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/socasanta/services/trackbacks/113725.aspx</trackback:ping>
        </item>
        <item>
            <title>Connected Services Framework 2.5 Scenario: You change your service's WSDL, recompile, bounce IIS and your Session still doesn't recognize your soapAction!</title>
            <link>http://geekswithblogs.net/socasanta/archive/2006/02/17/69929.aspx</link>
            <description>&lt;FONT face=Tahoma&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;In CSF 2.5 the Session.config setting &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;ParticipantConfiguration/ProxyCacheDirectoryPath&lt;/STRONG&gt;&lt;/FONT&gt; is used to specify the directory for the WSDL cache used by CSF when Sessions are created.&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;If you're a developer intent on implementing a particular service contract, forgetting about this cache might cost you a couple of hours of frustration.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Let's say I build a service at &lt;FONT face="Courier New" color=#0000ff&gt;&lt;STRONG&gt;http://MyMachine/MyVdir/sl.ashx&lt;/STRONG&gt;&lt;/FONT&gt; implementing SOAP action &lt;FONT face="Courier New" color=#0000ff&gt;&lt;STRONG&gt;MyAction&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp;I then try to create a Session in which the service is a participant, but unfortunately, the Session expects my service to have&amp;nbsp;SOAP action&amp;nbsp;&lt;FONT face="Courier New" color=#0000ff&gt;&lt;STRONG&gt;http://MyCompany/MyAction&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp; CSF will create&amp;nbsp;a cache file consisting of the URI as the top line, and the first draft WSDL as the remainder of the file.&amp;nbsp; Until the cache expires (and the default is 24 hours), nothing done to fix the action will work; not building, not bouncing IIS, etc. Until you delete the cached WSDL or it expires,&amp;nbsp;CSF will find the file based on the URI, and use the WSDL from it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Relevant Session.config settings:&lt;/FONT&gt;&lt;/P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size=2&gt;ParticipantConfiguration/ProxyCacheDirectoryPath&lt;/FONT&gt;&lt;/STRONG&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ParticipantConfiguration/ProxyCacheFileExpirationTime&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;Default cache directories in CSF 2.5:&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face=Verdana&gt;Developer Edition: &lt;/FONT&gt;C:\Program Files\Microsoft CSF\CSFDeveloper\Temp\&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;&lt;st1:State w:st="on"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Standard edition:&lt;/FONT&gt;&amp;nbsp;&lt;/st1:State&gt;&lt;/st1:place&gt;C:\csf\session\participant\cache\*.*&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=69929"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=69929" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/socasanta/aggbug/69929.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Michael Awai</dc:creator>
            <guid>http://geekswithblogs.net/socasanta/archive/2006/02/17/69929.aspx</guid>
            <pubDate>Sat, 18 Feb 2006 01:52:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/socasanta/comments/69929.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/socasanta/archive/2006/02/17/69929.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/socasanta/comments/commentRss/69929.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/socasanta/services/trackbacks/69929.aspx</trackback:ping>
        </item>
    </channel>
</rss>