xml datasource for reporting services
help pls - pulling hair out on this one am doing proof-of-concept for reporting services reports getting data via web services. got it working for simple examples (passing back strings etc) also woking passing back an object but cant get it working with a dataset - am having trouble filtering out the XML resultset this is my webmethod [WebMethod] public DataSet DSetExample() { DataSet ds = new DataSet("XMLTest"); DataTable dt = new DataTable(); DataColumn dc; dc = new DataColumn("IntegerColumn1", System.Type.GetType("System.Int32")); dt.Columns.Add(dc); dc = new DataColumn("StringColumn1", System.Type.GetType("System.String")); dt.Columns.Add(dc); dc = new DataColumn("DecimalColumn1", System.Type.GetType("System.Decimal")); dt.Columns.Add(dc); dc = new DataColumn("DateTimeColumn1", System.Type.GetType("System.DateTime")); dt.Columns.Add(dc); DataRow drow = dt.NewRow(); drow["IntegerColumn1"] = 1; drow["StringColumn1"] = "WTF"; drow["DecimalColumn1"] = 205.299; drow["DateTimeColumn1"] = DateTime.Parse("22/May/1966"); dt.Rows.Add(drow); ds.Tables.Add(dt); return ds; } this is my basic query <Query> <ElementPath IgnoreNamespaces="true">* </ElementPath> <Method Name="DSetExample" Namespace="http://localhost/testservice1"> </Method></Query> this just gives me the first node details but when ever i try and specify the elements i want by using the ElementPath nothing comes back.... just need to know how to specfiy the ELEMENTPATH to return the dataset details... thx
March 15th, 2008 1:13pm

Hi, markse,I am working with reporting services lately and I think I can help you (but I have some problems which I 'll tell about later).The very first thing - do not confuse the namespace with the address of your web service (I guess http://localhost/testservice1 is the address of your service, the namespace is located at the beginning of your web service code, it looks like: [WebService(Namespace = "http://tempuri.org/")]At first, I suggest you to get some free SOAP monitoring tool (I use SOAPUI, really helpful) and try to call webservice directly. Then you will see, what answer you get and how it looks like in XML.Modify your webmethod a little:<!--[if !supportLineBreakNewLine]--><!--[endif]--> [WebMethod] public DataSet DSetExample() { // this will dump the received request to a text file // so you can see what your report is sending to your // webservice Context.Request.SaveAs("C:\\req.txt", true); // the rest of your code.... When I did the same I noticed two problems: after publishing my webservice (which is similar to yours) and inspecting it in a web browser I got the following:<!--[if !supportLineBreakNewLine]--><!--[endif]--> POST /WSBS/DBService.asmx HTTP/1.1Host: localhostContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://progmars.org/GetData"<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetData xmlns="http://progmars.org/" /> </soap:Body></soap:Envelope> see the / at the end of the namespace of the method GetData? I think this was a problem in my case and it may be in yours too, so be aware. Because when I sent the following request:<Query><Method Name="GetData" Namespace="http://progmars.org"></Method><ElementPath IgnoreNamespaces="true">*</ElementPath></Query> the service receives:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetData xmlns="http://progmars.org" /> </soap:Body></soap:Envelope><!--[if !supportLineBreakNewLine]--><!--[endif]--> no slash at the end. So to overcome the problem you need to be precise and make your query like this:<!--[if !supportLineBreakNewLine]--><!--[endif]--> <Query><SoapAction>http://progmars.org/GetData</SoapAction><Method Name="GetData" Namespace="http://progmars.org/"></Method><ElementPath IgnoreNamespaces="true">*</ElementPath></Query> for some reasons if you just add the slash at the Namespace= and do not use <SoapAction>, Visual Studio gives an error. So I stick to <SoapAction> for every case, this just narrows the possibility for misunderstandings.For me such a query works fine BUT: if the data returned by your web service misses some fileds (XML serializer may drop out the fields with empty strings and so on) then you should add the manually to the fields list and drop to your report to avoid errors with missing fields. I guess, you missed all the fields in your case because of namespace problems, so there were no useful data at all. If you modify your query, the field list may get regenerated and may miss some fields again! That makes all this wbeservice datasource thing a bit tricky. The best is just make sure that at least one of your records has all the fields filled in when you execute your query for the first time (there is also Refresh Fields button which forces regenerating the field list, but it does not change your report, so if you missed some fields at the beginnig, you may need to add them manually to the report view). All gets even more tricky if you want to pass parameters to your webservice, but after some thinking and reading tutorials everything works nicely: <Query> <SoapAction>http://progmars.org/GetDocumentsByPersId</SoapAction> <Method Name="GetDocumentsByPersId" Namespace="http://progmars.org/"> <Parameters> <Parameter Name="persid"> <DefaultValue>0</DefaultValue> </Parameter> </Parameters> </Method> <ElementPath IgnoreNamespaces="true">*</ElementPath> </Query> And now this is the place where _I_ have trouble: I have a webservice which expects to receive some XML data as a parameter, but I have no idea, how to pass XML. Because if I use : <Parameter Name="myXMLData"> <DefaultValue> <Id>10</Id> <Field>a</Field> </DefaultValue> my webservice tells me that it received <myXMLData> &lt;Id&gt;10&lt;/Id&gt;&lt;Field&gt;a&lt;/Field&gt; </myXMLData> as you see, Microsoft is right about it: "Query parameters of type Msxml2.DOMDocument30 are passed as XML. Parameters of type String which happen to contain XML are passed as strings and are XML encoded in the SOAP message. The function CXml(String) converts a string into an Msxml2.DOMDocument30 and can be used in query parameter expressions." I tried: <Parameter Name="myXMLData" Type="Xml"> <DefaultValue> <Id>10</Id> <Field>a</Field> </DefaultValue> no results, the same problem. And I cannot find this CXml(String) in the Expression Builder. So, please, can someone help me, too? Anyway, if someone has something to say about everything I wrote here (I am just a beginner so I may be wrong), I will be really grateful.
Free Windows Admin Tool Kit Click here and download it now
March 16th, 2008 3:49pm

Can it really be so that no one knows how to send XML parameters to a webservice?
March 17th, 2008 12:21pm

bumpAt least - is there any way to save XML data as a parameter string without having SSRS converting those < and > to &lt; &gt:?Uff, it looks like I'll have to make a proxy web service which takes simple string, int parameters and wraps them into a XML document and passes them further to the "real" web service. Really dirty way, but it seems no one can suggest anything better...
Free Windows Admin Tool Kit Click here and download it now
March 28th, 2008 2:50pm

You can try passing the same name of the parameter in the query as a parameter to the webmethod in the webservice, this should work.
September 23rd, 2010 10:07am

Youi_2032, can please describe this in a little bit more details? I'm trying to build a report on an existing system and it has a searchParameters node with searchParameter subnodes inside.
Free Windows Admin Tool Kit Click here and download it now
December 27th, 2010 11:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics