Tuesday, 29 January 2008

Siebel 7.8 Web Services: Correcting WSDL

The WSDL that is generated by Siebel for inbound web services is lacking some internal schema imports. The .NET SOAP tooling gives some warnings, but works around it. Some other toolkits refuse to work with the schema. Passing the WSDL through this XSLT transform fixes the problem:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>
<xsl:output method="xml" indent="no"/>

<xsl:template match="xsd:schema[@targetNamespace='http://siebel.com/asi/']">
<xsd:schema>
<xsl:copy-of select="@*" />
</xsd:schema>
<xsd:import>
<xsl:attribute name="namespace">
<xsl:value-of select="//xsd:schema/@targetNamespace"/>
</xsl:attribute>
</xsd:import>
<xsl:copy-of select="node()"/>
</xsl:template>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Monday, 21 January 2008

Visual Studio 2008 unit tests: one App.config to rule them all

Background

When using NUnit, I tended to include unit tests in their projects, so they would be built as part of the .dll or .exe depending on the output type (so they were excluded in release builds).

Visual Studio's unit tests are built as separate libraries.  This is good in that it further removes dependencies, but removes access to internal methods: unit testing of internal methods was something I'd catered for since using JUnit, although in practice I can't remember many times that I've really needed to call an internal, rather than testing against the public interfaces.

Each project (e.g. libraries) now has a settings file, and VS 2008 takes care of maintaining a skeleton app.config within each project that contains the relevant applicationSettings section.  Typically a unit test for a library will depend on a lot of configuration for other libraries, e.g. application settings, WCF, etc.  Having a separate App.config under each unit test project with all this information means duplicating a lot of information that may change (e.g. locations of web services or databases required for tests).

Solution

Under 'Solution Items', add a new App.config that will be the master configuration for development and unit testing.  Then configure each unit test project with a post-build step to copy this configuration into the output directory using the 'Build Events' tab in the project settings.

VS shared test config

Unit testing: Visual Studio native and NUnit

Since Team System unit tests are now available in Visual Studio 2008 Pro, it is convenient to be able to use this rather than rely on a 3rd party add-ins to support NUnit.  On the other hand, it is good to have backwards compatibility with NUnit so that code could be built outside of VS, or in VS Express edition.

There is a pattern that Microsoft has been using to allow this, involving conditional compilation: place this at the top of a project file:

#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
#endif

The two APIs are not exactly the same but there is a useful subset of Assert methods that will work in both.

Sunday, 9 December 2007

Access control of HTTP addresses in Vista

Vista has namespace reservations to control the set up of HTTP listening ports. By default, a user does not have access to listen to arbitrary HTTP ports e.g. using wsHttpBinding in WCF.

To show the access control for all ports, use command:
  • netsh http show urlacl
To grant user Tony access to port 8000, do:
  • netsh http add urlacl url=http://+:8000/ user=Tony
Update: there is a deployment tool for WCF that includes this step.

Thursday, 30 August 2007

Junctions and symbolic links

NTFS Junctions Points
  • managed through the linkd command from the WRK.
  • (linkd /d is the safe way to delete junction points - don't use Explorer)

NTFS Symbolic Links
  • Vista and Server 2008
  • created using mklink
  • file links deleted using del
  • directory links deleted using rmdir

Monday, 14 May 2007

JBoss 4.0.2 under Java 1.5 / 1.6

I had a slight problem with this combination and was getting the following exception:


provider org.apache.xalan.processor.TransformerFactoryImpl not found


After some searching it turns out that the provider class has moved and it's now necessary to set a property to locate the new location. I did this with a JAVA_OPTS switch in the setenv.bat:

set JAVA_OPTS=-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

Friday, 11 May 2007

Terminal Services / Remote Desktop commands

I was looking for a way to see who is logged on before I bounce a Windows server. There are some useful commands for managing sessions:
  • mstsc: start new session
  • shadow: join a session
  • qwinsta: query window station e.g. show sessions
  • tskill: kill a session
  • tsdisconn: disconnect current session.b