是否可以使用nusoap的call()函数向XML Root添加属性?

时间:2010-12-02 19:45:30

标签: service nusoap fedex

我正在创建一个将使用Fedex Web服务的类。我试图通过nusoap php类的nosoapclient()函数进行通信,并传递一个wsdl文件。似乎Fedex在请求的文档根目录中需要名称空间属性。

我可以使用nusoap的call()函数并将一个XML字符串传递给PARAMETER agrument,它将正常工作。我宁愿传递一个数组作为PARAMETER参数,这就是我遇到问题的地方。

是否可以通过nusoap的call()函数传递数组,并在根目录中包含命名空间属性?

FEDEX RateRequest PHP exerpt
以下是我想要做的事情,而不是实际的代码

$client = new nusoapclient('RateRequest_v9.wsdl',true);
//Thought this would work but to no avail.
//$request_array is a multi-associative array with keys as required XML tag names and values as the tags inner value, did not include as it is irrelevant to this problem
//$root_attr = array('xmlns'=>'http://fedex.com/ws/rate/v9');
//$parameters = array('RateRequest'=>new soapval('RateRequest',false,$request_array,false,false,$root_attr));

$parameters = array('RateRequest'=>$request_array);

//Have tried with and without the third argument - which is the for the namespace
$response = $client->call('getRates',$parameters,'http://fedex.com/ws/rate/v9');

FEDEX RateRequest XML摘录
以下不是完整的XML(查看最终的RateRequest标记以查看差异)

错误格式

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns="http://fedex.com/ws/rate/v9"><SOAP-ENV:Body><RateRequest>...</RateRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>

正确格式

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns="http://fedex.com/ws/rate/v9"><SOAP-ENV:Body><RateRequest xmlns="http://fedex.com/ws/rate/v9">...</RateRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>

如果我在其他地方错过了这个对话,我会提前道歉但是我一直在搜索网络并尝试一切我能想到的工作,如果不可能有任何建议吗?提前感谢您的帮助。

0 个答案:

没有答案