1

このような石鹸ヘッダーを作成するにはどうすればよいですか?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<requestHeader>
<user>
<userId>ID</userId>
<password>Password</password>
</user>
<service>service</service>
</requestHeader>
4

2 に答える 2

1

何のために作成する必要があるかはあまり明白ではありませんが、一般的には PHP DOM 一連の関数です。

http://php.net/manual/en/book.dom.php

XML の生成を許可し、後で使用するために結果を文字列に保存します。SOAP を介して通信している場合、または SOAP サーバーを作成したい場合、PHP の SOAP 関数は優れたリソースです。

http://www.php.net/manual/en/book.soap.php

于 2011-05-11T11:44:24.690 に答える
1

SOAPサーバーへの「ログイン」に必須のクライアントヘッダーについて話していると思うので、その仮定に基づいて、これはあなたがしたいことのように見えます:

<?php 
$ns = 'urn:namespace'; // the namespace for the request, you don't appear to have any

// actual header construction, based on your structure
$soapHeader = array('user' => array( 
                      'userId' => $__yourUserID, 
                      'password' => $__yourUserPassword,
                    ),
                    'service' => $__yourService,
);

// Soap Header initialization
$header = new SOAPHeader($ns, 'requestHeader', $soapHeader);        

// add the Header to the Soap Client before request
$soap_client->__setSoapHeaders($header); 

?>
于 2011-05-11T12:30:33.613 に答える