Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: PHP SOAP create appointment example

  1. #1
    AddGun is offline Starter Member
    Join Date
    Jun 2007
    Posts
    2
    Rep Power
    8

    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)?

  2. #2
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    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!

  3. #3
    kinihepu is offline Junior Member
    Join Date
    Jan 2008
    Posts
    6
    Rep Power
    7

    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

  4. #4
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    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!

  5. #5
    kinihepu is offline Junior Member
    Join Date
    Jan 2008
    Posts
    6
    Rep Power
    7

    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

  6. #6
    kinihepu is offline Junior Member
    Join Date
    Jan 2008
    Posts
    6
    Rep Power
    7

    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.

  7. #7
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    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!

  8. #8
    kinihepu is offline Junior Member
    Join Date
    Jan 2008
    Posts
    6
    Rep Power
    7

    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

  9. #9
    zenthanian is offline Junior Member
    Join Date
    Jan 2008
    Posts
    7
    Rep Power
    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>";
    ?>

  10. #10
    kinihepu is offline Junior Member
    Join Date
    Jan 2008
    Posts
    6
    Rep Power
    7

    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.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Simple SOAP Admin Example In PHP
    By mikes2277 in forum Developers
    Replies: 11
    Last Post: 07-23-2011, 01:00 AM
  2. PHP SOAP vs Zimbra
    By Corey Scott in forum Developers
    Replies: 14
    Last Post: 02-05-2011, 04:41 AM
  3. How to handle SOAP body response in PHP
    By ferdinant in forum Developers
    Replies: 1
    Last Post: 07-03-2007, 01:21 PM
  4. php CreateAccountRequest via SOAP
    By bookatechie in forum Developers
    Replies: 2
    Last Post: 05-02-2007, 11:28 AM
  5. PHP create context header
    By bookatechie in forum Developers
    Replies: 1
    Last Post: 05-01-2007, 08:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •