2011-11-03 47 views
-2

我有c#示例如何使用某些web服務。如何將這段代碼放到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 accpount Informa公司)

我添加CLASSE,但還是不行。有什麼不對這個代碼

$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; 
} 
+2

這不是「請將我的代碼轉換爲我」網站。顯示你在PHP中寫這個的嘗試,我們可以評論/幫助。但否則這歸結爲「給我codez」 –

回答

1

假設你有使用相同的類在你的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應用程序。

+0

這只是一個文件, – Nikola