views:

874

answers:

3

I am testing a server and client i made on my webspace.

when i try to call a simple "testServer" function defined in a ServerMap class, I get "Looks like we got no XML document"

..?

I called getFunctions on the client and testServer is a valid function. I tried catching all exceptions and then calling __getLastResponseHeaders() and __getLastResponse.

header:

string(348) "HTTP/1.1 200 OK
Date: Tue, 23 Jun 2009 19:36:29 GMT
Server: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9
X-Powered-By: PHP/5.2.9
Cache-Control: max-age=1
Expires: Tue, 23 Jun 2009 19:36:30 GMT
Vary: Accept-Encoding
Content-Length: 1574
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
"

response:

string(1574) "DEBUG HEADER : This is a cached page !

"

If i look at the source html of the response, its actually:

string(1574) "DEBUG HEADER : This is a cached page !<?xml version="1.0"?>
<A lot of xml that looks pretty much like my WSDL file that my Zend_Soap_AutoDiscover generates>

So whats going on? I searched online and i didnt really find any solid solutions. I don't have blank space before my ..

A: 

If you are outputting to the browser, it is hiding the xml cause it is in a . Browsers ignore tags they don't understad.

Do a echo htmlentities($output); to see the xml tags.

Byron Whitlock
that may be true, but my problem still stands that i don't get back from my server what i want. All that i printed to the browser was taken from __getLastResponse() and such
Roman
A: 

Not sure what your problem is, but I can provide a bit of code that I know works for us using Zend Framework 1.8x as a backend SOAP service for silverlight and WCF. This service simples takes 2 integers, adds them and returns the result. Simple as you can get.

Controller Class example:

class SoapController extends Zend_Controller_Action  {

    /*
     * SOAP server action
     */
    public function indexAction() {

     $request = $this->getRequest();  
     if ($request->getParam('wsdl') !== null) {
      $wsdl = new Zend_Soap_AutoDiscover();
      $wsdl->setClass('SoapMath');
      $wsdl->handle();
     }
     else { 
      $module = $request->getModuleName();
         $controller = $request->getControllerName();
      $uri = 'http://' . Zend_Registry::get('fullUrl') . '/' . $module . '/' . $controller . '?wsdl';
      $server = new Zend_Soap_Server($uri);  
      $server->setClass('SoapMath');
      $server->handle();
     }
     exit;
    }
}

And the actual work is done by 'SoapMath' which is defined as:

class SoapMath {

    public function add($a,$b) {

     return ($a + $b);
    }
}
Jeff
A: 

Why use SOAP?

Just switch over to JSON and forget all the XML BS... There are JSON libraries for just about any language ever inventer over at json.org

Romansky