2

ZendアプリケーションでSOAPクライアントを開発する必要がありますが、それを機能させる方法について本当に混乱しています。私は可能な限りほとんど何でも試しましたが、ビリオンの時間についてグーグルで検索しましたが、その気の毒なWebサービス呼び出しを機能させる方法はありませんでした。

クライアントは、応答として証明書とオブジェクトを取得するために、画像といくつかの文字列をストリーミングできるようにする必要があります。

4

2 に答える 2

2

Zend_Soap での私の経験から、引数を配列として渡す必要があります。次に例を示します。

$client->ControlMRZ(array('file' => $file, 'filestream' => 'test.jpg', 'anothervar' => 0); 

SOAP ヘッダーを渡すには、次のように SOAPSOAPHeaderリクエストにオブジェクトを添付できます。

/**
 * Generate the auth token and create a soap header
 * 
 * @return SoapHeader
 */
private function generateAuthHeader()
{
    $ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';

    $token = new stdClass ();
    $token->Username = new SOAPVar ( $this->_vendor, XSD_STRING, null, null, null, $ns );
    $token->Password = new SOAPVar ( $this->_password, XSD_STRING, null, null, null, $ns );

    $wsec = new stdClass ();
    $wsec->UsernameToken = new SoapVar ( $token, SOAP_ENC_OBJECT, null, null, null, $ns );

    $headers = array(new SOAPHeader ( $ns, 'Security', $wsec, true ));

    return $headers;
}



    $this->_client->getSoapClient()->__setSOAPHeaders ( $this->generateAuthHeader () );

PS。ソープ嫌い

于 2012-07-10T21:02:12.480 に答える
0

最後に、それはそれを行う正しい方法でした:

$client = new Zend_Soap_Client($myWebServiceUri,array(
                                    'encoding' => 'UTF-8'
                                    ));
$client->setSoapVersion(SOAP_1_1);        
$url = '/var/www/upload/test.jpg';
$file = fread(fopen($url, "r"), filesize($url));

function generateHeader() {


    $headers[] = new SoapHeader( $ns , 'AccountName', new SoapVar( 'login', XSD_STRING, null, null, null, $ns ), false );
    $headers[] = new SoapHeader( $ns , 'AccountPassword', new SoapVar( 'password', XSD_STRING, null, null, null, $ns ), false );
    $headers[] = new SoapHeader( $ns , 'Agency', new SoapVar( 'agency', XSD_STRING, null, null, null, $ns ), false );
    $headers[] = new SoapHeader( $ns , 'FileName', new SoapVar( 'filename', XSD_STRING, null, null, null, $ns ), false );
    $headers[] = new SoapHeader( $ns , 'Options', new SoapVar( options, XSD_STRING, null, null, null, $ns ), false );

    return $headers;
}


$soapHeaders = generateHeader();
$client->getSoapClient()->__setSoapHeaders( $soapHeaders );
$result = $client->ControlMRZ(array('FileStream'=>$file));
Zend_Debug::dump($result);

@aporatとSebastienLorberの助けに感謝します!

于 2012-07-11T20:20:43.133 に答える