Php SOAP服务器:需要返回没有SOAP信封的SOAP响应
我正在用PHP开发一个SOAP服务器。 有一个特殊要求,即该服务器应使用SOAP信封接收请求,但在返回请求时不应包含任何SOAP信封 请求如下所示:Php SOAP服务器:需要返回没有SOAP信封的SOAP响应,php,web-services,soap,wsdl,Php,Web Services,Soap,Wsdl,我正在用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">
<?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>
1
响应应如下所示:
<?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>
基础知识
XYZ
请帮忙。你不能这样做,因为你会破坏协议。请考虑类似问题的答案。我使用以下方法来完成上述要求。 这是部分SOAP和部分RESTP
php://input
php://input 是一个只读流,允许您从请求主体读取原始数据
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
如果你有比这更好的建议
多谢各位