开发者

SSRS 2005 - XML webservice dataset - parameters not getting passed to webservice

I have an SSRS 2005 report which I'd like to use a webservice to retrieve some data. This webservice will take in several parameters.

As a test I set up a very simple demo webservice project on my local environment:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    public Service () {}

    [WebMethod]
    public int DivideByTwo(int numberIn) {
        return numberIn/2;
    }   
}

My test report then has a Dataset using an XML datasource, with the (localhost) URL of the webservice in the connection string.

In the query string of the dataset I have the following, based on MS documentation (http://msdn.microsoft.com/en-us/library/aa964129(SQL.90).aspx):

<Query>
    <SoapAction>http://tempuri.org/DivideByTwo</SoapAction>
    <Method Namespace="http://tempuri.org/" Name="DivideByTwo" />
    <Parameters>
        <Parameter Name="NumberIn">
          <DefaultValue>100</DefaultValue>
        </Parameter>
    </Parameters>
    <开发者_高级运维;ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>

The problem I'm having is that, despite the webservice being triggered, the parameter is not getting passed to the webservice and consequently the return value is always 0. I've debugged the webservice and placed a breakpoint in the DivideByTwo() method, and when the webservice call is triggered from the report and the breakpoint is hit, the numberIn value is always 0 regardless of what I place in the element of the Query XML.

I've also tried specifying the "NumberIn" parameter in the "Parameters" tab of the Dataset dialog box (with a supplied value) and removing the element from the query XML - the result is the same.

I've found some posts on the web outlining the same issue but can't seem to find a solution, and have been tearing my hair out for the last couple of hours. Any help would be much appreciated.


As DavveK mentioned, it looks like it's a simple typo with the capitalization of your parameter.

Your service definition is looking for:

numberIn

while your XML DataSet provides:

NumberIn

As the article you referenced mentions, paramaters are case-sensitive. See #8 at http://msdn.microsoft.com/en-us/library/aa964129(SQL.90).aspx


This can happen due to two reasons.

1) Parameter names are not exactly matched. Note that parameter names are case sensitive.

2) Namespace is not correctly matched. Note that if you specifiy namespace as "http://tempuri.org/" make sure that the trailing forward slash character is there in your webservice definition. E.g.

[WebService(Namespace = "http://tempuri.org/")]
public class ReportService : System.Web.Services.WebService
{

}

If any of these two conditions are not correctly specified, your web service method will get called yet the parameters (like datatime, int) will all have default values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜