简体   繁体   English

SOAP服务器:需要返回没有SOAP Envelop的SOAP响应

[英]SOAP Server: Need to return SOAP response without SOAP Envelop

I am developing a SOAP Sever in PHP. 我正在用PHP开发SOAP服务器。 There is a special requirement that this server should receive request with SOAP Envelop but while returning request it should not include any soap envelope. 有一个特殊要求,即该服务器应使用SOAP Envelop接收请求,但是在返回请求时,它不应包含任何肥皂信封。

Request Looks like this: 请求看起来像这样:

<?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>

Response should look like this: 响应应如下所示:

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

Kindly Help. 请帮助。

Your can not do it, because you would break the SOAP protocol. 您无法做到,因为您会破坏SOAP协议。 Please consider this answer for the similar question. 请针对类似问题考虑答案。

I am using following approach to get above requirement done. 我正在使用以下方法来完成上述要求。 This is Partial SOAP and Partial REST. 这是部分SOAP和部分REST。 :P :P

php://input

php://input is a read-only stream that allows you to read raw data from the request body. php:// input是一个只读流,允许您从请求正文中读取原始数据。

server.php looks like this. 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

If you have anything better than this kindly advice. 如果您有什么比这更好的建议。

Thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM