soap server doesn't work

39 views
Skip to first unread message

SoftWord

unread,
Jul 4, 2019, 12:02:09 PM7/4/19
to Fat-Free Framework
Hi, I've made a simple soapserver without any framwork, and it works. But in F3 not:



class OMSoap extends PluginStrategy
{
...............
...............
public function putPickingList(pickingList $pckList)
{
return 'ok';
}
public function putConsegne(consegne $consegne)
{
return 'ok';
}
public function Soap($f3)
{
$server = new SoapServer("src/Modules/OMSoap/app.wsdl", [
'classmap' => LAMBO_SOAP_CLASSMAP
]);
$server->setObject($this);
// $server->addFunction('putPickingList');
// $server->addFunction('putConsegne');
$server->handle();
}
}

If I try to check if all is working with http://localhost/lambo/soap?wsdl, I receive this error:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Bad Request</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Help please :(

richgoldmd

unread,
Jul 4, 2019, 12:18:57 PM7/4/19
to Fat-Free Framework
I can't confirm right now, but I suspect that F3 is consuming the input stream to populate the BODY variable in the hive, so its no longer available to SoapServer::handle()

You might try changing the handle() call to:

$server->handle($f3->get('BODY'));

If your payloads are very large, you may have issues and need to set RAW to true and stream the input, but this is not usually the case.

SoftWord

unread,
Jul 4, 2019, 12:38:58 PM7/4/19
to Fat-Free Framework
$server->handle($f3->get('BODY'));
it doesn't work :(


and yes I think that it consume file://input

SoftWord

unread,
Jul 5, 2019, 12:49:28 AM7/5/19
to Fat-Free Framework
I can confirm that without f3, my code works.

Any idea please?

richgoldmd

unread,
Jul 5, 2019, 5:15:18 AM7/5/19
to f3-fra...@googlegroups.com
So reviewing your code more closely - You are using the ?wsdl variant of the url, expecting to receive the wsdl document in return. Also your test is a GET, so your method wont have any body to parse in any case.

The server expects to receive actual Soap calls via POST.

I think you could either specify a separate route for the url for GET to handle the ?wsdl or check the verb in your handler, like this (I'd prefer a separate route, but nothing wring with this except that the method check is redundant):

public function Soap($f3)
{
   
if ($f3->get('VERB') == 'POST') {

      $server
= new SoapServer("src/Modules/OMSoap/app.wsdl", [
         
'classmap' => LAMBO_SOAP_CLASSMAP
     
]);
      $server
->setObject($this);
     
// $server->addFunction('putPickingList');
     
// $server->addFunction('putConsegne');

      $server
->handle($f3->get('BODY'));
   
} else { // GET
     
if ($f3->exists('GET.wsdl') || $f3->exists('GET.WSDL')) { // Some clients use uppercase WSDL
         header
('Content-Type: text/xml; charset="utf-8"');
         readfile
('src/Modules/OMSoap/app.wsdl'); // might be better to save path in a class const or variable and make sure this resolves to the file
     
} else {
         $f3
->error(404); // Not sure what to do for GET if WSDL is not provided.
     
}
   
}

}



Note that this should pass your ?wsdl test but that test is inadequate to test the functionality of the SopServer.

richgoldmd

unread,
Jul 5, 2019, 5:19:45 AM7/5/19
to Fat-Free Framework
I'm also assuming you are routing both GET and POST to this handler, via something like

$f3->route('GET|POST /soap','OMSoap->Soap');


Or otherwise directing the traffic there in response to GET or POST.

SoftWord

unread,
Jul 5, 2019, 5:50:47 AM7/5/19
to Fat-Free Framework
  1. $f3->route('GET|POST /soap', __NAMESPACE__ . '\OMSoap->Soap');

exacly I made this......
Message has been deleted

SoftWord

unread,
Jul 5, 2019, 6:49:42 AM7/5/19
to Fat-Free Framework
OMG it works!!!!!! Not good to see "if POST / else GET" but the important is that it works!!!

Many thanks my friend!!! I'm in debit of a beer :laugh:

richgoldmd

unread,
Jul 5, 2019, 8:05:25 AM7/5/19
to Fat-Free Framework
Glad I was able to help. You can avoid the if/else by using separate routes for GET and POST and just handle the wsdl in its own method.

Have you tried with a SOAP client to ensure that the post works as expected?

SoftWord

unread,
Jul 5, 2019, 8:41:51 AM7/5/19
to Fat-Free Framework

Have you tried with a SOAP client to ensure that the post works as expected?

yes, yes, I've made all tests, some problems about object classes namespace but solved correctly! :-D

thanx!

Richard Goldstein

unread,
Jul 6, 2019, 8:42:38 AM7/6/19
to SoftWord via Fat-Free Framework

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/ab6cb7a9-704d-4347-8672-b37e48ab8df7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages