Results 1 to 7 of 7

Thread: Accessing mail attachments via SOAP?

  1. #1
    Join Date
    Mar 2006
    Posts
    52
    Rep Power
    9

    Default Accessing mail attachments via SOAP?

    We would like to access files, that are attached to e-mails in Zimbra, with our web application.

    What is the best way to do this?

    If we try a direct link (http://mail.abak.net/service/home/~/...&part=2&disp=a) we get "Access to the specified resource (must authenticate) has been forbidden."

    What do these parameters in URL mean (auth, id, part, disp)?

  2. #2
    Join Date
    Feb 2007
    Posts
    2
    Rep Power
    8

    Default Problems retriving attachment via SOAP

    Good Morning:

    I need some help to retrieve attachment via SOAP. I'm able to get the message but when I call the GetMsgPartRequest I keep getting an 500 error and it looks like the SOAP server does not even know the tag GetMsgPartRequest

    I'm attaching the XML trace of my requests and responses. Can somebody give me an hint about what I'm doing wrong?

    ================================================== =======

    Message :

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra">
    <sessionId id="58">58</sessionId>
    <change token="2823"/>
    </context>
    </soap:Header>
    <soap:Body>
    <GetMsgResponse xmlns="urn:zimbraMail">
    <m cid="476" d="1170868653000" f="au" id="475" l="2" rev="2822" s="246593" sd="1170867043000">
    <e a="antonio.signore@gmail.com" d="antonio" id="0" p="antonio signore" t="f"/>
    <e a="antonio.signore@maina-software.com" d="antonio" id="1" p="antonio signore" t="t"/>
    <su>Re: pippo</su>
    <mid>&lt;80b323f40702070850ha97a5fcleb4d2fe42ed330 23@mail.gmail.com&gt;</mid>
    <mp ct="multipart/mixed" part="TEXT" s="244362">
    <mp body="1" cd="inline" ct="text/plain" part="1" s="89">
    <content>On 2/7/07, antonio signore &lt;antonio.signore@gmail.com&gt; wrote:
    &gt; progetto di test
    &gt;
    &gt;
    </content>
    </mp>
    <mp cd="attachment" ct="application/vnd.ms-project" filename="progettotest.mpp" part="2" s="179655"/>
    </mp>
    </m>
    </GetMsgResponse>
    </soap:Body>
    </soap:Envelope>


    After that, I try to get the attachment part = "2"

    query = <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra">
    <sessionId id="58"/>
    <change token="1" type="new"/>
    <authToken>0_6b8288a1218ba9503cb103fd6493b4c326442 a7f_69643d33363a33623538396266362d663934612d346630 652d623666332d3036316365633364653464653b6578703d31 333a313137303937303939363039313b61646d696e3d313a31 3b</authToken>
    </context>
    </soap:Header>
    <soap:Body>
    <GetMsgPartRequest xmlns="urn:zimbraMail">
    <m id="475">
    <mp part="2"/>
    </m>
    </GetMsgPartRequest>
    </soap:Body>
    </soap:Envelope>



    And I get back the following error:

    Status:HTTP/1.1 500 Internal Server Error
    Body:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><sessionId id="58">58</sessionId><change token="2823"/></context></soap:Header><soap:Body><soap:Fault><soap:Code><soa p:Value>soap:Sender</soap:Value></soap:Code><soap:Reason><soap:Text>unknown document: GetMsgPartRequest</soap:Text></soap:Reason><soapetail><Error xmlns="urn:zimbra"><Code>service.UNKNOWN_DOCUMENT</Code><Trace>com.zimbra.cs.service.ServiceException : unknown document: GetMsgPartRequest
    at com.zimbra.cs.service.ServiceException.UNKNOWN_DOC UMENT(ServiceException.java:188)
    at com.zimbra.soap.SoapEngine.dispatchRequest(SoapEng ine.java:218)
    at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.jav a:162)
    at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.jav a:84)
    at com.zimbra.soap.SoapServlet.doPost(SoapServlet.jav a:223)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)


    Thanks
    Antonio

  3. #3
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default No such command.

    Quote Originally Posted by antonio.signore View Post
    I need some help to retrieve attachment via SOAP. I'm able to get the message but when I call the GetMsgPartRequest I keep getting an 500 error and it looks like the SOAP server does not even know the tag GetMsgPartRequest
    Exactly correct. There is no such command, and there hasn't been one for a long, long time. Use GetMsgRequest to get the MIME structure of the message, then fetch the attachment from the user servlet (http://server.example.com:port/service/user/~/?id=<message-id>&part=<mime-part>). When you fetch the attachment, remember to either use HTTP basic auth or to attach a valid auth token in a cookie.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  4. #4
    Join Date
    Feb 2007
    Posts
    2
    Rep Power
    8

    Default

    cool.I'll try this.

    Why don't you guys remove out of the soap.txt doc that tag non used anymore?

    Thanks a lot
    Antonio

  5. #5
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default Authenticate!

    Quote Originally Posted by Abak View Post
    We would like to access files, that are attached to e-mails in Zimbra, with our web application.

    If we try a direct link (http://mail.abak.net/service/home/~/...&part=2&disp=a) we get "Access to the specified resource (must authenticate) has been forbidden."
    It means that you need to authenticate before fetching content from the server. You can use basic HTTP auth using your Zimbra id and password, or you can put a valid Zimbra auth token in the ZM_AUTH_TOKEN cookie on your HTTP GET request.

    Quote Originally Posted by Abak View Post
    What do these parameters in URL mean (auth, id, part, disp)?
    Please look at the REST documentation for details first!

    "auth=co" means to use cookie auth only; basic HTTP auth is not allowed on the request if you specify "auth=co". "id=2762" means that you want to fetch item 2762 from the mailbox. "part=2" means you wan the attachment in MIME part 2, not the whole message. And I believe that "disp=a" means that you want to specify "Content-Disposition: attachment" on the HTTP GET response.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  6. #6
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default No GetMsgPart

    Quote Originally Posted by antonio.signore View Post
    Why don't you guys remove out of the soap.txt doc that tag non used anymore?
    It's not there any longer, and it hasn't been there for a number of releases.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  7. #7
    Join Date
    Mar 2006
    Posts
    52
    Rep Power
    9

    Default Problem solved

    dkarp, the solution you describe works great!
    Thank you for help.

Similar Threads

  1. Problems with port 25
    By yogiman in forum Installation
    Replies: 57
    Last Post: 06-13-2011, 01:55 PM
  2. Replies: 7
    Last Post: 02-03-2011, 06:01 AM
  3. fresh install down may be due to tomcat
    By gon in forum Installation
    Replies: 10
    Last Post: 07-25-2007, 08:09 AM
  4. DynDNS and Zimbra
    By afterwego in forum Installation
    Replies: 30
    Last Post: 04-01-2007, 03:34 PM
  5. receiveing mail
    By maybethistime in forum Administrators
    Replies: 15
    Last Post: 12-09-2005, 03:55 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
  •