Results 1 to 6 of 6

Thread: [SOLVED] Java SOAP Request receiving service.UNKNOWN_DOCUMENT

  1. #1
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default [SOLVED] Java SOAP Request receiving service.UNKNOWN_DOCUMENT

    Answer to this (admin, please correct if needed): sevice.UNKNOWN_DOCUMENT happens when server cannot recognize the request (not sure of other reasons for this error). This can be due to the XML element not being linked to appropriate namespace.

    Here is one way to write XML using namespaces:

    Code:
    <soap:Envelope
    		xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    		xmlns:zimbra="urn:zimbra"
    		xmlns:zaccount="urn:zimbraAccount"
    		xmlns:zmail="urn:zimbraMail"
    		xmlns:zadmin="urn:zimbraAdmin">
    ...
    	<soap:Body>
    		<zaccount:AuthRequest>
    			<account by="name">[USERNAME]</account>
    			<password>[PWD]</password>
    		</zaccount:AuthRequest>
    	</soap:Body>
    ... OR ...
    	<soap:Body>
    		<zmail:GetFreeBusyRequest
    				s="[START_TIME_MS]"
    				e="[END_TIME_MS]"
    				name="[USERNAME]">
    		</zmail:GetFreeBusyRequest>
    	</soap:Body>
    Entering xmlns in envelope creates simple, consistent structure for this; then each element can be entered as shown above.

    - Answer done.

    - - - - - - - - - - - - - - - - - - - - - - - -

    I wrote Java SOAP request and am getting back unknown document from Zimbra 6.0. Below are code, SOAP request being sent, and response. The request is being made to our test server "carmen.egr.msu.edu" for user "user1".

    Please help determine what the problem is, and how to fix it.

    SOAP Request:
    <?xml version="1.0" encoding="UTF-8"?>

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
    <soap:context xmlns:soap="http://carmen.egr.msu.edu/service/soap/" xmlns="urn:zimbraSoap">
    <nonotify xmlns=""></nonotify>
    <noqualify xmlns=""></noqualify>
    </soap:context>
    </soap:Header>
    <soap:Body>
    <soap:AuthRequest xmlns="urn:zimbraSoap">
    <account xmlns="" by="name">user1</account>
    <password xmlns=""></password>
    </soap:AuthRequest>
    <SearchRequest calExpandInstEnd="1256248799000" calExpandInstStar="1193004000000" types="appointment"/>
    </soap:Body>
    </soap:Envelope>
    SOAP Response:
    <?xml version="1.0" encoding="UTF-8"?>

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
    <context xmlns="urn:zimbra"></context>
    </soap:Header>
    <soap:Body>
    <soap:Fault>
    <soap:faultcode>soap:Client</soap:faultcode>
    <soap:faultstring>unknown document: soap:AuthRequest</soap:faultstring>
    <soap:detail>
    <Error xmlns="urn:zimbra">
    <Code>service.UNKNOWN_DOCUMENT</Code>
    <Trace>com.zimbra.common.service.ServiceExceptio n: unknown document: soap:AuthRequest ExceptionId:btpool0-16://carmen.egr.msu.edu/service/soap/:1301322591086:0f0b2eafcb1b26e0 Code:service.UNKNOWN_DOCUMENT at com.zimbra.common.service.ServiceException.UNKNOWN _DOCUMENT(ServiceException.java:262) at com.zimbra.soap.SoapEngine.dispatchRequest(SoapEng ine.java:330) at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.jav a:274) at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.jav a:158) at com.zimbra.soap.SoapServlet.doWork(SoapServlet.jav a:291) at com.zimbra.soap.SoapServlet.doPost(SoapServlet.jav a:212) at javax.servlet.http.HttpServlet.service(HttpServlet .java:727) at com.zimbra.cs.servlet.ZimbraServlet.service(Zimbra Servlet.java:181) at javax.servlet.http.HttpServlet.service(HttpServlet .java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(Ser vletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedCha in.doFilter(ServletHandler.java:1166) at com.zimbra.cs.servlet.SetHeaderFilter.doFilter(Set HeaderFilter.java:79) at org.mortbay.jetty.servlet.ServletHandler$CachedCha in.doFilter(ServletHandler.java:1157) at org.mortbay.servlet.UserAgentFilter.doFilter(UserA gentFilter.java:81) at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter .java:155) at org.mortbay.jetty.servlet.ServletHandler$CachedCha in.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(Se rvletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle( SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(Se ssionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(Co ntextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebA ppContext.java:418) at org.mortbay.jetty.handler.ContextHandlerCollection .handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle (HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(Ha ndlerWrapper.java:152) at org.mortbay.jetty.handler.rewrite.RewriteHandler.h andle(RewriteHandler.java:230) at org.mortbay.jetty.handler.HandlerWrapper.handle(Ha ndlerWrapper.java:152) at org.mortbay.jetty.handler.DebugHandler.handle(Debu gHandler.java:77) at org.mortbay.jetty.handler.HandlerWrapper.handle(Ha ndlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(Htt pConnection.java:543) at org.mortbay.jetty.HttpConnection$RequestHandler.co ntent(HttpConnection.java:939) at org.mortbay.jetty.HttpParser.parseNext(HttpParser. java:755) at org.mortbay.jetty.HttpParser.parseAvailable(HttpPa rser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnec tion.java:405) at org.mortbay.io.nio.SelectChannelEndPoint.run(Selec tChannelEndPoint.java:413) at org.mortbay.thread.BoundedThreadPool$PoolThread.ru n(BoundedThreadPool.java:451)</Trace>
    </Error>
    </soap:detail>
    </soap:Fault>
    </soap:Body>
    </soap:Envelope>

    JAVA:
    Code:
    import java.io.ByteArrayOutputStream;
    import java.net.URL;
    
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.soap.SOAPMessage;
    
    		MessageFactory mf = MessageFactory.newInstance();
    		SOAPMessage sm = mf.createMessage();
    		SOAPEnvelope envelope = sm.getSOAPPart().getEnvelope();
    		envelope.addNamespaceDeclaration("soap", "http://carmen.egr.msu.edu/service/soap/");
    		envelope.setPrefix("soap");
    		envelope.setAttribute("xmlns:soap", "http://carmen.egr.msu.edu/service/soap/");
    		SOAPHeader header = envelope.getHeader();
    		header.setPrefix("soap");
    		SOAPElement context = header.addChildElement("context", "soap");
    		context.setAttribute("xmlns", "urn:zimbraSoap");
    		context.addChildElement("nonotify");
    		context.addChildElement("noqualify");
    		SOAPBody body = envelope.getBody();
    		body.setPrefix("soap");
    		SOAPElement authRequest = body.addChildElement("AuthRequest");
    		authRequest.setPrefix("soap");
    		authRequest.setAttribute("xmlns", "urn:zimbraSoap");
    		SOAPElement account = authRequest.addChildElement("account");
    		account.setAttribute("by", "name");
    		account.setTextContent("user1");
    		SOAPElement password = authRequest.addChildElement("password");
    		password.setTextContent("foo");
    		// Request
    		SOAPElement request = body.addChildElement("SearchRequest");
    		request.setAttribute("types", "appointment");
    		request.setAttribute("calExpandInstStar", "1193004000000");
    		request.setAttribute("calExpandInstEnd", "1256248799000");
    		// Display SOAP Request
    		System.out.println("\nSoap Request: ");
    		writeSoapMessagePretty(sm);
    		// Make request
    		SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
    		SOAPConnection connection = sfc.createConnection();
    		URL requestUrl = new URL("http://carmen.egr.msu.edu/service/soap/");
    		SOAPMessage response = connection.call(sm, requestUrl);
    		// Print SOAP response
    		writeSoapMessagePretty(response);
    Last edited by raymond.naseef; 04-10-2011 at 08:34 AM.

  2. #2
    Join Date
    Apr 2011
    Posts
    15
    Rep Power
    4

    Default

    It seems that there is no way to change the soap namespace in Zimbra java client.

    However, even we use the raw soap api, by:
    SOAPMessage sm = mf.createMessage();
    SOAPEnvelope envelope = sm.getSOAPPart().getEnvelope();
    envelope.addNamespaceDeclaration("soap", "http://www.w3.org/2003/05/soap-envelope");
    envelope.setPrefix("soap");
    envelope.setAttribute("xmlns:soap", "http://www.w3.org/2003/05/soap-envelope");
    SOAPHeader header = envelope.getHeader();
    header.setPrefix("soap");
    SOAPElement context = header.addChildElement("context", "soap");
    context.setAttribute("xmlns", "urn:zimbraSoap");
    context.addChildElement("nonotify");
    context.addChildElement("noqualify");

    There is still an UNKNOWN-DOCUMENT fail error in the soap response.
    Last edited by nickzm; 04-29-2011 at 11:27 PM.

  3. #3
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default Example for SOAP with namespaces

    Here is example of one of our requests; notice the "SOAP" namespace is not changed; each element can have prefix of namespace for it (e.g., <SoapRequest> has <zmail:SearchRequest>).

    That request successfully gets back user's free/busy times in Zimbra v6.0.8.

    Hope this helps,
    Ray

    Code:
    POST /service/soap HTTP/1.1
    Host: carmen.egr.msu.edu
    Content-Type: text/xml; charset="utf-8"
    
    <?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope
    		xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    		xmlns:zimbra="urn:zimbra"
    		xmlns:zaccount="urn:zimbraAccount"
    		xmlns:zmail="urn:zimbraMail">
    	<soap:Header>
    		<zimbra:context xmlns="urn:zimbraSoap">
    			<zaccount:authToken>...</zaccount:authToken>
    			<nonotify/>
    			<noqualify/>
    		</zimbra:context>
    	</soap:Header>
    	<soap:Body>
    		<zmail:SearchRequest
    				types="appointment"
    				calExpandInstStar="1301394794379"
    				calExpandInstEnd="1301452394379">
    			<query>inid:10</query>
    		</zmail:SearchRequest>
    	</soap:Body>
    </soap:Envelope>

  4. #4
    Join Date
    Apr 2011
    Posts
    15
    Rep Power
    4

    Default

    It is resolved by changing the namespace.

  5. #5
    Join Date
    Mar 2012
    Posts
    7
    Rep Power
    3

    Default

    Quote Originally Posted by nickzm View Post
    It is resolved by changing the namespace.
    Which namespace did you change to make it work?

  6. #6
    Join Date
    Mar 2011
    Location
    Lansing, MI
    Posts
    17
    Rep Power
    4

    Default

    Sorry, that sentence is vague. The issue is that namespaces need to be set for certain elements, such as "<SearchRequest" above being set "<zimbra:SearchRequest". If you look at my XML above, the error was for request "<SearchRequest".

Similar Threads

  1. zmzimletctl deploy zimbra_posixaccount.zip - ERROR -
    By todd_dsm in forum Administrators
    Replies: 0
    Last Post: 04-02-2009, 02:41 PM
  2. [SOLVED] Get EMAIL details with SOAP in JAVA
    By rkmorgan in forum Developers
    Replies: 5
    Last Post: 10-11-2007, 10:05 AM
  3. How to consume zimbra SOAP API in my java application
    By Hemant Shrivastava in forum Developers
    Replies: 34
    Last Post: 12-24-2006, 01:24 AM
  4. SOAP Request
    By urban@abak in forum Developers
    Replies: 15
    Last Post: 12-19-2006, 07:28 AM
  5. Replies: 6
    Last Post: 03-17-2006, 10:40 AM

Posting Permissions

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