在PHP中将多维数组传递给soap complexType
我正在从邮件服务器中提取一些电子邮件。有一个函数可以提取这些电子邮件并返回多维数组。我在客户机web服务器中使用这个数组来完成这项工作。我不知道如何将此数组传递给soap complexType。我编写了以下代码:在PHP中将多维数组传递给soap complexType,php,soap,multidimensional-array,complextype,Php,Soap,Multidimensional Array,Complextype,我正在从邮件服务器中提取一些电子邮件。有一个函数可以提取这些电子邮件并返回多维数组。我在客户机web服务器中使用这个数组来完成这项工作。我不知道如何将此数组传递给soap complexType。我编写了以下代码: $server->wsdl->addComplexType( 'MailTicket', 'complexType', 'struct', 'all', '', array( 'attachment' => array('name' => 'atta
$server->wsdl->addComplexType(
'MailTicket',
'complexType',
'struct',
'all',
'',
array(
'attachment' => array('name' => 'attachment', 'type' => 'xsd:string'),
'body' => array('name' => 'body', 'type' => 'xsd:string'),
'accountID' => array('name' => 'accountID', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'MailTicketReturn',
'complexType',
'struct',
'all',
'',
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 '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
require_once('nusoap.php');
$wsdlURL=”http://127.0.0.1/eticket/ETKWS.php?wsdl";
$client=新的nusoap_客户端($wsdlURL,true);
$client->soap_defencoding='UTF-8';
$client->decode_utf8=false;
$finalArray=数组
(
[附件]=>阵列
(
[0]=>阵列
(
[0]=>file1
[1] =>文件2
)
[1] =>阵列
(
[0]=>file1x
)
)
[body]=>数组
(
[0]=>一些文本
[1] =>一些其他文本
)
[accountID]=>数组
(
[0] => 5464654
[1] => 4654664
)
)
if(is_数组($finalArray))//创建新票证
{
$result=$client->call('createMailTicket',$finalArray);
}
$err=$client->getError();
如果($err){
回显“构造函数错误”。$err.';
echo'Debug'.htmlspecialchars($client->getDebug(),entu引号)。“”;
退出();
}
我得到了这个错误:
构造函数错误
分析第1行的SOAP负载时发生XML错误:格式不正确(无效令牌)NuSOAP支持返回多维数组(xsd:array) 客户
client=新的nusoap\u客户端(“http://localhost/webservice /php?wsdl”);
$client->setCredentials(“webadmin”,“****”);
$err=$client->getError();
如果($err){
回显“构造函数错误”。$err.';
}
$result=$client->call('test',array('id'=>'1');
打印(结果);
如果您使用PHP提供的Web服务没有问题,但是在其他语言中存在兼容性问题您解决过这个问题吗?我正在尝试做同样的事情,将数组传递到请求输入中,但是当我使用生成的WDSL时,它不会读取并传递数组(仅当我连接时没有WDSL)
$server= new nusoap_server();
$namespace = "http://localhost/webservice/";
// create a new soap server
$server = new nusoap_server();
// configure our WSDL
$server->configureWSDL("WebServices212");
// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;
$server->register(
// method name:
'test',
// parameter list:
array('id'=>'xsd:int'),
// return value(array()):
array('return'=>'xsd:Array'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'documentation');
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])
? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
client=new nusoap_client("http://localhost/webservice /webservices.php?wsdl");
$client->setCredentials("webadmin","****");
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$result = $client->call('test', array('id' => '1'));
print_r($result);