[英]PHP array to C# List
After submitting a form in my PHP application I store some values in an array like this 在PHP应用程序中提交表单后,我将一些值存储在这样的数组中
if(isset($_POST['submitArticle']))
{
$artikel = $_POST['article'];
$aantal = $_POST['quantity'];
$a=0;
$art = array();
$quan = array();
foreach($artikel as $key => $value)
{
$art[] = $artikel[$a];
$quan[] = $aantal[$a];
$a++;
}
$artikelArguments = array_combine($art, $quan);
Now I call a method in my C# application with my new array as an argument: 现在,我使用新数组作为参数在C#应用程序中调用一个方法:
$client->getArticle($artikelArguments);
My method in C# looks something like this: 我在C#中的方法如下所示:
public List<string> getArticle(List<KeyValuePair<int, int>> articles)
{
//Get articles based on ID
foreach (KeyValuePair<int, int> art in articles)
{
Now articles is always null, so the values won't get passed, or C# can't handle my PHP array. 现在article始终为null,因此不会传递值,否则C#无法处理我的PHP数组。 Does someone have any suggestions?
有人有什么建议吗?
Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault]
I saw that this didnt get a proper answer. 我看到这没有得到正确的答案。 For this issue I used objects instead of integers and then it worked fine.
对于这个问题,我使用对象而不是整数,然后工作正常。
This is not answering directly your question, but whenever I have to make soap calls from php, I use a proxy generator, such as the one you can find there , developped by Przemek Berezowski. 这不是直接回答你的问题,但每当我不得不作出从PHP SOAP调用,我使用代理发生器,如一个你可以找到那里 ,由Przemek Berezowski developped。 It'll handle soap type conversion for you
它将为您处理肥皂类型转换
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.