帮助将此 SOAP 请求转换为 XML 数据源的 Report Builder 2.0 查询
我的 .NET Web 服务中的 Web 方法有一个复杂的参数,我想使用 使用 SOAP 的报表生成器 2.0。使用 soapUI,我收到针对该 Web 方法的以下 SOAP 请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:qcr="MyNamespace">
<soapenv:Header/>
<soapenv:Body>
<qcr:MyWebMethod>
<qcr:MyComplexParameter><!--Represents a serializable class-->
<qcr:Action>?</qcr:Action><!--string-->
<qcr:ActionSortAscending>?</qcr:ActionSortAscending><!--Boolean-->
<qcr:ActionSortOrder>?</qcr:ActionSortOrder><!--int-->
</qcr:MyComplexParameter>
</qcr:MyWebMethod>
</soapenv:Body>
</soapenv:Envelope>
The only kind of Report Builder 2 query I之前使用过的 Web 方法采用字符串、整数或其他简单类型作为参数。我将如何编写 Report Builder 2 查询 这个 SOAP 请求?
使用简单参数的 Web 方法的示例 Report Builder 2 查询:
<Query>
<Method Name="MyWebMethod" Namespace="MyNamespace">
<Parameters>
<Parameter Name="MyStringParameter"><DefaultValue>foo</DefaultValue></Parameter>
<Parameter Name="MyNumericParameter"><DefaultValue>3</DefaultValue></Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="true">MyWebMethodResponse {}/MyWebMethodResult {}/Result</ElementPath>
</Query>
I have a complex parameter to a web method in my .NET web service, and I want to query that web method with Report Builder 2.0 using SOAP. With soapUI, I get the following SOAP request for that web method:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:qcr="MyNamespace">
<soapenv:Header/>
<soapenv:Body>
<qcr:MyWebMethod>
<qcr:MyComplexParameter><!--Represents a serializable class-->
<qcr:Action>?</qcr:Action><!--string-->
<qcr:ActionSortAscending>?</qcr:ActionSortAscending><!--Boolean-->
<qcr:ActionSortOrder>?</qcr:ActionSortOrder><!--int-->
</qcr:MyComplexParameter>
</qcr:MyWebMethod>
</soapenv:Body>
</soapenv:Envelope>
The only kind of Report Builder 2 queries I've worked with before were for web methods that took strings, integers, or other simple types as parameters. How would I go about writing a Report Builder 2 query for this SOAP request?
Sample Report Builder 2 query for web method with simple parameters:
<Query>
<Method Name="MyWebMethod" Namespace="MyNamespace">
<Parameters>
<Parameter Name="MyStringParameter"><DefaultValue>foo</DefaultValue></Parameter>
<Parameter Name="MyNumericParameter"><DefaultValue>3</DefaultValue></Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="true">MyWebMethodResponse {}/MyWebMethodResult {}/Result</ElementPath>
</Query>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想到的最好办法是更改 Web 服务的 Web 方法,使其只需要简单的参数,然后找到某种方法来表示字符串中的复杂对象并在 Web 方法中解析该对象。键值对和正则表达式、JSON 字符串等。如果我无法控制 Web 服务的代码,这将不起作用,而且看起来确实应该有一种方法从 Report 传递任何类型的可序列化参数XML Web 服务的构建器。如果我可以在正常的 SOAP 请求中传递参数,那么我应该能够通过报表生成器的愚蠢的
Query
语法传递该参数。如果它对其他人有帮助,为了解析格式为
key1=value1,key2=value2
的逗号分隔键值对,我使用了new Regex(@"([^=,]* )=(""[^""]*""|[^,""]*)")
和paramStr.Split(',').Select(pair =>pair.Split ('=')).ToDictionary(pair =>pair[0],pair =>pair[1])
获取参数的IDictionary
我的 C# Web 服务。The best I came up with was to change the web service's web method so it only takes simple parameters, then find some way of representing the complex object in a string and parsing that in the web method. Key-value pairs and regex, JSON strings, etc. This wouldn't work if I didn't have control over the web service's code, and it really seems like there ought to be a way of passing any kind of serializable parameter from Report Builder to an XML web service. If I can pass a parameter in a normal SOAP request, I should be able to pass the parameter via Report Builder's stupid
Query
syntax.If it helps anyone else, for parsing comma-separated key-value pairs of the format
key1=value1,key2=value2
, I usednew Regex(@"([^=,]*)=(""[^""]*""|[^,""]*)")
andparamStr.Split(',').Select(pair => pair.Split('=')).ToDictionary(pair => pair[0], pair => pair[1])
to get anIDictionary<string, string>
of parameters in my C# web service.