簡體   English   中英

帶參數和類型的soap客戶端調用函數

[英]soap client calling function with parameters and type

我對身體有肥皂要求

<soap:Body>
    <ProcessRequest>
        <request xsi:type="GetNotification">
            <node1>val1</node2>
            <node2>val2</node2>
        </request>
    </ProcessRequest>
</soap:Body>

我試圖在 PHP 的soap客戶端調用中傳遞請求類型GetNotification ,但它不起作用。 在 $args 我經過

$args = ['node1' => 'val1','node2'=>'node2'];
$response = $client->ProcessRequest(['request'=>$args])

我如何傳遞類型GetNotification

您可以使用此工具:

https://github.com/wsdl2phpgenerator/wsdl2phpgenerator

你可以給它soap url,它會為服務生成完整的類列表。 使用這些類將更容易理解您需要向您發送請求的內容和方式。

我認為這應該是這樣的。 因為 xsi:type 指示請求值應該是 GetNotification。 請記住,我沒有測試它,這只是一個想法。

<?php 

//using arrays
$response = $client->ProcessRequest(['request' => [
    'GetNotification' => ['node1' => 'val1', 'node2' => 'val2']
]);

//using objects
class request 
{
    private $GetNotification;

    public function __construct(GetNotification $getNotification) 
    {
         $this->GetNotification = $getNotification;
    }
}

class GetNotification
{
    private $node1;
    private $node2;

    public function __construct(string $node1, string $node2) 
    {
         $this->node1 = $node1;
         $this->node2 = $node2;
    }
}

$response = $client->ProcessRequest(
    new request(new GetNotification('val1', 'val2'))
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM