您所写的内容被称为proxy http://en.wikipedia.org/wiki/Proxy_server.
有一些例子 http://www.codeproject.com/Articles/140189/PHP-NuSOAP-Tutorial#premain3NuSoap 服务器在线发送复杂类型addComplexType
method.
//Create a complex type
$server->wsdl->addComplexType('MyComplexType','complexType','struct','all','',
array( 'ID' => array('name' => 'ID','type' => 'xsd:int'),
'YourName' => array('name' => 'YourName','type' => 'xsd:string')));
实现代理的一种方法是使用存根数据构建服务,这样它实际上不会首先与后端服务通信。看看您的代理的人为响应是否能让原始客户满意。一旦有了这个,使用真正的后端服务应该是微不足道的(根据我的经验,SOAP 客户端操作比服务器操作更容易)。
另一种选择是考虑本地肥皂服务器 http://www.php.net/manual/en/class.soapserver.php类代替。第一条评论here http://www.php.net/manual/en/soapserver.addfunction.php展示如何创建复杂类型。
EDIT
环顾四周后,这是一个更好的例子 http://www.discorganized.com/php/a-complete-nusoap-and-flex-example-part-1-the-nusoap-server/.
根据文档块,有 2 种方法可以使用 NuSoap 注册复杂类型addComplextType
(lib/class.wsdl.php)
/**
* adds an XML Schema complex type to the WSDL types
*
* @param string $name
* @param string $typeClass (complexType|simpleType|attribute)
* @param string $phpType currently supported are array and struct (php assoc array)
* @param string $compositor (all|sequence|choice)
* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
* @param array $elements e.g. array ( name => array(name=>'',type=>'') )
* @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
* @param string $arrayType as namespace:name (xsd:string)
* @see nusoap_xmlschema
* @access public
*/
在我发布的后面的示例中看看他是如何做到的:
$server->wsdl->addComplexType('Contact',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'first_name' => array('name' => 'first_name', 'type' => 'xsd:string'),
'last_name' => array('name' => 'last_name', 'type' => 'xsd:string'),
'email' => array('name' => 'email', 'type' => 'xsd:string'),
'phone_number' => array('name' => 'phone_number', 'type' => 'xsd:string')
)
);
那么如何返回响应Contact复杂类型:
function updateContact($in_contact) {
$contact = new Contact($in_contact['id']);
$contact->first_name=mysql_real_escape_string($in_contact['first_name']);
$contact->last_name=mysql_real_escape_string($in_contact['last_name']);
$contact->email=mysql_real_escape_string($in_contact['email']);
$contact->phone_number=mysql_real_escape_string($in_contact['phone_number']);
if ($contact->update()) return true;
}
您还可以在他的示例中了解如何使用数组变体。抱歉回答这么大!