Kev*_*nig 5 reporting-services
我有一个使用C#和Visual Studio 2010创建的Web服务.定义如下.
[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;
}
}
Run Code Online (Sandbox Code Playgroud)
它很简单,你可以看到它需要一个参数一个整数,它是一个表的唯一id.你不会想到任何问题.除了当我通过SSRS(通过ReportBuilder 2.0在本地模式下)或直接从SSRS服务器调用Web服务时,everthing工作,参数assessmentid始终为0.
SSRS报告使用数据集中的以下查询参数调用Web服务.
<Query xmlns="http://targetrocksoftware.org">
http://targetrocksoftware.org/GetAssessment
<ElementPath IgnoreNamespaces="True">
GetAssessmentResponse/GetAssessmentResult/Test
{
NumQuestions(integer),
nAnswered(integer),
Highest(float),
Lowest(float),
Median(float),
Mean(float),
Correct(integer),
Incorrect(integer),
KR20(float),
StandardDeviation(float),
Variance(float)
}
</ElementPath>
<SoapAction></SoapAction>
<Method Namespace="http://targetrocksoftware.org" Name="GetAssessmet">
<Parameters>
<Parameter Name="assessmentid">
<DefaultValue>88</DefaultValue>
</Parameter>
</Parameters>
</Method>
</Query>
除了evaluatementid参数始终为0之外,其他任何工作似乎都有效.如果我硬编码我知道在db中的评估(在本例中为88),Web服务将返回正确的Xml文档,并且报表呈现完美.
但是对于我的生活,我无法让SSRS正确传递参数.我使用fiddler2来查看下面复制的请求
POST
http://192.168.2.10/WebServices/GetAssessmentResults.asmx http:// targetrocksoftware.org/GetAssessment`
内容类型:text/xml
主机:192.168.2.10
内容长度:280
期望:100-continue
连接:Keep-Alive HTTP/1.1
SOAPAction:
<?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>
Run Code Online (Sandbox Code Playgroud)
`
如果我使用像soapUI这样的WebService测试工具向服务发送请求(例如,评估结果是传递的值,88).我能看到的唯一不同的是,在soapUI发送的请求中,传递的参数具有名称空间限定符.Cany有人帮我请.下面包含一个netmon跟踪,它显示了两个请求之间的差异.我的基本问题是你如何让ssrs工作(例如在soap请求的每个部分包含名称空间(至少这是我认为是错误的:))
- Soap: xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/"
- Envelope: <soapenv:Envelope>
+ STag: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/">
+ Header: <soapenv:Header>
- Body: <soapenv:Body>
+ STag: <soapenv:Body>
- Node: XmlElement:<tar:GetAssessment>
+ STag: <tar:GetAssessment>
- Element: XmlElement:<tar:assessmentid> - 88
+ STag: <tar:assessmentid>
Content: 88
+ ETag: </tar:assessmentid>
+ ETag: </tar:GetAssessment>
+ ETag: </soapenv:Body>
+ ETag: </soapenv:Envelope>- Soap: xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/"
- Envelope: <soapenv:Envelope>
+ STag: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/">
+ Header: <soapenv:Header>
- Body: <soapenv:Body>
+ STag: <soapenv:Body>
- Node: XmlElement:<tar:GetAssessment>
+ STag: <tar:GetAssessment>
- Element: XmlElement:<tar:assessmentid> - 88
+ STag: <tar:assessmentid>
Content: 88
+ ETag: </tar:assessmentid>
+ ETag: </tar:GetAssessment>
+ ETag: </soapenv:Body>
+ ETag: </soapenv:Envelope>
凯文
如果有人感兴趣,我已经解决了这个问题。虽然不是很好的办法,但是已经解决了。解决方案是重新开始并重新创建具有完全相同功能的新 Web 服务。唯一的区别是,现在我将服务命名空间保留为默认的http://tempuri.org。我不确定为什么它解决了这个问题,但它确实解决了。如果有人能解释一下那就太好了
凯文