2 users online. Create an account or sign in to join them.Users
Interacting with Web Services
This is an open discussion with 14 replies, filed under General.
Search
So Symphony will connect to these "dynamic XML" datasources and pass parameters to them, etc.
A Dynamic XML DS is only able to work with URL based requests. SOAP is an XML RPC like service and sends and receives XML based on a WSDL spec. Symphony handles XML easily, so that isn't the problem. What will be is actually making the requests via the SOAP client to the server.
My suggestion would be to abstract a lot of the low level SOAP calls to a PHP class (or extension). Then you would have a bunch of DS's and Events for calling that class and sending/receiving XML.
http://au2.php.net/manual/en/function.soap-soapclient-soapcall.php
That's a good start. What you could also do is have a standalone script that your Symphony Dynamic XML DS can make requests to, rather than using an extension. E.G. http://mysite.com/soapclass.php?action=sendCreditCard&name=Fred&Number=1234 which would return XML for success or failure.
We are doing exactly this to integrate Symphony with .NET SOAP webservices. A PHP page/class sits as a proxy between the two, nailed into Symphony as a Dynamic DS. Something like:
{$root}/assets/service.php?method=GetRecord&id={$ds-section}
This is all very well for doing request-based calls (question 1). The PHP script interprets the URL (the method and the ID passed to it), creates a SOAP request, gets the XML response from this SOAP request, formats back into XML that is easy to read (SOAP XML can be very verbose), and outputs the XML (which then goes into the Symphony page).
However making a post-based request (question 2) will require a change of tack. Instead of making the SOAP call inside the PHP proxy page, you'd want to use a Symphony event, and modify the event PHP file (generated by Symphony) to make your SOAP call. From the Symphony event you can write out XML into the page depending on success/fail from the SOAP request.
Thanks both. I'm passing this info on to my colleagues.
However making a post-based request (question 2) will require a change of tack.
Why not have an Event that uses the POST data to make the call to your proxy script in the same way a Dynamic XML DS would?
You should make a new extension to handle the SOAP work, it'd have it's own events and datasources, but the code that fetches and sends would be in the extension.driver.php file.
Just a code design thought.
Craig, (or anyone else) can I ask if/how you were able to solve the SOAP issue? We have a project that will require interaction between a CMS and a business application that will be dependent on SOAP for data exchange. Symphony seems a logical choice for this. Is it?
Would the best solution involve developing an extension that will manage the SOAP calls?
We never got around to doing the custom donation forms, so I never had to tackle this particular problem. And even though the majority of our content came from CRM via SOAP, we never had to do any pushing of data to CRM.
Thanks, Craig. As we’re looking into this further, we may be able to work with the existing system to create custom forms, so we we’re looking at primarily pulling rather than pushing data.
It would be nice to have a Symphony-based solution as an option, though. It would be interesting to take a closer look at how Nick’s ideas might work.
We did something sort of similar to what Nick suggested for our CRM search. We had several search forms, all of which pointed to a custom PHP script which parsed the inputs and created a series of URL params to submit to the results pages, all of which used the same Dynamic DS.
So the process you are describing is the same thing that is being discussed here?
No, not quite. Those were simple Dynamic DSes. Search was a little different.
There was one SOAP web service for searching, which had several different methods (program search, publication search, people search, etc.). Then each method could accept a bunch of search params (titlecontains=example, or authorcontains=zheng, for example).
So we set up one Dynamic DS to interact with this web service. But we had multiple forms with different fields, and multiple results pages. We also need to format form data into URL params to pass to the results pages. So I wrote a PHP script to sit between the forms and the results pages. All the forms submitted to this script, which would parse out the POST data and put together a string of GET params to pass to the results page.
Then we had problems with the way Symphony processes GET params (dealing with spaces, etc). So the Dynamic DS was customized to do a little more parsing of those params. I wrote a function that would re-process all the GET params and append them to the $dsParamURL. So in the end, no matter which form was submitted, or how many fields were filled out (could be any combination of 1-12 fields), all the input would get properly processed and submitted as a call to the web service, and Symphony would grab the resultant XML and attach it to the appropriate results page.
I've been asked to integrate a SOAP web service with an existing Symphony site. The site currently uses URL based XML requests to get its data. I love this way of working and I am very disappointed that SOAP has come into the equation. Who's idea was that?
Grievance aside, I see from the above thread that I'm most probably have to write a PHP script to process URL requests into SOAP requests in order to get my data.
Does anyone have an example of such a script that they can share with me so that I can gauge whether this is going to be achievable with my rubbish PHP skills
Thanks
Hi Stu,
I've not done any SOAP work, but for a project I've managed at work, one of our developers has.
He wrote the following function, using PHP 5's native SOAPClient class:
public function check_applicants($xml=null, $xsd=null)
{
$result = FALSE;
$service_action = "checkApplicants";
if(is_null($xml))
{
return $result;
}
libxml_use_internal_errors(true);
if($this->validate_xml( $xml, $xsd ) !== FALSE)
{
try
{
if(class_exists('SoapClient'))
{
$client = new SoapClient($this->soap_server_location . '/batchService?wsdl', array());
$request_options = array
(
'arg0' => $this->__username,
'arg1' => $this->__password,
'arg2' => $xml
);
$result = $client->__soapCall($service_action, $request_options);
}
else
{
@mail($this->config->item('developer_email'), 'Sentinel >> check_applicants() Error', 'SoapClient class does not exist');
}
}
catch(Exception $e)
{
@mail($this->config->item('developer_email'), 'Sentinel >> check_applicants() Exception Caught', $e->getMessage());
pr($e->getMessage(), true, 'Exception Error');
}
}
return $result;
}
I hope this helps some...
Thanks John. Its all a bit over my head, but I'm hoping to enlist some more qualified help and this may well help them.
Create an account or sign in to comment.
Apologies in advance, because I don't fully understand most of what I'm asking about here
The Background
At my day job, we're rebuilding our organization's site in Symphony 2. A fair amount of the data that will power the site is actually going to be coming out of our Microsoft(!) CRM. The developers that are customizing CRM for us are making that data available to Symphony as XML using Web Services (SOAP, I believe). So Symphony will connect to these "dynamic XML" datasources and pass parameters to them, etc.
The Issue
One of the things we'd like to do is set up a series of custom donation interfaces on our site (either as a Symphony section or as a separate install, depending on security needs). We will build the interfaces and the forms in Symphony, but when submitted, they will need to be able to:
I suspect that we'll have to create some custom event handlers and whatnot, but I don't really know. I've just been instructed to "see how difficult it would be to call a web service from Symphony."
Thanks in advance for any help...