in

ASP.NET Weblogs

Christian Weyer: Smells like service spirit

What's first?

September 2004 - Posts

  • *Must have* resource on Web services interop

    MSDN, finally an official place for Web services interop on MSDN. Do not miss the overall great Web Services Interoperability Guidance (WSIG)!
    Current installments:

    IBM WebSphere Application Developer 5.1.2
    Simon Guest shares recommendations for Web Services interoperability between the Microsoft .NET Framework 1.1 and IBM WebSphere Application Developer (WSAD) 5.1.2.  

    BEA WebLogic 8.1 SP3 (8.1.3)
    Based on a series of unit tests between Microsoft .NET and BEA WebLogic 8.1.3, this article shows a series of scenarios and recommendations for achieving Web Services Interoperability between the two.  

    WS-Security Interoperability Using WSE 2.0 and Sun JWSDP 1.4
    This article shows WS-Security Interoperability between Microsoft WSE 2.0 and Sun JWSDP 1.4. The walkthroughs in this article will take you through all you need to know to configure the two environments for securely signing and encrypting SOAP requests and responses using X509 certificates.  

    Mr. Simon Guest did it. Again.

  • The Web services empire strikes back - Schema Importer Extensions

    Part 1: The Web services empire strikes back - Introductory thoughts
    Part 2: The Web services empire strikes back - Inner Workings
    Part 3: The Web services empire strikes back - Web Services in Visual Studio 2005
    Part 4: The Web services empire strikes back - WS-I BP Conformance
    Part 5: The Web services empire strikes back - Custom XML Serialization
    Part 6: The Web services empire strikes back - Proxy Type Sharing
    Part 7: The Web services empire strikes back - Contract-first with .NET 'IDL'

    Just imagine you have a new data class that provides a disconnected, in-memory cache of data from a relational data store and you are sure nobody else has ever implemented this. Now your instances of this class to be used to pass data between Web services. If you have read this small articles series carefully, you might want to say that you just have implement the IXmlSerializable interface for this type. This enables you to control the serialization and deserialization of instances of the class and provide whatever schema they want to expose for the type. Great. While this addresses serialization, deserialization and schema export, what about the actual programming experience on the client? The exact programming model that is available on the service side should also to be provided to consumers of Web services that utilize this new data type - at least on the .NET platform. There are cases where you just do not want to use simple data containers, but classes with a bit of logic in it. Please note, that I personally do not think this is a good design decision, but you cannot always have the best of breed design ideas implemented in your every day projects.

    Essentially, the programming model should roundtrip the schema export on the service side to the schema import on the client process. Again, this is not about type fidelity like in .NET Remoting! It is just for enabling the Web services consumer developer with the same powerful programming model that may be exposed in the services internal implementation. The solution is to implement a SchemaImporterExtension-based extension that generates the same programming model on the client.

    The so called Schema Import Extensions feature of ASMX v2 enables third-parties to plug into the schema import process. This process is invoked whenever a Web service proxy is produced either via the Add Web Reference .. dialog or wsdl.exe (or some other tool that uses the intrinsic classes). The schema import involves the creation of a source code representation of a graph of CLR types induced by the examination of the provided schema. These extensions are called on import to generate proxy code for schemas and WSDL. They are pluggable at the application and machine configuration level for dynamic deployment.

    As you might imagine, this feature is the base for supporting new data types and controlling the schema generation for both the .NET Framework developers and you. For example there are already two pre-built implementations of the base class in the next version of the .NET Framework: System.Data.DataSetSchemaImporterExtension and System.Data.Design.TypedDataSetSchemaImporterExtension.

    To make things a bit clearer lets take a look at an example.
    When registered appropriately, this example SchemaImporterExtension takes care of providing the actual implementation for an Order type. There are two overloaded versions of the ImportSchemaType method. Here we use the version that explicitly expects the name and the namespace of a type as a string. When we encounter a certain type we just use CodeDoms functionality to import our .NET namespace for the Order type into the CodeDom code namespace. For ease of deployment we do not inject any source code into the generated proxy files but rather rely on referencing an external assembly. This assembly has to be deployed hand in hand with the schema importing assembly.

    public class OrderSchemaImporterExtension : SchemaImporterExtension
    {
      public override string ImportSchemaType(string name, string ns,
        XmlSchemaObject context, XmlSchemas schemas,
        XmlSchemaImporter importer, CodeNamespace codeNamespace,
        StringCollection references, CodeGenerationOptions options,
        ICodeGenerator codeGenerator)
      {
        if(name.Equals("Order") && ns.Equals("
    http://orders/"))
        {
          references.Add("Order.dll");
          codeNamespace.Imports.Add(new
            CodeNamespaceImport("MSDNOnline.Samples"));
          return "MSDNOnline.Samples.Order";
        }
        return null;
      }

      public override CodeExpression ImportDefaultValue(
        string value, string type)
      {
        return new CodePrimitiveExpression(new Order());
      }
    }


  • Databases, MSMQ, [you name a resource manager] and Services Without Components

    Just another quick note from today's work:
    as a lot of other people and well-known gurus have already stated - SWC (services without components) is maybe one of the most powerful and yet unknown features of.NET Enterprise Services (yeah, this COM+-y thing ...). No need for ServicedComponent and registration in the registry and COM+ catalog.

    All the love and goodness can be found in the System.EnterpriseServices namespace - namely the ServiceConfig and ServiceDomain classes. E.g. to both update a SQL Server database and place a message in a transactional queue in MSMQ is as easy as some lines of code without the burden of a configured COM+ component.

    using System.EnterpriseServices;
    using System.Messaging;
    using System.Data.SqlClient;

    ...

    public void StoreData()
    {
      ServiceConfig sc = new ServiceConfig();
      sc.Transaction = TransactionOption.Required;
      ServiceDomain.Enter(sc);
     
      try
      {
        using(SqlConnection myConnection = new SqlConnection("..."))
        {
          SqlCommand myCommand = new SqlCommand();

          MessageQueue myQueue = new MessageQueue(@".\MyQueue");
          myQueue.Send("1", "CW", MessageQueueTransactionType.Automatic);
      
          myConnection.Open();
          myCommand.Connection = myConnection;
          myCommand.CommandText = "INSERT INTO ...";
          myCommand.ExecuteNonQuery();
      
          ContextUtil.SetComplete();
        }
     
     }
      catch(System.Exception ex)
      {
        ContextUtil.SetAbort();
      }
      finally
      {
       
    ServiceDomain.Leave();
      }
    }

    This feature works with Windows Server 2003 and Windows XP SP2, officially.
    But, there is a tweak to get it working before XP SP2: Hotfix 828741. You won't see any single word about SWC mentioned there, but believe me, with this hotfix all things are good :) Thanks to Christian for this last hint.

  • They did it again: SOAPScope 4.0

    A great product can even get greater. SOAPScope 4.0 has been released ...

    Mindreef SOAPscope 4.0 is a toolkit-independent Web services diagnostic system for examining, debugging, testing, tuning, and supporting Web services. New features include:

    • SOAPscope Workspace: Gather Web services resources for a particular test or problem. Focus on the relevant resources viewing, testing, analyzing and annotating within the workspace environment.
    • SOAPscope Packaging: Workspaces may be saved to a package file for archival and sharing. Use Packaging to create artifacts of your testing process or capture and share problems between customers, support, operations, test, and development.
    • WSDL Closures: WSDL documents may reference other documents, which may also reference documents. The complete hierarchy is called a WSDL closure. SOAPscope 4.0 is the first tool that can compare, analyze or graphically view a WSDL closure.
    • Testing Secure Services: WSDL Invoke and Message Resend can now utilize SSL client certificates for mutual authentication. WS-Security compliant user and password header info can be included when invoking or resending messages.
    • Support for New Standards and Technologies: Industries first product to support test against the newest WS-I standards including the WS-I Basic Profile 1.1 and WS-I Attachments Profile 1.0. Attachments support includes features to test, debug and support services that employ SwA/MIME attachments.
    • Eclipse 2.x/3.0 Plug-in Support: Use SOAPscope directly within the popular Eclipse IDE without having to leave the IDE. New support for Eclipse 2.x makes the plugin available to a broader audience.
    • Improved Scalability: As the sophistication of Web Services increases customer demands on SOAPscope are scaling as well. Release 4.0 is tuned for better thoughput, memory utilization, reliability and performace to meet the growing demands of our customers.

  • Indigo and COM+ - together we are

    Just a quick note as I am watching Don Box's Channel9 video wandering the floors of Building 42:

    Andy Milligan, responsible for integrating the 'old' and unmanaged COM+ world with Indigo, states that that a developer will be able to automatically expose a deployed COM+ service as an Indigo service, od course without having the need to change existing DCOM-based clients. The bridging goo between the Indigo message and the COM+ call (in both directions, for server and client code) will be handled inside the infrastructure and not in your code.

    OK, I not quite sure about the 'vision' of connecting my Excel spreadsheet with VBA scripts and DCOM calls to my Indigo services - but at least it will be possible ;)

    Posted Sep 14 2004, 02:08 AM by CWeyer
    Filed under:
  • The Web services empire strikes back - Contract-first with .NET 'IDL'

    Part 1: The Web services empire strikes back - Introductory thoughts
    Part 2: The Web services empire strikes back - Inner Workings
    Part 3: The Web services empire strikes back - Web Services in Visual Studio 2005
    Part 4: The Web services empire strikes back - WS-I BP Conformance
    Part 5: The Web services empire strikes back - Custom XML Serialization
    Part 6: The Web services empire strikes back - Proxy Type Sharing

    Clemens thinks 'IDL' is good and often enough to hammer down your services interface and message contract - well somehow, yes.
    But we do not have to wait for Indigo, just some few months for Whidbey. T
    hings really get better with ASMX v2 in Whidbey.

    The following description assumes that you already have an exisiting WSDL (or a bunch of them) and then generate code from it. But the process can also be turned around: First code your interface in .NET and voila... you have the code-based contract-first approach rather than the schema-based one with XSD and WSDL.

    ASMX v2 will generate a different interface for each binding in a WSDL description. E.g.:

    [WebServiceBinding(Name="OrderBinding", Namespace="urn:...")]
    public interface IOrderEntry
    {
          [WebMethod]
          [SoapDocumentMethod(...)]
          string PlaceOrder(Order order);

          [WebMethod]
          [SoapDocumentMethod(...)]
          string UpdateOrder(Order order);

    }

    Each interface has the WebServiceBindingAttribute with the binding's name and namespace. At runtime, ASMX reflects over the interfaces that a user's class implements to find all WebServiceBinding and WebMethod attributes. A class that implements an interface which has the WebServiceBindingAttribute can't itself have any Web services or XML serialization attributes. Makes sense but is very important!
    Obviously, a class can implement multiple interfaces each corresponding to a different WSDL binding, but a given binding cannot be split across multiple interfaces.
    If an interface inherits from another interface, at most one of the interfaces can have the WebServiceBindingAttribute. This is analogous to WSDL not allowing portType inheritance.
    The generated interface has the same name as the binding name and is prefixed with 'I' to indicate "Interface". Multiple bindings can be passed to the code generation process (e.g. with wsdl.exe) in one or more WSDL files. Each binding will then yield a different interface.

    And as already stated at the beginning of this article: Just use this approach reversely and you are all set to design your contract-first Web services in 'IDL'.

  • SwA feature support for .NET

    Update: Simon does not use the ASMX runtime, sorry.

    Now, with MTOM being in the final stages ... we still need a real-world solution for opaque data today. OK, there is DIME support in WSE 2.0 ... and Simon Fell has the well-known PocketSOAP COM lib which obviously can also be used in .NET.
    He shows how to leverage the SwA feature of PocketSOAP in a Web service hosted in ASP.NET. Nice.

  • Beispiele für den WebCast "Connected Systems - Implementierungsstrategien: ASMX und WSE"

    Wie versprochen stellen Dariusz und ich hier die gezeigten Beispiele aus dem WebCast vom Montag, den 6. September 2004 zur Verfügung. Wer den Live WebCast verpasst hat, kann ihn sich (und freilich alle anderen auch) über die deutsche MSDN-Seite herunter laden - so ca. in eins bis zwei Wochen.

    Der Download besteht aus drei Beispielanwendungen zum Thema ASMX und WSE 2.0:

    • Im ersten Sample zeigen wir den Schritt weg vom klassischen Hello World Web Service, hin zu einem mehr nachrichtenorientierten Denken bei Web services mit ASMX (ASP.NET Web services). Es wird gezeigt wie man die interne .NET-Implementierung weitestgehend entkoppeln kann vom aussen sichtbaren Interface und Message Contract des Web services - per Code -> Code-basiertes Contract First.
    • Die zweite Demo besteht aus einem Web-Projekt und einer Windows Forms-Applikation. Im initial leeren Web-Projekt soll ein ASMX Web service gehostet werden. Ziel ist es, beide Anwendungen völlig unabhängig voneinander zu entwickeln - das einzige was beide wissen müssen ist, wie der Contract in Form eines WSDL ausssieht.
      Dieses WSDL wurde vorher mit einem externen WSDL Editor von CapeClear entworfen, basierend auf einem Schema welches in Form eines XSDs im Visual Studio .NET 2003 erstellt wurde. Ausgehend von diesen XML-Metadaten wird dann mittels des WsContractFirst Tools .NET Code für beide Anwendungen erzeugt. -> Schema-basiertes Contract First.
    • Das letzte Beispiel dient der Verdeutlichung von "echten" Einwegnachrichten basierend auf SOAP. Mit WSE 2.0 lässt sich auf unterschiedlichen Ebenen (SoapSender/SoapReceiver oder SoapClient/SoapService) SOAP Messaging par excellence implementieren. Die beiden Windows Forms-Anwendungen zeigen dies anhand von SoapSender und SoapReceiver.

    Für Fragen können Sie gerne Kontakt mit mir aufnehmen. Danke.

  • No, not HTTP, UDP! Soap over UDP spec

    Now it gets real: standards-based SOAP-not-only-over-HTTP with SOAP-over-UDP:

    Many application protocol patterns match the semantics of the User Datagram Protocol (UDP) [RFC 768]. Some do not require the delivery guarantees of TCP while others make use of multicast transmission. In order to allow Web services to support these patterns, we need a way to map SOAP envelopes to user datagrams. This support is essential for services using WS-Discovery, where the use of multicast and need for low connection overhead makes UDP a natural choice. It is anticipated that other protocols will have similar requirements. This specification defines a binding of SOAP to user datagrams, including message patterns, addressing requirements, and security considerations.

More Posts