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 Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-2007, 12:23 AM
Project Contributor
 
Posts: 52
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)?
Reply With Quote
  #2 (permalink)  
Old 02-08-2007, 02:00 AM
Starter Member
 
Posts: 2
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
Reply With Quote
  #3 (permalink)  
Old 02-08-2007, 06:34 AM
Zimbra Employee
 
Posts: 1,434
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!
Reply With Quote
  #4 (permalink)  
Old 02-08-2007, 06:38 AM
Starter Member
 
Posts: 2
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
Reply With Quote
  #5 (permalink)  
Old 02-08-2007, 06:41 AM
Zimbra Employee
 
Posts: 1,434
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!
Reply With Quote
  #6 (permalink)  
Old 02-08-2007, 06:41 AM
Zimbra Employee
 
Posts: 1,434
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!
Reply With Quote
  #7 (permalink)  
Old 02-09-2007, 05:56 AM
Project Contributor
 
Posts: 52
Default Problem solved

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.