Reporting services 使用Web服务和参数的SSRS XML数据源
我有一个使用C#和VisualStudio2010创建的Web服务。定义如下Reporting services 使用Web服务和参数的SSRS XML数据源,reporting-services,Reporting Services,我有一个使用C#和VisualStudio2010创建的Web服务。定义如下 [WebService(Namespace = "http://targetrocksoftware.org")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from s
[WebService(Namespace = "http://targetrocksoftware.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class GetAssessmentResults : System.Web.Services.WebService
{
SchoolTestManagerDBContainer SchoolDB = new SchoolTestManagerDBContainer();
[WebMethod]
public XmlDocument GetAssessment(int assessmentid)
{
int intid = 88;
Assessment a = SchoolDB.Assessments.SingleOrDefault(m=>m.Id == (int) intid);
if (a != null)
{
MemoryStream ms = new MemoryStream();
Test t = Test.GetTestStructure(a);
t.SerializeTest(ms);
ms.Seek(0, SeekOrigin.Begin); //reset read pointer
XmlDocument xd = new XmlDocument();
xd.Load(ms);
return xd;
}
else
return null;
}
}
正如您所看到的,它非常简单,只需要一个参数,一个整数,它是表的唯一id。没有你会想到的问题。除了从SSRS调用web服务(通过ReportBuilder 2.0以本地模式调用)或直接从SSRS服务器调用web服务外,其他一切都可以正常工作,参数assessmentid始终为0
SSRS报告在数据集中使用以下查询参数调用web服务
GetAssessmentResponse/GetAssessmentResult/Test
{
NumQuestions(整数),
nAnswered(整数),
最高(浮动),
最低(浮动),
中位数(浮动),
平均值(浮动),
正确(整数),
不正确(整数),
KR20(浮动),
标准偏差(浮动),
差异(浮动)
}
http://targetrocksoftware.org/GetAssessment
88
除了assessmentid参数始终为0外,其他所有操作似乎都正常工作。如果我硬编码了一个我知道在数据库中的assessmentid(在本例中为88),那么web服务将返回正确的Xml文档,并且报告呈现得非常完美
但就我个人而言,我无法让SSR正确地传递参数。我使用fiddler2查看了下面复制的请求
发布
http://192.168.2.10/WebServices/GetAssessmentResults.asmxHTTP/1.1
SOAPAction:
http://targetrocksoftware.org/GetAssessment`内容类型:文本/xml
主机:192.168.2.10
内容长度:280
期望值:100继续
连接:保持活力
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAssessmet xmlns="http://targetrocksoftware.org">
<assessmentid>88</assessmentid>
</GetAssessmet>
</soap:Body>
</soap:Envelope>
88
`
如果我使用像soapUI这样的WebService测试工具向它工作的服务发送请求(例如,assessmentid是sest,即传递的值,88)。唯一不同的是,在从soapUI发送的请求上,传递的参数具有名称空间限定符。谁能帮帮我吗。下面包含一个netmon跟踪,它显示了两个请求之间的差异。我的基本问题是如何让SSR工作(例如,在soap请求的每个部分中包含名称空间(至少我认为这是错误的:))
-Soap:xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/“xmlns:tar=”http://targetrocksoftware.org/“
-信封:
+雄鹿:
+标题:
-正文:
+雄鹿:
-节点:xmlement:
+雄鹿:
-元素:XmlElement:-88
+雄鹿:
内容:88
+ETag:
+ETag:
+ETag:
+ETag:-Soap:xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/“xmlns:tar=”http://targetrocksoftware.org/“
-信封:
+雄鹿:
+标题:
-正文:
+雄鹿:
-节点:xmlement:
+雄鹿:
-元素:XmlElement:-88
+雄鹿:
内容:88
+ETag:
+ETag:
+ETag:
+ETag:
凯文如果有人感兴趣,我已经解决了这个问题。虽然不是很好,但问题已经解决了。解决方案是重新开始,用完全相同的功能重新创建一个新的Web服务。唯一的区别是,现在我将服务名称空间保留为默认名称空间。我不知道为什么它解决了这个问题,但它确实解决了。如果有人能解释一下,那就太好了 凯文