locked
Force XmlSchemaProvider method execution on every HTTP request RRS feed

  • Question

  • Is there a way to force XmlSchemaProvider method execution on every http  request? Trying to send an additional QueryString  parameter during WSDL request. Intent of this additional parameter is to construct a different schema based on the parameters and return appropriate schema in the HTTP response. XmlSchemaProvider registered method does not get called for every HTTP request.  Is there anyway to force this method call every HTTP Request?
    Friday, November 30, 2012 11:02 PM

All replies

  • What kind of request? Are you asking about ASMX web services?


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Monday, December 3, 2012 6:23 PM
    Moderator
  • Thanks John

    Yes I am referring to ASMX. I have a XmlSchemaProvider that reflects a WSDL from a schema to the consumer. When the consumer passes QueryString parameter with every request, the XmlSchemaProvider method picks the appropriate schema to reflect. This parameter is in addition to the WSDL querystring. It looks like not every WSDL request is invoking XmlSchemaProvider method. Is there a way to invoke XmlSchemaProvider method for every HTTP request? 


    Tuesday, December 4, 2012 3:46 AM
  • I still have no idea what you're talking about.

    What kinds of request are currently causing your XmlSchemaProvider to be called?

    What kinds of request do you want to have calling your provider?


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Wednesday, December 5, 2012 2:31 PM
    Moderator
  • XmlSchemaProvider attribute is invoked by ASMX SoapReflector. Use this link, scroll down to Schema Provider and Web Services section. This is the technique I am using to reflect WSDL to a consumer. 

    For ex: I have a web service say Service1.asmx. Typically consumers call Service1.asmx?WSDL to get its WSDL. 

    I am extending WSDL reflection using Schema Provider attribute. In addition, I am allowing consumers to call Service1.asmx?WSDL&component=Contact, Service1.asmx?WSDL&component=Customer or Service1.asmx?WSDL&component=Order

    component parameter triggers what schema is reflected to the consumer. However, Schema Provider method is not invoked everytime the WSDL URL with component parameter is called. It seems to be called infrequently. I have code attached to W3WP and this is how I can see the method is called infrequently and also the WSDL content doesn't change when method isn't invoked

    First call; Service1.asmx?WSDL&component=contact; contact WSDL is reflected

    Second call; Service1.asmx?WSDL&component=customer; sometimes contact WSDL is reflected and sometimes it is not

    Third call; Service1.asmx?WSDL&component=order; once again sometimes order WSDL is reflected and sometimes it is not

    hope this helps

    Wednesday, December 5, 2012 3:29 PM
  • ASMX web services have no support for what you're trying to accomplish.

    In particular, there is only one WSDL per service. That's the WSDL that you can affect through XmlSchemaProvider. You cannot get a different WSDL based on query string parameters.

    If you need multiple WSDLs, then you need multiple ASMX services.

    You may be able to do something of this nature with WCF. It implements the WS-MetadataExchange protocol for returning multiple related metadata documents about a service (including WSDL documents). I haven't seen an example of what you're looking for, but I note that invocations of this protocol involve passing a URI to the service. I presume that you the URI might contain a query string, or that you could use something like Service1.svc/Customer in the URI.

    See the System.ServiceModel.Description namespace, but especially the members with names starting with "Metadata", and the IMetadataExchange Interface.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Thursday, December 6, 2012 7:03 PM
    Moderator
  • John,

    With all due respect, I have to disagree. It's easy to recreate this.I can upload my project if you want to have a look. After every WSDL load when I run an IISRESET or kill the appropriate W3WP process; consumer can invoke the URL with a different component parameter for every invoke after every reset and download a different WSDL everytime for the same method and same web service

    Say, I save each of these WSDL to the disk and provide to the consumer like soapUI as files. soapUI can successfully load all 3 WSDLs, call the same service, same method with 3 entirely different schemas.

    When soapUI invokes my web method, I can override

    public void ReadXml(XmlReader reader)

    , inspect the namespace and type cast to appropriate object. Furthermore, I am able to access this type casted object inside the same webmethod

    Only problem I am running into is the damn IISRESET everytime I need a new WSDL and save it to disk as a file, which takes away the charm of a self describing WSDL

    Thanks

    Thursday, December 6, 2012 8:50 PM
  • Believe it or not, we're in agreement.

    The fact that you need to do that IISRESET is proof that ASMX does not support the functionality to switch the WSDL based on the URL used to request it. It may happen to not remove the query string from the URL, allowing you to return the chosen WSDL.

    But only the first time. ASMX has no idea that the query string might change, and so caches the files resulting from the first call. You're not going to get it to cache by query string. This is not a function that it supports.

    You've got to keep in mind that the last major release for this functionality was in .NET 2.0, seven years ago. Other than JSON support for AJAX, nothing has really changed in ASMX in the past seven years.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Thursday, December 6, 2012 9:54 PM
    Moderator
  • Thanks for your patience and response. Is there a way to access the SoapProtocolReflector, ProtocolReflector, DiscoveryServerProtocol, or ServerProtocolFactory from inside ASMX?  I have a theory that I can reinitiate a reflection from Application_BeginRequest

    Friday, December 7, 2012 5:20 PM
  • I have no idea if there's a way to do that. It would almost certainly be unsupported.

    One of the benefits of doing it with WCF is that it would be supported.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Friday, December 7, 2012 11:56 PM
    Moderator