2016-05-18 7 views
0

を追加し、電子メールアドレスを追加する必要があり、これは必要な形式です:PHPのSOAPクライアントは、SOAPサーバに要求を実行しようとした情報

  <EmailAddresses> 
     <Home xsi:nil="true" /> 
     <Invoice xsi:nil="true" /> 
     <Primary xsi:nil="true" /> 
     <Work xsi:nil="true" /> 
     <Alternative xsi:nil="true" /> 
     </EmailAddresses> 
      <PhoneNumbers> 
     <Home xsi:nil="true" /> 
     <Fax xsi:nil="true" /> 
     <Mobile xsi:nil="true" /> 
     <Primary xsi:nil="true" /> 
     <Work xsi:nil="true" /> 
     </PhoneNumbers> 

私は、パラメータを作成するためのコードのこの部分を持っている:

$username = "www; 
$password = "ddd"; 
$applicationid = "ggg"; 
$options = array('trace' => true); 
$params ["credential"]["Username"] = $username; 
$encodedPassword = md5(mb_convert_encoding($password, 'utf-16le', 'utf-8')); 
$params ["credential"]["Password"] = $encodedPassword; 
$params ["credential"]["ApplicationId"] = $applicationid; 
$params ["credential"]["IdentityId"] = "xxx"; 

try { 
$authentication = new SoapClient("https://api.24sevenoffice.com/authenticate/v001/authenticate.asmx?wsdl", $options); 
$login = true; 
if (!empty($_SESSION['ASP.NET_SessionId'])) { 
    $authentication->__setCookie("ASP.NET_SessionId",  $_SESSION['ASP.NET_SessionId']); 
    try { 
     $login = !($authentication->HasSession()->HasSessionResult); 
    } catch (SoapFault $fault) { 
     $login = true; 
    } 
    } 
    if ($login) { 
    $result = ($temp = $authentication->Login($params)); 
    $_SESSION['ASP.NET_SessionId'] = $result->LoginResult; 
    $authentication->__setCookie("ASP.NET_SessionId", $_SESSION['ASP.NET_SessionId']); 
    // throw an error if the login is unsuccessful 
    if ($authentication->HasSession()->HasSessionResult == false) 
     throw new SoapFault("0", "Invalid credential information."); 
    } 

$superService = new SoapClient("https://api.24sevenoffice.com/CRM/Company/V001/CompanyService.asmx?wsdl", $options); 
$superService->__setCookie("ASP.NET_SessionId", $_SESSION['ASP.NET_SessionId']);  

$datosCompania = array("Type" => "Business", 
        "Name" => "Trying with all parameters again 4", 
        "Address" => "Libertad 1320, Vicente Lopez, Buenos Aires, Argentina", 
        "PhoneNumbers" => array("Primary" =>"41771296","Work"=>"47910936","Home"=>"47955678"), 
        "EmailAddresses" => array("Primary" =>"[email protected]"), 
        "OrganizationNumber" => "987987654"); 

    $result = $superService->SaveCompanies(array("companies" =>array("Company"=>$datosCompania))); 

} catch (SoapFault $fault) { 
echo 'Exception: ' . $fault->getMessage(); 
} 
echo "<pre>"; 
print_r($result); 

そして、これは私が得る応答である:私は要求を実行すると、私はOKメッセージを取得

stdClass Object 
(
[SaveCompaniesResult] => stdClass Object 
    (
     [Company] => stdClass Object 
      (
       [Id] => 90036 
       [OrganizationNumber] => 987987654 
       [Name] => Trying with all parameters again 4 
       [PhoneNumbers] => stdClass Object 
        (
         [Home] => stdClass Object 
          (
          ) 

         [Primary] => stdClass Object 
          (
          ) 

         [Work] => stdClass Object 
          (
          ) 

        ) 

       [EmailAddresses] => stdClass Object 
        (
         [Primary] => stdClass Object 
          (
          ) 

        ) 

       [Type] => Business 
      ) 

    ) 

) 

、どちらも電子メールアドレスまたは電話番号が格納されている場合は、私が間違っていることについて私を助けることができますか?

Link to the soap structure

+0

を追加するためのラインであります今。 –

+0

ユージーン、すべてのコードは今質問に、ありがとう –

答えて

0

最終的に私はそれを行う方法を見つけ、これはあなたが全体の要求コード、サーバコード、のて送信を取得したメッセージ、すなわち、より多くの情報を持ち出す必要がある電子メール

"EmailAddresses" => array("Work" => array("Description" => "this is test","Name" =>"name", "Value" => "[email protected]")), 
関連する問題