« December 2003 | Main | February 2004 »

January 2004

Update on ASMX's BP conformance and testing with SOAPscope

For those of you who read my report on ASMX's BP conformance I have a slight update. Not that now by accident ASMX is compatible, but there are some problems with SOAPscope 3.0, IIS, and the way external schemas and WSDL are referenced in the base WSDL document. The following is a shrink-wrapped version of the results the Mindreef support and I encountered.

What was really strange when testing the Web service from this article were the schema and malformed XML errors I and also the SOAPscope support did not quite understand. As it turns out it was IIS and the way SOAPscope interacts with IIS that caused the problems. Try stopping IIS, starting it, then the next web request you make, click SOAPscope's Analyze tab (once you're already viewing the WSDL). This should show up the 'real' analysis of the Web service. Every subsequent call will result in those other strange results ...

Not all of the errors are being caused by this, just the ones of the bad XML variety are (though, that may prevent required schemas from loading properly).
Actually, IIS was refusing access to one of the imported files in the WSDL. Well, to make a long story short: you can achieve the correct results by disabling the 'Keep-Alive' setting in your IIS preferences. This will cause everything to function correctly, as IIS will no longer get stuck in a state of inappropriately maintaining useless connections. Obviously, this is currently nothing more than a workaround.

This leads us to the updated error report for the Web service with multiple bindings and schema and WSDL import. These are all errors, some of which are just consecutive errors, though:

Schema Validation
Schema Error: Duplicate key value [ID Value:
http://KeithhPij.org/WSLibrary/MyStoreMB/Sales] declared for identity constraint of element "definitions".
Node: import

Schema Validation
Schema Error: Duplicate key value [ID Value:
http://KeithhPij.org/WSLibrary/MyStoreMB/Support] declared for identity constraint of element "definitions".
Node: import

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1" is a schema, which is not permitted through the use of import.

SOAPscope
Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([3,61] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema2" is a schema, which is not permitted through the use of import.

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3" is a schema, which is not permitted through the use of import.

SOAPScope
Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([3,61] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1" is a schema, which is not permitted through the use of import([3,140] imported from "http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl1").

SOAPscope
Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([3,61] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema2" is a schema, which is not permitted through the use of import([4,126] imported from "http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl1").

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3" is a schema, which is not permitted through the use of import([5,142] imported from "http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl1").

SOAPscope
Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([3,61] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1" is a schema, which is not permitted through the use of import([3,140] imported from "http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl2").

SOAPscope
Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([3,61] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema2" is a schema, which is not permitted through the use of import([4,126] imported from "http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl2").

WS-I Basic Profile
Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3" is a schema, which is not permitted through the use of import([5,142] imported from "http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl2").

SOAPscope
Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([3,61] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.

WS-I Basic Profile
Multiple wsdl:ports with same location
Multiple wsdl:ports Sales and Support have the same value for their "location" attributes.


Patterns, practices for enterprise applications: this time from the other side

IBM's Redbook series has been there for a long time - much longer than Microsoft's excellent PAG materials.
So today I will introduce you to the two latest (beta) additions in the Redbook library:

Hm, you think this sounds familiar ... ;-)

Update: Frans kindly pointed me to the Java patterns page (part of the Blueprint initiative from Sun). Yes, I knew it before, but somehow gracefully ignored it - although I talked about the famous Java Enterprise Patterns book in my patterns talk at Microsoft DevDays Switzerland.

Yasser goes Indigo - on MSDN

My friend Yasser has published a new article about developing Indigo applications with the PDC build in Visual Studio .NET Whidbey. Actually it is part of the new 'Indigo Lingo' series. Check it out on MSDN:

In the first installment of the Indigo Lingo column, Yasser Shohoud explores Visual Studio .NET project templates for creating Indigo applications. (11 printed pages)

This year's Professional Developers Conference (PDC) attendees received a technology preview of the upcoming Windows® release code-named Longhorn that contains a new communications subsystem code-named Indigo. They also received a preview of the Longhorn SDK that contains several Indigo development tools and over 40 Indigo code samples, as well as Visual Studio .NET® Indigo project templates.

In this article I explain how to create and consume services using the PDC release of Longhorn, Visual Studio® .NET code-named Whidbey, and the various Visual Studio .NET project templates present in the Longhorn SDK. The goal is to get you started with a general understanding of what's in the bits and how you can use the templates.


 

ASMX's conformance to the WS-I BP 1.0 - do not blindly trust public information

Ouch!
At first sight I thought that the latest article on MSDN about attributing your ASMX code to control the WSDL (Inside WSDL with .NET Attribution) will help people to better understand what WSDL is and how it works.

Abstract: Understanding how a WSDL file describes your Web service is the key to understanding how XML Web services work in general. This article is for .NET developers who want to demystify the WSDL files that Microsoft ASP.NET generates by examining the seven major elements that compose a WSDL file. Techniques for altering the generated WSDL by using the attributes available within the System.Web.Services, System.Web.Services.Protocols, and the System.Xml.Serialization namespaces are also shown.

Maybe a further step will then be that they actually first think about their service's contract and then start coding (with tool support)... it actually seems to propose some best practices when working with service interfaces. Well, that was at least my theory.

When playing with the article's sample code I happened to start up the SOAPscope 3.0 Analyze Service feature. Kawoom! Ouch!

WS-I BP compliancy error messages.

The following list depicts details of some of the most important errors that occured when analyzing the demo service MyStoreMB.asmx(there were a bunch more, but I did not quite understand their meaning ;-) See at the bottom of this entry).
Obviously ASMX does currently not support a number of the WS-I BP 1.0 recommendations, which is natural as the ASMX engine did not get any service pack or fix release since the BP's existence
:

Schema Error: Duplicate key value [ID Value: http://KeithhPij.org/WSLibrary/MyStoreMB/Sales] declared for identity constraint of element "definitions".
Node: import
ID:W062

Schema Error: Duplicate key value [ID Value: http://KeithhPij.org/WSLibrary/MyStoreMB/Support] declared for identity constraint of element "definitions".
Node: import
ID:W062

Wsdl:import points to a schema document
Imported file "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1" is a schema, which is not permitted through the use of import.
ID:W095

Xsd:import schemaLocation unknown
SOAPscope cannot perform the xsd:import specified by Element xs:import([?,?] imported from "
http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1") because the namespace is unrecognized and the "schemaLocation" attribute is missing or invalid.
ID:W107

Multiple wsdl:ports with same location
Multiple wsdl:ports Sales and Support have the same value for their "location" attributes.
ID:W065

Missing wsdl:binding
Wsdl:port Sales refers to an unknown wsdl:binding with QName "{http://KeithhPij.org/WSLibrary/MyStoreMB/Sales}Sales".
ID:W034

Missing wsdl:binding
Wsdl:port Support refers to an unknown wsdl:binding with QName "{http://KeithhPij.org/WSLibrary/MyStoreMB/Support}Support".
ID:W034

The last error e.g. is related to the second binding entry in the WSDL as shown below and defined through the SoapDocumentMethod(Binding:="Support") attribute in the source code.

<definitions targetNamespace="http://KeithPij.org/WSLibrary/MyStoreMB"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:i1="KeithPij.org/WSLibrary/DataTypes"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:i4="http://KeithhPij.org/WSLibrary/MyStoreMB/Support"
    xmlns:i3="http://KeithhPij.org/WSLibrary/MyStoreMB/Sales"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tns="http://KeithPij.org/WSLibrary/MyStoreMB"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns="http://schemas.xmlsoap.org/wsdl/">
   <import namespace="http://KeithhPij.org/WSLibrary/MyStoreMB/Sales" location="http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema1"/>
   <import namespace="KeithPij.org/WSLibrary/DataTypes" location="http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema2"/>
   <import namespace="http://KeithhPij.org/WSLibrary/MyStoreMB/Support" location="http://pcpauline/WSLibrary/MyStoreMB.asmx?schema=schema3"/>
   <import namespace="http://KeithhPij.org/WSLibrary/MyStoreMB/Sales" location="http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl1"/>
   <import namespace="http://KeithhPij.org/WSLibrary/MyStoreMB/Support" location="http://pcpauline/WSLibrary/MyStoreMB.asmx?wsdl=wsdl2"/>
   <types/>
   <service name="MyStoreMB">
      <documentation>MyStore web service with multiple bindings</documentation>
      <port name="Sales" binding="i3:Sales">
         <soap:address location="http://pcpauline/WSLibrary/MyStoreMB.asmx"/>
      </port>

      <port name="Support" binding="i4:Support">
         <soap:address location="http://pcpauline/WSLibrary/MyStoreMB.asmx"/>
      </port>

   </service>

</definitions>


It is left as an excercise to the reader to determine the other above mentioned problems in the XML document.
So I cannot help but recommend NOT TO USE THE APPROACH mentioned in the article's Controlling Port Types with .NET Attributes section. It may lead to heavy interoperability issues!

And finally I will also show you the error I did not quite understand. It occured several times. Any comments?:

Malformed XML:
Line: 1, Column: 55 in the original XML stream.
White spaces are required between publicId and systemId.

As a last fact I just to to make sure that nobody voluntarily uses RPC/encoded Web services (as introduced in another section of the article).

All in all, I like the basic idea of what Keith Pijanowski did. But I really expected that such public and recommended information had been tested and proved several times before published. Maybe a hint on the WS-I BP would have been just one more line or link in the article. We know from Yasser that they plan to fully support the BP in ASMX and it is really a must - there is no way out.

Just my 2 cents.

We all like attributes - don't we?

Well, I really like attributes in .NET. And this idea is just so plain cool and powerful that Microsoft has a patent on it.

Extending program languages with source-program attribute tags

Abstract
Attribute tags embedded in the statements of a source program system extend a programming language. A compiler for the program includes an interface to detect the attribute tags and to call one of a number of attribute-provider programs external to the compiler. The provider programs modify the operation of the compiler, for example by injecting additional statements or other code into the program at one or more predetermined points remote from the attribute tag. The compiler interface lists the names of the attributes and locations of their associated provider programs.

Do not forget about testing: your Web services will thank you

Testing. Unit testing. JUnit, NUnit ... yes we all know these buzzwords, these technologies and tools. They make our life as a software developer much easier - and try to make sure that our code behaves they way it is supposed to. But hey - what about those pesky Web services?

Well, I hope that the following lines won't sound too much like a marketing brochure - by I cannot stand and tell about my latest love affair in the Web services world. Fortunately, I seem not to be the only one who is addicted to this tool. The guys from Mindreef did a fantastic job and just released the latest incarnation of SOAPScope - they call it version 3.0 and seems to me like the best tool for testing and analyzing Web services.

The by far most interesting features of SOAPScope in my opinion are the nearly seemless integration into Visual Studio .NET and the support for testing your Web service (well, its contract) against the offical WS-I BP 1.0 recommendations (see screenshots below, click to see full size). Not to mention the forever existing testing functionality which supersedes the very basic ASMX-intrinsic test page by magnitudes.

  

One effect of the WS-I testing feature is that Scott Short's most excellent framework to include XML Schemas into an ASMX-hosted Web service does not (or better said: no longer) present a valid solution (see second screenshot).
Note to self: enhance Scott's code to make it BP-compliant. Urgently need by some customers.

OK, enough praise now. And obviously there is more than just those $99 to the tool. Some people might even dismiss their XBox:

“SOAPscope 3.0 is easily the most addictive piece of software I've encountered since Halo. When does the multi-player version come out?”
Don Box, XML Messaging Architect, Microsoft and co-inventor of SOAP

No, I am not related to Mindreef.

Service Agents as a best practice pattern to call Web services

'Nough said: Try to always think asynchronously when speaking and thinking about Web services. Kudos David.

In this article I’ll describe how you can implement a simpler asynchronous call pattern which allows you to consume web services from a WinForm application without having to worry about threads ever again.
[...]
Now while this is not exactly rocket science, I find the need for making such a ‘double hop’ is needlessly complicated. The problem is that the original caller of the asynchronous method (i.e., the WinForm class in this example) is made to be responsible for switching threads and this requires using another delegate and the Control.Invoke method.
[...]
One technique that I employ quite often to lessen the complexity, and the amount of code required, to making asynchronous calls is to factor the thread switching and delegate stuff into an intermediate class. This makes it really easy to make asynchronous calls from the UI class without ever having to worry about such things as threads and delegates. I call this technique ‘Auto Callback’.

Note to self: Enhance the WsContractFirst tool to allow support for a base Service Agent functionality - would help developers a lot.

Apache Axis C++ v1.0 Final released

Just 'forwarding' part of the email on the Axis mailing list to my blog:

We are proud to announce the release of Apache Axis C++ v1.0.
This implementation of a C++ SOAP engine provides a stable platform for developing Web services in C and C++. This engine can be used to develop client applications as well. This release includes the following features:

- SOAP engine with both client and server support
- Partial support for both SOAP 1.1 and SOAP 1.2
- Web Service Deployment Descripter (WSDD) based deployment
- Support for all basic types, complex types and arrays
- WSDL2Ws tool for building C/C++ components from WSDL,
     
Server side - Skeletons and Wrappers
     
Client side - Stubs
- WSDL2WS tool generated wrappers act as RPC Providers and they perform
     
Serialization
     
Deserialization
     
Method invocation
- WSDLs hosted statistically in the server
- Standalone SOAP server (HTTP)
- Web server modules for Apache HTTPD 1.3 (Linux/Windows)
- Web interface to the deployed services and their WSDLs
- Sample web services and client applications
- Supportive documentation for developers and users

Both binary and source are available at Apache mirror sites: http://www.apache.org/dyn/closer.cgi/ws/axis-c/