Hi Tony,

Don't use NuSOAP. It's terrible, outdated, slow, and unstable.

PHP has a native SOAP extension that handles this, and Agavi has a very 
complete integration with it that makes sure you don't have to worry about 
SOAPy details (it even generates WSDLs for you et cetera).

Your problem is that you are trying to start a SOAP service inside a web 
context.

Look at the Sample App to see how it is done. I recommend you check out the 
latest 1.0 branch from SVN, as the process of sending a WSDL file is now 
simpler than in 1.0.5.

1) Edit samples/pub/index.php, and samples/pub/soap.php to bootstrap 
"development-tony".
2) Edit samples/app/config/factories.xml and copy the existing 
"development-david" configuration block that defines the full URI for 
"soap.php" in the WSDL that Agavi will generate
3) Call samples/pub/index.php/products.wsdl in your browser (should bring up a 
blank page, but the page source will have the service WSDL)
4) Edit samples/pub/soap-test.php to point to 
http://localhost/....../samples/pub/index.php/products.wsdl
5) Call samples/pub/soap-test.php - it should now show some results from the 
SOAP call it made to the Agavi service running at soap.php.

The Sample App routing.xml contains a configuration block for SOAP; in there, 
each <route> has a pattern with the name of the method, and then you simply 
define the individual input and output arguments in a reduced WSDL syntax; the 
example in there should be sufficiently explanatory. As you can see in that 
file, you can also embed XML schemas describing custom data types.

The whole WSDL will then be generated for you by Agavi; the Sample App has a 
"SendWsdl" action in the default module that simply instantiates a new soap 
context inside the current web context and fetches the generated WSDL file.

The service in the Sample App allows listing products and fetching individual 
products; the code is of course the same as the products list and detail view 
in the web interface, just the views have a new executeSoap() method returning 
the SOAP response data (which in this case is simply the Product model object 
or an array of them, and Agavi and the PHP SOAP extension then marshal it into 
XML according to the WSDL and send a response).

As you can see, easy stuff. Set it up once, and then you can expose any action 
via SOAP, without even having to duplicate code :)

Hope that helps; let me know if you have more questions,

David

P.S. The Sample App also has a command line interface; try "php console.php" in 
samples/pub/ :)


On 21.06.2011, at 07:47, t m wrote:

> Has anyone tried using agavi as a soap server, i found scarcely anything on 
> the net about using agavi alone or with nusoap to create a soap server. I 
> keep getting errors like agavi wants to send the headers. It looks like there 
> is some special config that has to be used to turn off http headers? The 
> approach i am using, which may be off track also, is to instantiate a nusoap 
> server in the Model constructor. Then the methods of the model become the 
> methods of the soap service which gets called by a single default action. 
>  
> Thanks in advance,
>  
> Tony Muscarelli _______________________________________________
> users mailing list
> [email protected]
> http://lists.agavi.org/mailman/listinfo/users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to