Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-24-2007, 08:17 PM
Starter Member
 
Posts: 2
Default PHP SOAP create appointment example

I need help in creating appointment in PHP by using SOAP.
Can anyone give me an example (complete code in PHP)?
Reply With Quote
  #2 (permalink)  
Old 06-29-2007, 10:04 AM
Zimbra Employee
 
Posts: 1,434
Default Debug window

Easiest thing to do is turn on the SOAP trace debug window and create an appointment from the AJAX client. Then use the PHP SOAP package of your choice to generate XML like that...
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #3 (permalink)  
Old 01-28-2008, 04:27 PM
Junior Member
 
Posts: 6
Default PHP SOAP create appointment example

I am trying to do the same thing, but I am not an administrator, but have an account, and don't know too much about Zimbra or SOAP. Is there an example out that will show all the steps to sending SOAP requests to Zimbra. I assume I have to provide login and password then send my request. I also need to send emails as well.

I don't mind figuring this out on my own, but I can't anything other than the "create an account" example that doesn't help me all that much.

Thanks for your help.

K
Reply With Quote
  #4 (permalink)  
Old 01-29-2008, 11:05 AM
Zimbra Employee
 
Posts: 1,434
Default

Same advice stands. Search the forums for how to open the debug window from your (non-admin) client. Then do your normal AJAX client operations and watch the SOAP fly by in the debug window.
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #5 (permalink)  
Old 01-29-2008, 11:14 AM
Junior Member
 
Posts: 6
Default Code Example?

Thanks for the response, but I was looking for something along the lines of a PHP or PEAR code example.



Thanks

K
Reply With Quote
  #6 (permalink)  
Old 01-29-2008, 04:00 PM
Junior Member
 
Posts: 6
Default A Little Closer

So I'm able go "login" to Zimbra without errors. Now, I'm trying to create the appointment. Here's the code I'm using and I'm not getting anywhere with it.
Anyone have any ideas?

If there is any documentation about this google hasn't heard of it.

Thanks
K

try {
$result = $soapClient->__soapCall("CreateAppointmentRequest",
array(
// new SoapParam('me', 'uid'),
new SoapParam("d=20080131T100000", 's'),
new SoapParam("d=20080131T120000", 'e'),
new SoapParam("a=client1", 'at'),
new SoapParam("a=client2", 'at')
)
);
}
catch (SoapFault $exception) {
//if(is_soap_fault($ZimbraSession))
// trigger_error("SOAP Fault: (faultcode: {$ZimbraSession->faultcode}, faultstring: {$ZimbraSession->faultstring})", E_USER_ERROR);
echo "exception caught $exception<br><br>";
//echo $client->__getLastRequest() . "<br><br>";
echo "Retrieveing Request Headers.....<br>";
echo $soapClient->__getLastRequestHeaders() . "<br><br>";
echo "Retrieveing Response Headers.....<br>";
echo $soapClient->__getLastResponseHeaders() . "<br><br>";
echo "Retrieveing Response.....<br>";
echo $soapClient->__getLastResponse() . "<br><br>";
echo $exception . "<br><br>";
}

And the response I get is.......


SoapFault exception: [soap:Client] unknown document: ns1:CreateAppointmentRequest in /dir_path/index.php:75 Stack trace: #0 /dir_path/index.php(10): SoapClient->__soapCall('CreateAppointme...', Array) #1 {main}

Last edited by kinihepu : 01-29-2008 at 04:19 PM.
Reply With Quote
  #7 (permalink)  
Old 01-29-2008, 04:16 PM
Zimbra Employee
 
Posts: 1,434
Default

Make sure you set it up so that the request specifies that "CreateAppointmentRequest" is in the namespace "urn:zimbraMail".
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #8 (permalink)  
Old 01-30-2008, 10:20 AM
Junior Member
 
Posts: 6
Default

>> Make sure you set it up so that the request specifies that "CreateAppointmentRequest" is in the namespace "urn:zimbraMail".


Anybody have the slightest idea of how I would do this?

Thanks for you help.

K
Reply With Quote
  #9 (permalink)  
Old 01-30-2008, 12:30 PM
Junior Member
 
Posts: 7
Default

I don't have a create appointment example... but I do have a search request example. Hope this helps.

Code:
<?php
    $options = array('uri' => "urn:zimbraMail");
	$params = array( 
    	new SoapParam("inbox", 'l'), 
    	new SoapParam("5", 'limit'), 
    	new SoapParam("is:unread", 'query'));
    	
    try {
        echo "creating header<br>";
        $soapHeader = new SoapHeader(
                    'urn:zimbra',
                    'context',
                    new SoapVar('<ns2:context><authToken>' . $authToken . '</authToken></ns2:context>', XSD_ANYXML)
                    );

        echo "trying<br>";
        $result = $client->__soapCall(
                    "SearchRequest",
                    $params,
                    $options,
                    $soapHeader
        );
        echo "executed<br>";
    } catch (SoapFault $exception) {
        echo "exception caught<br><br>";
        echo print_nice($client->__getLastRequest()) . "<br><br>";
        echo print_nice($client->__getLastRequestHeaders()) . "<br><br>";
        echo print_nice($client->__getLastResponseHeaders()) . "<br><br>";
        echo print_nice($client->__getLastResponse()) . "<br><br>";
        echo $exception . "<br><br>";
    }

    echo "done<br><br>";
    echo print_nice($client->__getLastRequest()) . "<br><br>";
    echo print_nice($client->__getLastResponse()) . "<br><br>";
?>
Reply With Quote
  #10 (permalink)  
Old 01-30-2008, 02:39 PM
Junior Member
 
Posts: 6
Default That Was Huge Help

That really helped, but now I'm getting another error that is just as mysterious. Here is the code I came up with:


$options = array('uri' => "urn:zimbraMail");
$params = array(
new SoapParam("<s d=\"20080131T100000\" /> <e d=\"20080131T120000\" />
<at a=\"him\" /> <at a=\"her\" /> ", 'm')
);

try {
echo "creating header<br>";
$soapHeader = new SoapHeader(
'urn:zimbra',
'context',
new SoapVar('<ns2:context><authToken>' . $authToken . '</authToken></ns2:context>', XSD_ANYXML)
);

echo "trying<br>";
$result = $soapClient->__soapCall(
"CreateAppointmentRequest",
$params,
$options,
$soapHeader
); //<== line 80
echo "executed<br>";
}

and the error is:

SoapFault exception: [soap:Server] system failure: java.lang.NullPointerException in /calendar/index.php:80 Stack trace: #0 /calendar/index.php(80): SoapClient->__soapCall('CreateAppointme...', Array, Array, Object(SoapHeader)) #1 {main}



I have been trying to run the $set:debug 1 in my search window, but it either hangs or I an error like "Your skin won't allow some tree...". So I'm not sure how correct my syntax is.


Thanks all for your help.

K

Last edited by kinihepu : 01-30-2008 at 04:06 PM.
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0