猿问

PHP调用webservice,返回字符串但取不到返回值

PHP调用webservice,但取不到返回值,在网页上直接获取是可以拿到返回值的。

获取返回值的方法如下:


ini_set("soap.wsdl_cache_enabled",0);

function getSoapData($cardNo){    

    echo '##########################,';
    echo $cardNo;
    try {
        // 示例webservice地址.
        $client = new SoapClient ( "http://soap.org/wsdl?", array (
                'encoding' => 'UTF-8' 
        ) );
        $strinfo = $client-> GetOpenID( array (
                'CardNo'=>$cardNo
        ) );
        echo ',##########################'.$client->GetOpenID($cardNo);
    } catch ( Exception $e ) {
        echo 'ERR\n\n\n';
        Think\Log::record ( $e, 'ERR' );
    }
    return $strinfo;
}

网页上的返回值是:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
        <GetOpenIDResponse xmlns="http://www.xxxxxxxx.cn">
            <GetOpenIDResult>fdlsakfjsdlafsdkllfk02943ielkdsjfalsdk12878</GetOpenIDResult>
        </GetOpenIDResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

请问该怎么才能取到返回值??谢谢.

慕工程0101907
浏览 514回答 1
1回答

慕田峪7331174

$client = new SoapClient($host, array( 'trace' => true, 'cache_wsdl' => WSDL_CACHE_BOTH, )); $functionName = 'funcname'; $response = $client->__soapCall($functionName, array( $functionName => array('in0' => $params), )); 确认一下你的soap Server地址
随时随地看视频慕课网APP
我要回答