I am trying to create a soap service in php using native php soap server. I have already prepared the wsdl file. There are basically four methods that can be called with the soap service. The input soap request for one of the request ShowRemittanceDetail is shown below.

<soap-env:body>
    <ns1:showremittancedetailrequest>
        <username>admin</username>
        <password>pass</password>
        <refno>USA1956127848</refno>
    </ns1:showremittancedetailrequest>
</soap-env:body>

Anyway the soap request does not have a header and I have just shown the body here. I have no problem parsing the soap request. The response should look like this

<?xml version="1.0" encoding="ISO-8859-1"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <ns2:responseType xmlns:ns2="http://tempuri.org/response">
        <code>00</code>
        <message>Transaction does not exist or is not available</message>
        <responseBody>
            <responseStr>4</responseStr>
        </responseBody>
    </ns2:responseType>
    </soapenv:Body>
</soapenv:Envelope>

This is a particular response which is generated when the transaction with the reference number is not available in the server. I have received the soap request and evaluated it. However I have a problem with the return type of the soap response. I cannot generate a valid response. What type of response should a soap server return?

Things I have tried:

  1. I have tried returning an xml string. But the soap client request throws an exception with the following message. looks like we got no xml document.
  2. I have also tried returing a native php SoapVar() with the same result.

  3. I have tried returning an object response that is specified in the classmap fo the soap server. e.g. for the example above, I have tried returning a ShowRemittanceDetailResponse object with the same result. (looks like we got no xml document).

  4. I have tried returning a DomDocument Object . The exception thrown in this case is

the encoded object does not have a responseStr property.

  1. I have tried returning an stdClass object with the same fields as the response expects with similar result.

Please help me. Thanks in advance.

有帮助吗?

解决方案

The solution I found was returning a SoapVar object. I didnt have soapui and the client I wrote in php was incorrect. Hence, I had problem verifying the returned xml as the php soap client was throwing an exception. The correct way for me was to return a SoapVar.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top