因此,我将数组项的字段传递给Web服务调用,并且请求和响应看起来还可以,但是我试图获取Value属性来告知类型,所以这是我的字段:
$fields = array(
"Password"=>'password',
"entity"=>array(
"Name" =>"namehere",
"Id"=>'1234',
"Attributes"=>
array(
array(
"AttributeType"=>'SingleLineOfText',
"Key"=>'Key1',
"Value"=>'1',
),
array(
"AttributeType"=>'SingleLineOfText',
"Key"=>'Key2',
"Value"=>'2',
),
array(
"AttributeType"=>'DateAndTime',
"Key"=>'Key3',
"Value"=>'2016-09-16T00:00:00'
)
)
)
);
所以我的要求是:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:Create>
<ns1:Password>password</ns1:Password><ns1:entity>
<ns1:Name>namehere</ns1:Name><ns1:Id>1234</ns1:Id><ns1:Attributes><ns1:Attribute>
<ns1:AttributeType>SingleLineOfText</ns1:AttributeType>
<ns1:Key>Key1</ns1:Key><ns1:Value>1</ns1:Value>
</ns1:Attribute><ns1:Attribute>
<ns1:AttributeType>SingleLineOfText</ns1:AttributeType>
<ns1:Key>Key2</ns1:Key><ns1:Value>2</ns1:Value>
</ns1:Attribute><ns1:Attribute>
<ns1:AttributeType>DateAndTime</ns1:AttributeType>
<ns1:Key>Key3</ns1:Key><ns1:Value>2016-09-16T00:00:00</ns1:Value></ns1:Attribute></ns1:Attributes></ns1:entity>
</ns1:Create></SOAP-ENV:Body></SOAP-ENV:Envelope>
因此您可以看到
foreach($fields['entity']['Attributes'] as $attribute){
echo $attribute['Value'] = new SoapVar($attribute, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
}