locked
Custom Service Operation Woes RRS feed

  • Question


  • Seasoned developer, WCF noobie. I am trying to do what seems to be the "hello world" of a custom service operation, and the reference I am using is here: http://msdn.microsoft.com/en-us/library/cc668788(VS.100).aspx.

    I have a DataService for Jobs and have no problems with:

    * The Standard IQueryable<Job> Jobs property, as Reflected by the DataService provider.

    * A parameterless Method as a custom service operation
     
    [WebGet] public IQueryable<Job> GetRecentJobs()...

    However, with something like public IQueryable<Job> GetJobsByNameOrNumber(string query), I get:

    The communication object, System.ServiceModel.Channels.TransportReplyChannelAcceptor+TransportReplyChannel, cannot be used for communication because it has been Aborted. 

    I setup tracing and viewed the exception using SvcTraceViewer. This exception only occurs with a proper url that contains the "query" parameter, such as http://host/data.svc/GetJobsByNameOrNumber?query=42. The data service operation does not even execute!
    The exception does NOT occur with a parameterless url (http://host/data.svc/GetJobsByNameOrNumber); the code executes, but with of course a null value for 'query'.
    The exception does NOT occur with a parameterized query of the wrong parametername (http://host/data.svc/GetJobsByNameOrNumber?nottherealparam=42); the code executes, but with of course a null value for 'query'.

    This is repeatable in a brand new web application project. It's repeatable on my workstation (XP SP3) and a dev server (Win 2003 R2). It doesn't matter the querystring parameter name (tried 'p0', etc.). It's repeatable with a rotely simplified method, returning a primitive type, such as:

     

    [WebGet] public string GetGreeting(string query){return "Hello, " + query;}

     

    thanks in advance

    Wednesday, July 1, 2009 4:08 PM

Answers

  • Hi ,
     I just tried this out a local Data Service and dont see the same issue . Not that it means anything , just verifying if this scenario is totally broken.

     String parameters to Service operations should be surrounded by single quotes ,
     
    http://host/data.svc/GetJobsByNameOrNumber?query='42'

    If the error still continues after adding the single quotes to the URI , please give us the following data .
    1.  How are you hosting the data service ? Is it in IIS or the Visual Studio Web Server ( Cassini ) ?
    2.  If you are not hosting it  in IIS , then a fiddler trace would be really helpful when this error occurs.
     
     
    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Wednesday, July 1, 2009 4:45 PM
    Moderator

All replies

  • Hi ,
     I just tried this out a local Data Service and dont see the same issue . Not that it means anything , just verifying if this scenario is totally broken.

     String parameters to Service operations should be surrounded by single quotes ,
     
    http://host/data.svc/GetJobsByNameOrNumber?query='42'

    If the error still continues after adding the single quotes to the URI , please give us the following data .
    1.  How are you hosting the data service ? Is it in IIS or the Visual Studio Web Server ( Cassini ) ?
    2.  If you are not hosting it  in IIS , then a fiddler trace would be really helpful when this error occurs.
     
     
    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Wednesday, July 1, 2009 4:45 PM
    Moderator
  • Ugh. This problem was hour #2 wasted due to poor MSDN documentation (I also wasted another hour on the 'contains' function, which doesn't actually exists-it appears to have been replaced with 'substringof'.

    The page I referenced above shows clearly no quotes around the parameter value (there are other same examples on MSDN):

    Addressing Service Operations

    You can address service operations by placing the name of the method in the first path segment of a URI. As an example, the following URI accesses a CustomersByCity operation that returns an IQueryable of Orders types:

    http://localhost:12345/northwind.svc/CustomersByCity?city=London.

    Shame on me for following the docs! Thank you, Phani.

    Wednesday, July 1, 2009 5:05 PM
  • Hi ,
     I've opened a documentation bug against that MSDN article , I apologize for the inconvenience.

     In the meantime , Mike's article is an excellent primer on ADO.NET Data Services.
     Its available here :  http://msdn.microsoft.com/en-us/library/cc907912.aspx
     It has a section called "Data Type Literal Representations" which talks about the various literal forms for parameters to Service operation .
    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Wednesday, July 1, 2009 5:09 PM
    Moderator