如何通过名称/值对到ASMX Web方法? [英] How to Pass Name/Value Pairs to an ASMX Web Method?

查看:174
本文介绍了如何通过名称/值对到ASMX Web方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个web服务,基本上远程数据库某些数据库调用(让他们发生了HTTP,而不是默认的1433 SQL Server的端口)。

I am creating a webservice that essentially remotes some database calls (so that they happen over HTTP rather than the default SQL Server port of 1433).

从本质上讲就是我一直在努力做的是通过一些参数上的ASMX WebService的一个WebMethod。参数如下:

Essentially what I have been trying to do is pass a number of parameters to a WebMethod on an ASMX WebService. The parameters are:


  • 表示
    查询ID被执行的字符串。

  • 表示
    表的结构,该信息应该是
    填充到数据表


  • 参数(即名称值对)
    字典由$ b $表示上面的b的ID来获得预期的
    结果的查询运行。

  • 一个布尔值是
    不重要了这个问题

  • A string representing the ID of the query to be execute.
  • A DataTable representing the structure of the table that the information should be filled into.
  • A dictionary of parameters (i.e. name value pairs) to be run with the query represented by the ID above to get the expected results.
  • A boolean which is unimportant to this question

现在的问题,我我有是,对于ID字符串,数据表和布尔都通过就好了过来,但字典没有。我知道,在默认情况下,任何实施的IDictionary不XMLSerializing的支持,所以我转换的字典成两个对象数组,一个键,一个用于值。

Now the problem I am having is that the string for the ID, the DataTable and the boolean are all coming through just fine, but the Dictionary does not. I know that by default, anything implementing IDictionary is not supported by XMLSerializing, so I have converted the dictionary into two object arrays, one for the keys, and one for the values.

我正在从客户端发送通过似乎是正确的。该SOAP数据包包含键数组和值的数组都正确的值。

What I'm sending through from the Client appears to be correct. The SOAP packet contains the correct values for both the keys array and the values array.

我收到的WebService的到底是什么(我可以在突破的WebMethod,因为它被称为)为null同时为阵列。不是空数组,只是空。

What I'm receiving on the WebService end (I can break in the WebMethod as it is called) is null for both of the arrays. Not an empty array, just null.

我已经尝试了很多事情,才能传达给web服务(编码的SerializableDictionary得到这些参数,试图堵塞的关键/值对到一个数据表,试图简单地用两个字符串数组,然后投结果返回到正确类型的WebService的结束),但我绝对没有任何运气

I have tried a lot of things in order to get these parameters across to the webservice (coded a SerializableDictionary, attempted to jam the key/value pairs into a data table, attempted to simply use two string arrays and then cast the results back into the correct types on the WebService end) but I've had absolutely no luck whatsoever.

有谁知道一个好办法,成功地发送名称 - 值对,其中名称是一个字符串,值几乎可以是任何对象类型,但永远是一个序列化对象到WebService的WebMethod,这样它们名称 - 值正确对服务端进行解释。

Does anyone know a good way to successfully send Name-Value pairs where Name is a string, and Value can be almost any object type, but will always be a serializable object to a WebService WebMethod, such that they Name-Values are correctly interpreted on the service side.

推荐答案

我不整肯定什么问题(也可能是我自己的
愚蠢的),但我从头开始一遍,并用2个数组实现的
液(键(字符串)之一,其中一个对象
(值))和它的工作如预期。

I'm not entire sure what the problem was (it may have been my own stupidity) but I started from scratch again, and implemented the solution with 2 arrays (one of keys (strings) and one of objects (values)) and it worked as expected.

这篇关于如何通过名称/值对到ASMX Web方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆