1

我正在使用一个 SOAP 应用程序,它要求一些 GUID 类型的参数。我不确定这一切意味着什么。

我发现这是在 PHP 中制作 GUID 的:

function getGUID(){
    if (function_exists('com_create_guid')){
        return com_create_guid();
    } else {
        mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $hyphen = chr(45);// "-"
        $uuid = chr(123)// "{"
            .substr($charid, 0, 8).$hyphen
            .substr($charid, 8, 4).$hyphen
            .substr($charid,12, 4).$hyphen
            .substr($charid,16, 4).$hyphen
            .substr($charid,20,12)
            .chr(125);// "}"
        return $uuid;
    }
}

但是当我尝试传入参数时,我不知道这是如何工作的。这是我需要如何使用它的示例:

$option=array('trace'=>1);
$url = "http://example.com/admin.asmx?WSDL";
$client = new SoapClient($url, $option);
$params = array(
    'consumerid'   => '1234',
    'userName'     => '1234',
    'password'     => '1234',
    'adminDomain'  => 'admin.example.com',
    'SubscriberID' => '1234',
    'orderID'      => '22147'); /* <- This value needs to be of the type GUID */

$result = $client->getOrderDetail($params);

我可以创建新的 GUID,但我不知道如何将值与之关联。有人可以提供解释吗?

4

1 回答 1

0

Did you mean:

$option=array('trace'=>1);
$url = "http://example.com/admin.asmx?WSDL";
$client = new SoapClient($url, $option);

# get guid and store in variable
$guid = getGUID();

$params = array(
    'consumerid'   => '1234',
    'userName'     => '1234',
    'password'     => '1234',
    'adminDomain'  => 'admin.example.com',
    'SubscriberID' => '1234',
    'orderID'      => $guid); # now use that guid here

$result = $client->getOrderDetail($params);
于 2012-06-29T19:01:08.940 回答