Link to home
Start Free TrialLog in
Avatar of flowerbloom
flowerbloom

asked on

wsdl php error revealing

I have a soap wsdl programs that are working fine, but when an error occurs, the dump reveals to the calling function private information, like what internal directory is being used.  How can I supress this information from showing up?  Do I need to post the wsdl and the script error to get an answer?
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Yes, we probably need to see your test case.  Please minimize it to the SSCCE and show us how to cause the error.  You may be able to use PHP exception handling.  We will know more once we can test it out.
Avatar of flowerbloom
flowerbloom

ASKER

Below are the files involved, my domain has been replaced with "my.domain.com".

To create an error just have a syntax error on the server.


--- hello_server.php
<?php
function doHello($yourName = "") {
  return "Hello, $yourName";
}

try {
  $server = new SoapServer("hello.wsdl");
} catch (SoapFault $exc) {
  echo "Very Bad.";
}

$server->AddFunction("doHello");
$server->handle();
?>


--- hello_client.php
<?php
try{
  $sClient = new SoapClient('http://my.domain.com/hello.wsdl');
 
  $params = "John";
  $response = $sClient->doHello($params);
  echo "$response <br>\n";
 
} catch(SoapFault $e){
  echo "Error\n";
}
?>


--- hello.wsdl
<?xml version="1.0"?>

<definitions
  name="HelloWorld"
  targetNamespace="urn:HelloWorld"
  xmlns:tns="urn:HelloWorld"  
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns="http://schemas.xmlsoap.org/wsdl/">

  <types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Hello">
      <xsd:element name="getName" type="xsd:string" />
      <xsd:element name="HelloResponse" type="xsd:string" />        
    </xsd:schema>        
  </types>

  <message name="doHello">
    <part name="yourName" type="tns:getName" />
  </message>
 
  <message name="doHelloResponse">
    <part name="return" type="tns:HelloResponse" />
  </message>  

  <portType name="HelloPort">
    <operation name="doHello">
      <input message="tns:doHello" />
      <output message="tns:doHelloResponse" />
    </operation>
  </portType>

  <binding name="HelloBinding" type="tns:HelloPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
      <operation name="doHello">
        <soap:operation soapAction="urn:HelloAction" />
        <input>
          <soap:body use="encoded" namespace="urn:Hello" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />      
        </input>
        <output>
          <soap:body use="encoded" namespace="urn:Hello" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />      
        </output>
      </operation>
  </binding>

  <service name="HelloService">
    <port name="HelloPort" binding="tns:HelloBinding">
      <soap:address location="http://my.domain.com/hello_server.php" />
    </port>
  </service>

</definitions>
Which line of code produces the information you do not want to reveal?
It's the exception dump if there is an error with the "server".  No particular error, any error.
Why not just return a null string when an exception occurs?  On the server you might want to use error_log() so you could inspect the contents of the exception object.
This is not when it works well, otherwise, you're right, just catch the error and send null.

This is when there is a bug and the program crashes.  Please don't saw "debug your program".
when there is a bug and the program crashes
We might need a little more to go on.  What would be an example of a "bug?"  And "crashes" is not really a term of art in software development.  There are specific error conditions, such as loop, wait, incorrect output, etc.  What exactly is (are) the errors?
ASKER CERTIFIED SOLUTION
Avatar of flowerbloom
flowerbloom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I figured it out.