2014-07-05 70 views
0

我正在PHP中開發SOAP服務器。 有一個特殊的要求,這個服務器應該接收SOAP信封的請求,但在返回請求時它不應該包含任何SOAP信封。SOAP服務器:需要返回沒有SOAP的SOAP響應信封

請求如下所示:

<?xml version="1.0"?> 
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope" 
SOAP-ENV:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> 
    <SOAP-ENV:Body xmlns:m="http://www.xyz.org/quotations"> 
    <GetDetails> 
     <UserID>1<UserID> 
    </GetDetails> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

響應應該是這樣的:

<UserDetails> 
    <fame>ABC</fname> 
    <lame>XYZ</lname> 
</UserDetails> 

請幫助。

回答

0

你不能這樣做,因爲你會打破SOAP協議。請爲類似問題考慮this答案。

0

我正在使用以下方法來完成上述要求。 這是部分SOAP和部分REST。 :P

php://input 

php:// input是一個只讀流,允許您從請求主體讀取原始數據。

server.php看起來像這樣。

$HTTP_METHOD = $this->input->server('REQUEST_METHOD'); 

if($HTTP_METHOD!='POST'){ 
    echo "Invalid http method"; 
    die; 
} 

$data = fopen('php://input','rb'); 
$Headers = getallheaders(); 
$CLength = $Headers['Content-Length']; 
$content = fread($data,$CLength); 

//Here We can Parse Request XML and get required SOAP header and Soap Body out of it 

/* 
//Here We can write our business logic 


*/ 


echo $resonse; //In this we can built custom xml and simple echo 

如果你有什麼比這種善意的建議更好。

謝謝