Posts

Showing posts with the label xml

Developing ASMX Web Services and Controlling the Generated WSDL

Microsoft has made the development of web services very simple for developers who use Visual Studio. Add a web service project and the basic plumbing code is generated! Many developers do not know what goes behind the hood or how to customise the generated WSDL when required. I’ve listed some salient ones that may be of help… Apply [WebService(Namespace = " http://www.johannes.org/webservice/2011/11/03/ ",Name=" ExtendingWebService ", Description=" version 1.0 ")] to the class to get these: < wsdl : definitions targetNamespace = "http://www.johannes.org/webservice/2011/11/03/" > < wsdl : documentation > version 1.0 </ wsdl : documentation > ... < wsdl : service name = "ExtendingWebService" > Apply [WebMethod(Description=" This web service is a typical one ")] to the operation to get this: < wsdl : operation name = "..." > < wsdl : documentation > This web service is a...

Use and abuse of the .NET DataSet

Here are some facts about the DataSet that ones needs to be aware of. A DataSet: is up to 30x less performant than a DataReader (refer here ) – the disparity in performance increases as more records are retrieved represents an in-memory database for the application (supports keys, relationships, validation, etc.) can be either strongly-typed or un-typed is a provider-neutral data representation is a dis-connected data object supports edits and updates as well as random access can be sorted, filtered can be very easily bound to UI controls has excellent integration with XML (serialisation to and from XML) Appropriate Use Cases DataSets are often abused and thus discouraged from use. However, they can be useful in the following scenarios: Need for a dis-connected data object that is to be batch-edited, separately updated and subsequently synchronised with the database. Although ideal for OCC or desktop client, this is also possible for a web application with a session-based DataSe...

HTML-scraping

Ever had a need to process pages from a website that does not support any form of structural system integration like Web Service, RSS, REST, etc. The only information available is ill-formed HTML; not even XHTML!?I have always been using HTML Agility for the .NET platform to perform such HTML screen-scraping. Recently, found a number of Java equivalent toolkit to do the same: TagSoup JSoup HTML Parser HTML Cleaner NekoHTML Found this site that collects various toolkits for this purpose here .

To Enable HTTP Compression in IIS

  Need to enable it in Web.Config as follows: < system.webServer > < httpCompression directory = "%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" > < scheme name = "gzip" dll = "%Windir%\system32\inetsrv\gzip.dll" /> < dynamicTypes > < add mimeType = "text/*" enabled = "true" /> < add mimeType = "message/*" enabled = "true" /> < add mimeType = "application/javascript" enabled = "true" /> < add mimeType = "*/*" enabled = "false" /> </ dynamicTypes > < staticTypes > < add mimeType = "text/*" enabled = "true" /> < add mimeType = "message/*" enabled = "true" /> < add mimeType = "application/javascript" enabled = "true" /> < add mimeType = "*/*...

Web Services Interoperability - .NET & Java

For those who are attempting to write web services in .NET to be consumed in Java. The following are things to note or watch out for: Note the WS-I guideline found here Run the WS-I tests first to ensure that the web services comply with Basic Profile 1.0. Download the "Interoperability Testing Tools 1.1" from here Refrain from having the same name for operation and parameter type (this causes Axis 1.4 to fail as it attempts to generate classes for service and parameter type. Axis will try to generate the same class for both. For example: a complex type named search will "clash" with an operation with the same name. In the WSDL: <s:complexType name="search"> will "clash" with <s:operation name="search"> ) Refrain from incorporating non-ASCII characters directly into the content of a string property (which finally gets serialized into XML). Use character encoding instead. E.g., do not use “smart quotes” directly; us...

XSL for XML with namespaces

This started off as a problem with writing a single XSL for RSS and ATOM feeds. To be fair, producing separate XSL files for RSS and ATOM feeds should not be a huge problem. Attempting to merge them is probably not trivial. Thankfully, writing a XSL file for RSS is pretty trivial. It uses regular XSL know-how. However, writing one for ATOM seemed very different! The reason is that the ATOM XML comes with namespaces. I've encountered these two namespaces in use in different feeds: <feed version="0.3" xmlns="http://purl.org/atom/ns#"> and <feed xmlns="http://www.w3.org/2005/Atom"> As such, a regular template match will not match the content of the document. <xsl:template match="feed"> I'll need to write the XSL such that both gets matched. In order to match the first feed, I'll need the template to be: <xsl:template match="{http://purl.org/atom/ns#}feed"> To shortcut this, you'll need to have a pref...