DOTNET POWER PLAY
.NET stuffings and MICROSOFT (C) technologies
Monday, June 28, 2004
Friday, June 25, 2004
Blogger has C# Atom code
using System;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web.Services.Protocols;
using System.Xml;
public class AtomClient {
public static void Main(string[] arg) {
if (arg.Length != 3) {
Console.WriteLine("Usage: AtomClient user password url");
return;
}
string user = arg[0];
string password = arg[1];
string url = arg[2];
// Create a blog entry
entryType blog = new entryType();
blog.issued = DateTime.Now;
blog.title = "First Post!";
// Author
blog.author = new authorType();
blog.author.name = "Sam Ruby";
blog.author.url = "http://www.intertwingly.net/blog/";
// Generator
blog.generator = new generatorType();
blog.generator.url = "http://www.intertwingly.net/blog/";
blog.generator.Value = "WSDL C# Client";
// Fill in the content
XmlDocument d = new XmlDocument();
d.InnerXml = "
Hello World!
";
blog.content = new contentType[1];
blog.content[0] = new contentType();
blog.content[0].mode = contentTypeMode.xml;
blog.content[0].type = "application/xhtml+xml";
blog.content[0].Any = new XmlNode[1];
blog.content[0].Any[0] = d.DocumentElement;
// Create an 'atom' authorization header
Security auth = new Security();
UsernameToken unt = new UsernameToken();
auth.UsernameToken = new UsernameToken();
auth.UsernameToken.Nonce = new Random().Next().ToString();
auth.UsernameToken.Username=user;
auth.UsernameToken.Created=DateTime.Now.ToString("u").Replace(' ','T');
// Fill in the password
SHA1 md = new SHA1CryptoServiceProvider();
string v = auth.UsernameToken.Nonce + auth.UsernameToken.Created + password;
byte[] digest = md.ComputeHash(Encoding.Default.GetBytes(v));
auth.UsernameToken.Password=new passwordType();
auth.UsernameToken.Password.Value=Convert.ToBase64String(digest);
auth.UsernameToken.Password.Type="wsse:PasswordDigest";
auth.UsernameToken.Password.AnyAttr=new XmlAttribute[1];
auth.UsernameToken.Password.AnyAttr[0]=d.CreateAttribute("wsse:placeholder",
"http://schemas.xmlsoap.org/ws/2002/07/secext");
try {
// Post the request
AtomAPI api = new AtomAPI();
api.SecurityValue = auth;
api.Url = url;
api.POST(ref blog);
} catch (SoapException fault) {
System.Console.WriteLine(fault.Message);
} catch (WebException httpStatus) {
System.Console.WriteLine(httpStatus.Message);
}
}
}
Wednesday, June 23, 2004
ASP.NET Home: Manage Detail Pages Across Multiple Platforms with Centralized Data Caching (ASP.NET Technical Articles)
Tuesday, June 22, 2004
Friday, June 18, 2004
How to use XPath on a DataSet?
How to use XPath on a DataSet?Used Classes:
DataRow
DataSet
XmlDataDocument
XmlNodeList
XmlNode
XML File:
Code:
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("file.xml"));
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/CategoryList/Category[@ID=01]");
DataRow myRow;
foreach (XmlNode myNode in nodeList)
{
myRow = xmlDoc.GetRowFromElement((XmlElement)myNode);
if (myRow != null)
Response.Write(myRow[0]);
}
Output:
One
Thursday, June 17, 2004
Wednesday, June 16, 2004
Calling WebServices using Javascript
Calling WebServices using Javascript
If you are using Microsoft IE 5 or later, you can use the behavior/HTML-Component "WebService" to access a Web service. The "WebService" behavior communicates with Web services over HTTP using Simple Object Access Protocol (SOAP).
To use the "WebService" behavior, you must attach it to an element using the STYLE attribute, as follows:
STYLE="behavior:url(webservice.htc)">
A complete example taken from the Microsoft Web site is as follows:
Enter a Value
style="behavior:url(webservice.htc)"
onresult="onmyresult();">