我正在开发一个PHP的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>请帮帮忙。
发布于 2014-07-05 21:25:31
您不能这样做,因为您会破坏SOAP协议。请考虑类似问题的this答案。
发布于 2014-07-07 13:50:45
我正在使用以下方法来完成上述要求。这是部分SOAP和部分REST。:P
php://inputphp://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如果你有比这个更好的建议。
谢谢
https://stackoverflow.com/questions/24583803
复制相似问题