Php 重写SoapClient doRequest将返回字符串,而不是对象
我正在重写SoapClient中的doRequest函数,以便解析/解码响应。请求发送正常,响应内容正常。我遇到的问题是第二个函数(_myDoRequest)返回的是字符串,而不是对象 我怀疑因为myDoRequest绕过了_调用,所以_调用必须以某种方式格式化响应。据我所知,我不能重写_调用,因为它需要函数名和参数,在myDoRequest中我不知道这一点(我只是重新生成标题,并将xml复制到正文中)。是否有任何解决方案不涉及解析xml文档以获取函数/参数 注意事项:Php 重写SoapClient doRequest将返回字符串,而不是对象,php,soap,soap-client,Php,Soap,Soap Client,我正在重写SoapClient中的doRequest函数,以便解析/解码响应。请求发送正常,响应内容正常。我遇到的问题是第二个函数(_myDoRequest)返回的是字符串,而不是对象 我怀疑因为myDoRequest绕过了_调用,所以_调用必须以某种方式格式化响应。据我所知,我不能重写_调用,因为它需要函数名和参数,在myDoRequest中我不知道这一点(我只是重新生成标题,并将xml复制到正文中)。是否有任何解决方案不涉及解析xml文档以获取函数/参数 注意事项: $this->parse
$this->parse_response($response)
:返回字符串
简言之:
$this->soapclient->\uu doRequest(…)代码>:返回字符串
$this->soapclient->搜索名称($request)
:返回对象(stdClass)
我希望$this->soapclient->name\u of_search($request)
返回一个对象,而不是字符串
__召唤
public function __call($function_name, $arguments)
{
$this->__setSoapHeaders($this->generateWSSecurityHeader());
return parent::__call($function_name, $arguments);
}
__多勒奎斯特
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
return $this->parse_response($response);
}
__myDoRequest
function __myDoRequest($request, $location, $action, $version, $one_way = 0)
{
//Set up the new headers
$xml = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="..." xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<SOAP-ENV:Header>';
$xml .= $this->generateWSSecurityHeader("xml");
$xml .= "</SOAP-ENV:Header><SOAP-ENV:Body>";
$xml .= $request;
$xml .= "</SOAP-ENV:Body></SOAP-ENV:Envelope>";
$response = parent::__doRequest($xml, $location, $action, $version, $one_way);
if((isset($this->__soap_fault)) && ($this->__soap_fault != null))
{
$exception = $this->__soap_fault;
if($exception != null)
{
throw $exception;
}
}
return $this->parse_response($response);
}
function\uu myDoRequest($request、$location、$action、$version、$one\u way=0)
{
//设置新标题
$xml='0
';
$xml.=$this->generatewsecurityheader(“xml”);
$xml.=“”;
$xml.=$request;
$xml.=“”;
$response=parent::u doRequest($xml、$location、$action、$version、$one\u-way);
if((isset($this->\uuusoap\u fault))&($this->\usoap\u fault!=null))
{
$exception=$this->\u soap\u故障;
如果($exception!=null)
{
抛出$exception;
}
}
返回$this->parse_response($response);
}
他们是如何被称为:
<snip>
if($raw_xml)
{
$response = $this->soapclient->__doRequest($raw_xml, '...', "", 1, 0);
}
else
{
$response = $this->soapclient->name_of_search($request);
}
<snip>
if($raw_xml)
{
$response=$this->soapclient->doRequest($raw\uxml,“…”,“,1,0);
}
其他的
{
$response=$this->soapclient->name\u of_search($request);
}