1

I am developing a SOAP Sever in PHP. 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.

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.

nana.chorage
  • 496
  • 4
  • 15

2 Answers2

0

Your can not do it, because you would break the SOAP protocol. Please consider this answer for the similar question.

Community
  • 1
  • 1
dzensik
  • 695
  • 11
  • 20
0

I am using following approach to get above requirement done. This is Partial SOAP and Partial REST. :P

php://input

php://input is a read-only stream that allows you to read raw data from the request body.

server.php looks like this.

$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

nana.chorage
  • 496
  • 4
  • 15