将web服务客户端从c#转换为php


convert web service client from c# to php

我有c#的例子如何使用一些web服务。如何在PHP中查看这些代码?

PartnerAPI papi = new PartnerAPI();
ApiReqHeader arh = new ApiReqHeader();
arh.clientId = "99992222";
LoginAuthenticationInfo lai = new LoginAuthenticationInfo();
lai.login = "login";
lai.pwd = "password";
ServiceAccountInfo sai = new ServiceAccountInfo();
sai.Serviceaccount = "1234567890";
GetChildAccountInfoBySearchCriteriaRequest child = new GetChildAccountInfoBySearchCriteriaRequest();
child.serviceAccountInfo = sai; // customerInfo = customer;
child.reqHeader = arh;
child.loginAuthenticationInfo = lai;

GetChildAccountInfoBySearchCriteriaResponse resp = papi.GetChildAccountInfoBySearchCriteria(child);

这只是一个文件(只有这个代码,需要得到onlu帐户信息)

我添加类,但仍然不工作。这段代码有什么问题

 $papi = new SoapClient($url,
                    array(
                      "trace"      => 1,        // enable trace to view what is happening
                      "exceptions" => 0,        // disable exceptions
                      "cache_wsdl" => 0)        // disable any caching on the wsdl, encase you alter the wsdl server
 );
$arh = new ApiReqHeader();
$arh->client_id = "99992222";
$lai = new LoginAuthenticationInfo();
$lai->login = "login";
$lai->pwd = "password";
$sai = new ServiceAccountInfo();
$sai->Serviceaccount = "1234567890";
$child = new GetChildAccountInfoBySearchCriteriaRequest();
$child->serviceAccountInfo = $sai; // customerInfo = customer;
$child->reqHeader = $arh;
$child->loginAuthenticationInfo = $lai;

$resp = $papi->GetChildAccountInfoBySearchCriteria($child);
echo $resp;

class ApiReqHeader{
    public  $clientId;
}

假设PHP文件中使用了相同的类,并且包含了所需的文件,下面的语法很可能是:

<?php
    $papi = new PartnerAPI();
    $arh = new ApiReqHeader();
    $arh->client_id = "99992222";
    $lai = new LoginAuthenticationInfo();
    $lai->login = "login";
    $lai->pwd = "password";
    $sai = new ServiceAccountInfo();
    $sai->Serviceaccount = "1234567890";
    $child = new GetChildAccountInfoBySearchCriteriaRequest();
    $child->serviceAccountInfo = $sai; // customerInfo = customer;
    $child->reqHeader = $arh;
    $child->loginAuthenticationInfo = $lai;

    $resp = $papi->GetChildAccountInfoBySearchCriteria($child);
?>

显然,除非您在PHP应用程序中使用相同的文件,否则这不会神奇地工作。