Routing with WSE 2.0

Discussion in 'ASP .Net Web Services' started by Pete Wright, Feb 3, 2005.

  1. Pete Wright

    Pete Wright Guest

    Hi All,

    I'm trying to develop a custom SoapHttpHandler, but it just doesn't want to
    work. Here's my handler

    public class BrokerRoutingHandler :
    Microsoft.Web.Services2.Messaging.SoapHttpRouter
    {
    protected override Uri ProcessRequestMessage( SoapEnvelope message)
    {
    System.Diagnostics.EventLog EventLog1 = new
    System.Diagnostics.EventLog();

    if (!System.Diagnostics.EventLog.SourceExists("Broker"))
    System.Diagnostics.EventLog.CreateEventSource(
    "Broker", "Application");

    EventLog1.Source = "Broker";
    EventLog1.WriteEntry ("Intercepted a message and passed it on.");


    // Code goes here to intercept the message and have a tweak.
    return base.ProcessRequestMessage (message);
    }

    }
    Simple enough - the idea is that when this intercepts a message it will post
    to the event log just so I know it's doing something.

    I updated the web.config as the WSE documenation says to do for content
    based routing, to include this

    <system.web>
    :
    :
    <httpHandlers>
    <add type="BrokerService.BrokerRoutingHandler, BrokerService" path="*.asmx"
    verb="*" />
    </httpHandlers>
    </system.web>

    So, any request for any web service hits my customer handler.

    To build the application I created a standard web service project, with a
    web service in it, then added in WSE2.0 support, and then added in the class
    above.

    The problem is, when I hit F5 to run the app just to make sure everything's
    ok, I get this

    "WSE003: The input was not a valid SOAP message"

    I have tried pretty much all I can think of to solve this. Any ideas?
    (All replies to the group please -I've searched Google relentlessly for a
    solution or anyone that's come across WSE003 as an error code and found
    nothing, so we should probably keep this public.)


    Cheers,


    --
    Pete Wright
    Author of ADO.NET Novice to Pro for Apress
    www.petewright.org
    Pete Wright, Feb 3, 2005
    #1
    1. Advertising

  2. Hello Pete,
    Cannot hit F5 and run a web service. You would need to create a web service
    client and send a soap message to it. What seems to be happening here is,
    when you hit F5 the IDE makes a web request to xyz.asmx and that request
    goes through your router aswell (no surprises there)! If you are just wanting
    to log any request using your router, Id suggest you could just create a
    SoapExtension [0] that traces your request.

    [0] - http://msdn.microsoft.com/library/d...bservicesprotocolssoapextensionclasstopic.asp
    HTH
    Regards,
    Dilip Krishnan
    MCAD, MCSD.net
    dkrishnan at geniant dot com
    http://www.geniant.com

    > Hi All,
    >
    > I'm trying to develop a custom SoapHttpHandler, but it just doesn't
    > want to work. Here's my handler
    >
    > public class BrokerRoutingHandler :
    > Microsoft.Web.Services2.Messaging.SoapHttpRouter
    > {
    > protected override Uri ProcessRequestMessage( SoapEnvelope message)
    > {
    > System.Diagnostics.EventLog EventLog1 = new
    > System.Diagnostics.EventLog();
    > if (!System.Diagnostics.EventLog.SourceExists("Broker"))
    > System.Diagnostics.EventLog.CreateEventSource(
    > "Broker", "Application");
    > EventLog1.Source = "Broker";
    > EventLog1.WriteEntry ("Intercepted a message and passed it on.");
    > // Code goes here to intercept the message and have a tweak.
    > return base.ProcessRequestMessage (message);
    > }
    > }
    > Simple enough - the idea is that when this intercepts a message it
    > will post
    > to the event log just so I know it's doing something.
    > I updated the web.config as the WSE documenation says to do for
    > content based routing, to include this
    >
    > <system.web>
    > :
    > :
    > <httpHandlers>
    > <add type="BrokerService.BrokerRoutingHandler, BrokerService"
    > path="*.asmx"
    > verb="*" />
    > </httpHandlers>
    > </system.web>
    > So, any request for any web service hits my customer handler.
    >
    > To build the application I created a standard web service project,
    > with a web service in it, then added in WSE2.0 support, and then added
    > in the class above.
    >
    > The problem is, when I hit F5 to run the app just to make sure
    > everything's ok, I get this
    >
    > "WSE003: The input was not a valid SOAP message"
    >
    > I have tried pretty much all I can think of to solve this. Any ideas?
    > (All replies to the group please -I've searched Google relentlessly
    > for a
    > solution or anyone that's come across WSE003 as an error code and
    > found
    > nothing, so we should probably keep this public.)
    > Cheers,
    >
    Dilip Krishnan, Feb 3, 2005
    #2
    1. Advertising

  3. Pete Wright

    Pete Wright Guest

    Thanks Dilip.

    eventually this handler will grow into a dynamic router based on content in
    the message passed in; for now though I'd just be happy to see the handler
    running.

    You are right though - I changed the proxy that I had calling the service to
    use
    Microsoft.Web.Services2.WebServicesClientProtocol

    sinstead of the standard base class. Now I get an error of Destination
    unreachable.

    Does it matter that the handler and web service are on the same machine? Any
    ideas?

    Pete


    "Dilip Krishnan" <> wrote in message
    news:...
    > Hello Pete,
    > Cannot hit F5 and run a web service. You would need to create a web
    > service client and send a soap message to it. What seems to be happening
    > here is, when you hit F5 the IDE makes a web request to xyz.asmx and that
    > request goes through your router aswell (no surprises there)! If you are
    > just wanting to log any request using your router, Id suggest you could
    > just create a SoapExtension [0] that traces your request.
    >
    > [0] -
    > http://msdn.microsoft.com/library/d...bservicesprotocolssoapextensionclasstopic.asp
    > HTH
    > Regards,
    > Dilip Krishnan
    > MCAD, MCSD.net
    > dkrishnan at geniant dot com
    > http://www.geniant.com
    >
    >> Hi All,
    >>
    >> I'm trying to develop a custom SoapHttpHandler, but it just doesn't
    >> want to work. Here's my handler
    >>
    >> public class BrokerRoutingHandler :
    >> Microsoft.Web.Services2.Messaging.SoapHttpRouter
    >> {
    >> protected override Uri ProcessRequestMessage( SoapEnvelope message)
    >> {
    >> System.Diagnostics.EventLog EventLog1 = new
    >> System.Diagnostics.EventLog();
    >> if (!System.Diagnostics.EventLog.SourceExists("Broker"))
    >> System.Diagnostics.EventLog.CreateEventSource(
    >> "Broker", "Application");
    >> EventLog1.Source = "Broker";
    >> EventLog1.WriteEntry ("Intercepted a message and passed it on.");
    >> // Code goes here to intercept the message and have a tweak.
    >> return base.ProcessRequestMessage (message);
    >> }
    >> }
    >> Simple enough - the idea is that when this intercepts a message it
    >> will post
    >> to the event log just so I know it's doing something.
    >> I updated the web.config as the WSE documenation says to do for
    >> content based routing, to include this
    >>
    >> <system.web>
    >> :
    >> :
    >> <httpHandlers>
    >> <add type="BrokerService.BrokerRoutingHandler, BrokerService"
    >> path="*.asmx"
    >> verb="*" />
    >> </httpHandlers>
    >> </system.web>
    >> So, any request for any web service hits my customer handler.
    >>
    >> To build the application I created a standard web service project,
    >> with a web service in it, then added in WSE2.0 support, and then added
    >> in the class above.
    >>
    >> The problem is, when I hit F5 to run the app just to make sure
    >> everything's ok, I get this
    >>
    >> "WSE003: The input was not a valid SOAP message"
    >>
    >> I have tried pretty much all I can think of to solve this. Any ideas?
    >> (All replies to the group please -I've searched Google relentlessly
    >> for a
    >> solution or anyone that's come across WSE003 as an error code and
    >> found
    >> nothing, so we should probably keep this public.)
    >> Cheers,
    >>

    >
    >
    Pete Wright, Feb 3, 2005
    #3
  4. Pete Wright

    Pete Wright Guest

    Solved the problem.

    By having the handler registered as "*.asmx* what was happening was that the
    router was initially triggering and then directing out to something.asmx.
    This would then pop back into the router and get thrown out since each time
    the router gets hit the next Via is set to the current To:, so the second
    time around To is cleared out and there are no more vias - if that makes
    sense, so the result is desintation unreachable.

    The solution is to have the handler pick up specific names (since this is a
    broker we are going for request.asmx and publish.asmx) and then route out to
    the appropriate service, OR always route out to asmx files in a different
    virtual directory. The latter is better because then you really can keep the
    router on one machine and services on another.


    "Pete Wright" <> wrote in message
    news:...
    > Thanks Dilip.
    >
    > eventually this handler will grow into a dynamic router based on content
    > in
    > the message passed in; for now though I'd just be happy to see the handler
    > running.
    >
    > You are right though - I changed the proxy that I had calling the service
    > to
    > use
    > Microsoft.Web.Services2.WebServicesClientProtocol
    >
    > sinstead of the standard base class. Now I get an error of Destination
    > unreachable.
    >
    > Does it matter that the handler and web service are on the same machine?
    > Any
    > ideas?
    >
    > Pete
    >
    >
    > "Dilip Krishnan" <> wrote in message
    > news:...
    >> Hello Pete,
    >> Cannot hit F5 and run a web service. You would need to create a web
    >> service client and send a soap message to it. What seems to be happening
    >> here is, when you hit F5 the IDE makes a web request to xyz.asmx and that
    >> request goes through your router aswell (no surprises there)! If you are
    >> just wanting to log any request using your router, Id suggest you could
    >> just create a SoapExtension [0] that traces your request.
    >>
    >> [0] -
    >> http://msdn.microsoft.com/library/d...bservicesprotocolssoapextensionclasstopic.asp
    >> HTH
    >> Regards,
    >> Dilip Krishnan
    >> MCAD, MCSD.net
    >> dkrishnan at geniant dot com
    >> http://www.geniant.com
    >>
    >>> Hi All,
    >>>
    >>> I'm trying to develop a custom SoapHttpHandler, but it just doesn't
    >>> want to work. Here's my handler
    >>>
    >>> public class BrokerRoutingHandler :
    >>> Microsoft.Web.Services2.Messaging.SoapHttpRouter
    >>> {
    >>> protected override Uri ProcessRequestMessage( SoapEnvelope message)
    >>> {
    >>> System.Diagnostics.EventLog EventLog1 = new
    >>> System.Diagnostics.EventLog();
    >>> if (!System.Diagnostics.EventLog.SourceExists("Broker"))
    >>> System.Diagnostics.EventLog.CreateEventSource(
    >>> "Broker", "Application");
    >>> EventLog1.Source = "Broker";
    >>> EventLog1.WriteEntry ("Intercepted a message and passed it on.");
    >>> // Code goes here to intercept the message and have a tweak.
    >>> return base.ProcessRequestMessage (message);
    >>> }
    >>> }
    >>> Simple enough - the idea is that when this intercepts a message it
    >>> will post
    >>> to the event log just so I know it's doing something.
    >>> I updated the web.config as the WSE documenation says to do for
    >>> content based routing, to include this
    >>>
    >>> <system.web>
    >>> :
    >>> :
    >>> <httpHandlers>
    >>> <add type="BrokerService.BrokerRoutingHandler, BrokerService"
    >>> path="*.asmx"
    >>> verb="*" />
    >>> </httpHandlers>
    >>> </system.web>
    >>> So, any request for any web service hits my customer handler.
    >>>
    >>> To build the application I created a standard web service project,
    >>> with a web service in it, then added in WSE2.0 support, and then added
    >>> in the class above.
    >>>
    >>> The problem is, when I hit F5 to run the app just to make sure
    >>> everything's ok, I get this
    >>>
    >>> "WSE003: The input was not a valid SOAP message"
    >>>
    >>> I have tried pretty much all I can think of to solve this. Any ideas?
    >>> (All replies to the group please -I've searched Google relentlessly
    >>> for a
    >>> solution or anyone that's come across WSE003 as an error code and
    >>> found
    >>> nothing, so we should probably keep this public.)
    >>> Cheers,
    >>>

    >>
    >>

    >
    >
    Pete Wright, Feb 3, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Heliboy

    Xilinx FPGA routing question

    Heliboy, Jul 6, 2004, in forum: VHDL
    Replies:
    1
    Views:
    620
    Kelvin
    Jul 6, 2004
  2. Alex

    Routing to AppDomains

    Alex, Aug 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    314
  3. =?Utf-8?B?anV2aQ==?=

    Routing System for buildings

    =?Utf-8?B?anV2aQ==?=, Nov 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    349
    John Timney \( MVP \)
    Nov 7, 2005
  4. james

    Vehicle Routing problem

    james, Jan 10, 2004, in forum: Java
    Replies:
    1
    Views:
    1,003
    Chris Gokey
    Jan 11, 2004
  5. Replies:
    0
    Views:
    400
Loading...

Share This Page