【发布时间】:2017-09-28 20:48:10
【问题描述】:
我尝试在 c# 服务器和 php 客户端之间使用 web 服务。
当我使用不带参数的网络服务时,一切正常!
但是当我想将参数传递给函数时,我遇到了这个错误: SoapFault : Le format de la chaîne d'entrée est 不正确
我的 wsdl 文件: https://pastebin.com/ti805zkW
我的php代码:
public function previewAction(Request $req)
{
$client = new \SoapClient("http://localhost:1664/WebReport/Service/?wsdl");
$preview = $client->Preview(array('id' => 1, 'choice' => 2, 'userDate' => 'test'));
return new JsonResponse($preview);
}
我的 c# Iservice 代码:
using System.Collections.Generic;
using System.ServiceModel;
namespace WebReport
{
[ServiceContract]
public interface IService
{
[OperationContract]
bool Reload();
[OperationContract]
bool Treatment();
[OperationContract]
Dictionary<string, float> Preview(int id, int choice, string userDate);
}
}
我的 c# 服务代码:
using System;
using System.Collections.Generic;
namespace WebReport
{
public class Service : IService
{
public bool Reload()
{
//Application.GetInstance().ReloadConfig();
return true;
}
public bool Treatment()
{
//DataPoints.Treatment.GetInstance().run();
return true;
}
public Dictionary<string, float> Preview(int id, int choice, string userDate)
{
Console.WriteLine("{ 0}.{ 1}.{ 2}", id, choice, userDate);
Dictionary<string, float> test = new Dictionary<string, float>();
test.Add("2017-05-04 10:10:10", 100000);
test.Add("2017-05-05 10:10:10", 100001);
return test;
}
}
}
我已经测试使用 wsdl2phpgenerator 从 wsdl 文件中提取 php 类,但同样的错误。
有什么想法吗?
【问题讨论】:
标签: c# php web-services soap wsdl