我从邮件服务器上发了一些电子邮件.有一个函数应该拉这些电子邮件并返回一个多维数组.我在客户端Web服务器中使用此数组来为我完成这项工作.我不知道如何将此数组传递给soap complexType.我写了以下代码:
$server->wsdl->addComplexType(
'MailTicket','complexType','struct','all','',array(
'attachment' => array('name' => 'attachment','type' => 'xsd:string'),'body' => array('name' => 'body','accountID' => array('name' => 'accountID','type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'MailTicketReturn',array(
'Done' => array('name' => 'result','type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('createMailTicket',// method name
array('mailTicketData' => 'tns:MailTicket'),// input parameters
array('return' => 'tns:MailTicketReturn'),// output parameters
'urn:eticketing',// namespace
'urn:eticketing#createMailTicket',// soapaction
'rpc',// style
'encoded',// use
'create a ticket by mail' // documentation
);
在客户端,我写道:
require_once('nusoap.PHP');
$wsdlURL="http://127.0.0.1/eticket/ETKWS.PHP?wsdl";
$client = new nusoap_client($wsdlURL,true);
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$finalArray=Array
(
[attachment] => Array
(
[0] => Array
(
[0] => file1
[1] => file2
)
[1] => Array
(
[0] => file1x
)
)
[body]=>Array
(
[0] => some text
[1] => some other text
)
[accountID] => Array
(
[0] => 5464654
[1] => 4654664
)
)
if(is_array($finalArray)) // creat new tickets
{
$result=$client->call('createMailTicket',$finalArray);
}
$err = $client->getError();
if ($err) {
echo '
Constructor error
' . $err . '';
echo '
Debug
' . htmlspecialchars($client->getDebug(),ENT_QUOTES) . '';
exit();
}
我收到了这个错误:
在第1行解析SOAP有效负载的XML错误:格式不正确(无效令牌)