How can i set attributes with NuSoap in PHP?
I am working with nuSoap to build a soap server. But i cant get the attributes the way i want.
I would like as return value:
<return xsi:type="tns:Taxatie">
<EmailAdres OptIn="1" xsi:type="tns:string">email@domain.com</EmailAdres>
</return>
And i get:
<return xsi:type="tns:Taxatie">
<EmailAdres OptIn="1" xsi:type="tns:EmailAdres">
<EmailAdres xsi:type="xsd:string">email@domain.com</EmailAdres>
</EmailAdres>
</return>
anyone know what i must change?
Or how I should set up the arrays?
This is my test code:
<?php
require_once("nusoap.php");
$soapserver = new nusoap_server();
$soapserver->configureWSDL('thijs.test', 'urn:thijs.test');
$soapserver->wsdl->addComplexType(
'Taxatie',
'complexType',
'struct',
'all',
'',
array(
'EmailAdres' => array('name' => 'EmailAdres', 'type' => 'tns:EmailAdres')
)
);
$soapserver->wsdl->addComplexType(
'EmailAdres',
'simpleType',
'struct',
'all',
'',
array(
"EmailAdres" => array('name' => 'EmailAdres', 'type' => 'xsd:string', 'minOccurs' => 0)
),
array(
'OptIn' => array('name' => 'OptIn', 'type' => 'xsd:boolean', 'use' => 'required')
)
);
$soapserver->register('taxatie', // method name
array(), // input parameters
array('return' => 'tns:Taxatie'), // output parameters
'urn:thijs.test', // namespace
'urn:thijs.test#taxatie', // soapaction
'rpc', // style
'encoded', // use
'return something' // documentation
);
class taxatie
{
var $EmailAdres = null;
function taxatie()
{
$this->EmailAdres = new emailadres();
}
}
class emailadres
{
var $EmailAdres = 'email@domain.com';
var $OptIn = true;
}
function taxatie()
{开发者_开发问答
return new taxatie();
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$soapserver->service($HTTP_RAW_POST_DATA);
Thanks in advance
Why not simply return an array instead of using complex type?
e.g
$resultarray['taxatie'] = array(
'EmailAdres' => $row["EmailAdres"],
'tagcount' => $row["tagcount"],
'OptIn' => $row["OptIn"]
);
精彩评论