Results 1 to 6 of 6

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

Threaded View

  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.

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
  •