locked
Executing a service operation that returns a primitive type RRS feed

  • Question

  • Hi to all, I'm trying to execute this service operation: 
    [WebGet()]
    public int Add(int a, int b)
    {
    return a + b;
    }

    In this way:

    int a = 1; 
    int b = 2; 
    
    DataServiceQuery<int> query = context.CreateQuery<int("Add") 
    .AddQueryOption("a", a) 
    .AddQueryOption("b", b);
    
    int s = query.Execute().First();
    
    

    But I get:   

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata  <code></code>
      <message xml:lang="en-US">Bad Request - Error in query syntax.</message>
    </error>
    ">
    
    

    I have an error if I access to this uri : http://localhost:1135/WebDataService.svc/Add()?a=1&b=2

    I must use this other one: http://localhost:1135/WebDataService.svc/Add?a=1&b=2

    But I can consume the service operation if it's parameterless:

    [WebGet()]
    public int Add()
    {
        return 4;
    }
    
    
    DataServiceQuery<int> query = context.CreateQuery<int("Add") 
    int s = query.Execute().First();
    
    

    In this way, the value of the integer s is 4.

    Could somebody help me, please?

    Thanks :)

    Monday, November 23, 2009 4:10 PM

Answers

  • Hi there,

    You can send the repro/info to me: pqian at microsoft dot com

    Thanks!

    Regards,
    PQ
    Peter Q. http://blogs.msdn.com/peter_qian
    Tuesday, November 24, 2009 3:54 AM
    Answerer

All replies

  • Hi,

    Are you using CTP 2 of data service? There was a known bug with service op URI parser in V1 and it was fixed in the recent CTP release. If the problem still repros in the new CTP, let us know.

    Regards,
    PQ

    Peter Q. http://blogs.msdn.com/peter_qian
    Monday, November 23, 2009 6:58 PM
    Answerer
  • Hi Peter, thanks for your time. I know about this bug but I think this is another one. I'm using v1.5CTP2. I tryed to report this bug by Microsoft Connect, but I couldn't. I have more information about this bug that I can report.

    Thanks :)

    Monday, November 23, 2009 11:40 PM
  • Hi there,

    You can send the repro/info to me: pqian at microsoft dot com

    Thanks!

    Regards,
    PQ
    Peter Q. http://blogs.msdn.com/peter_qian
    Tuesday, November 24, 2009 3:54 AM
    Answerer
  • Hi, Im using DataServices V2, but i still have this problem, what is wrong with CreateQuery and WebGet? Where i can found detailed documentation of dataservice (las version) not old webcasts.

     

    i Think im going to create some extension method to replace to parentheses.


    Make it Ice
    Thursday, April 29, 2010 9:15 PM