doushishi2415 2012-09-02 09:46 采纳率: 0%
浏览 45

使用类似JSON的参数从.NET调用PHP webservice

I'm trying to consume a php webservice from .NET. In PHP the call would be something like this:

// array with guest information
$extrainfo = array(
            'voorletters'               => 'T.e.s.t.',
            'voornaam'                  => '',
            'tussenvoegsels'            => '',
            'achternaam'                => 'Baker',
            'rekeningnummer'            => '123456789',
            'website'                   => 'www.bla.nl',
            'geboortedatum'             => '19-2-1985',
            'telefoon_extra_restnummer' => '',
            'straat'                    => '',
            'huisnummer'                => '',
            'huisnummer_toevoeging'     => '',
            'postcode'                  => '',
            'woonplaats'                => '',
);
// add guest
$result = $client_cart->setGuest('MySessionID', 'test@test.nl',$extrainfo);

If I generate a proxy in Microsoft .NET using the wsdl, the 'setGuest' operation takes three parameters as expected. A string (sessionID), a string (mail address) and a parameter of type 'object' (extra info).

I've tried to create a custom class to pass the extra info from .NET, create an instance, populate it and pass the it as a serialized object but then the PHP webservice complains that it expects an array in stead of an object. I've also tried to pass the guest information as a Dictionary:

  Dictionary<string, string> dict = new Dictionary<string, string>();
  dict.Add("voorletters", "T.e.s.t.");
  dict.Add("voornaam", "");
  dict.Add("tussenvoegsels", "");
  dict.Add("achternaam", "Baker");
  ...

  object obj = _proxyService.setGuest("MySessionID", "test@test.nl", dict.ToArray());

But then the PHP web service complains that no extra information is received.

So my question is; how do I pass the guest information as a parameter using the proxy that is generated in .NET?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改